mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-06-22 08:22:00 +08:00
测试 role,列表和添加
This commit is contained in:
parent
3556e460e7
commit
a0b3bd32b0
@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
*/
|
*/
|
||||||
@Tag(name = "A4-chat角色")
|
@Tag(name = "A4-chat角色")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/ai/chat/role")
|
@RequestMapping("/ai/chat")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class ChatRoleController {
|
public class ChatRoleController {
|
||||||
@ -27,34 +27,35 @@ public class ChatRoleController {
|
|||||||
private final ChatRoleService chatRoleService;
|
private final ChatRoleService chatRoleService;
|
||||||
|
|
||||||
@Operation(summary = "chat角色 - 角色列表")
|
@Operation(summary = "chat角色 - 角色列表")
|
||||||
@GetMapping("/list")
|
@GetMapping("/role/list")
|
||||||
public PageResult<ChatRoleListRes> list(@Validated @ModelAttribute ChatRoleListReq req) {
|
public PageResult<ChatRoleListRes> list(@Validated @ModelAttribute ChatRoleListReq req) {
|
||||||
return chatRoleService.list(req);
|
return chatRoleService.list(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "chat角色 - 添加")
|
@Operation(summary = "chat角色 - 添加")
|
||||||
@PutMapping("/add")
|
@PutMapping("/role")
|
||||||
public CommonResult<Void> add(@Validated @RequestBody ChatRoleAddReq req) {
|
public CommonResult<Void> add(@Validated @RequestBody ChatRoleAddReq req) {
|
||||||
chatRoleService.add(req);
|
chatRoleService.add(req);
|
||||||
return CommonResult.success(null);
|
return CommonResult.success(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "chat角色 - 修改")
|
@Operation(summary = "chat角色 - 修改")
|
||||||
@PostMapping("/update")
|
@PostMapping("/role/{id}")
|
||||||
public CommonResult<Void> update(@Validated @RequestBody ChatRoleUpdateReq req) {
|
public CommonResult<Void> update(@PathVariable("id") Long id,
|
||||||
chatRoleService.update(req);
|
@Validated @RequestBody ChatRoleUpdateReq req) {
|
||||||
|
chatRoleService.update(id, req);
|
||||||
return CommonResult.success(null);
|
return CommonResult.success(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "chat角色 - 修改可见性")
|
@Operation(summary = "chat角色 - 修改可见性")
|
||||||
@PostMapping("/update-visibility")
|
@PostMapping("/role/update-visibility")
|
||||||
public CommonResult<Void> updateVisibility(@Validated @RequestBody ChatRoleUpdateVisibilityReq req) {
|
public CommonResult<Void> updateVisibility(@Validated @RequestBody ChatRoleUpdateVisibilityReq req) {
|
||||||
chatRoleService.updateVisibility(req);
|
chatRoleService.updateVisibility(req);
|
||||||
return CommonResult.success(null);
|
return CommonResult.success(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "chat角色 - 修改可见性")
|
@Operation(summary = "chat角色 - 修改可见性")
|
||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/role")
|
||||||
public CommonResult<Void> delete(@RequestParam("chatRoleId") Long chatRoleId) {
|
public CommonResult<Void> delete(@RequestParam("chatRoleId") Long chatRoleId) {
|
||||||
chatRoleService.delete(chatRoleId);
|
chatRoleService.delete(chatRoleId);
|
||||||
return CommonResult.success(null);
|
return CommonResult.success(null);
|
||||||
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.ai.dal.dataobject;
|
|||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
@ -14,6 +15,7 @@ import lombok.experimental.Accessors;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
|
@TableName("ai_chat_role")
|
||||||
public class AiChatRoleDO extends BaseDO {
|
public class AiChatRoleDO extends BaseDO {
|
||||||
/**
|
/**
|
||||||
* 编号,表示聊天角色在数据库中的唯一标识符
|
* 编号,表示聊天角色在数据库中的唯一标识符
|
||||||
@ -52,7 +54,7 @@ public class AiChatRoleDO extends BaseDO {
|
|||||||
private String classify;
|
private String classify;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发布状态,0表示仅自己可见,1表示公开,2表示禁用
|
* 发布状态,private 表示仅自己可见,public表示公开,disable表示禁用
|
||||||
*/
|
*/
|
||||||
private String visibility;
|
private String visibility;
|
||||||
|
|
||||||
|
@ -33,9 +33,10 @@ public interface ChatRoleService {
|
|||||||
/**
|
/**
|
||||||
* chat角色 - 修改
|
* chat角色 - 修改
|
||||||
*
|
*
|
||||||
|
* @param id
|
||||||
* @param req
|
* @param req
|
||||||
*/
|
*/
|
||||||
void update(ChatRoleUpdateReq req);
|
void update(Long id, ChatRoleUpdateReq req);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,15 +67,16 @@ public class ChatRoleServiceImpl implements ChatRoleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(ChatRoleUpdateReq req) {
|
public void update(Long id, ChatRoleUpdateReq req) {
|
||||||
// 转换enum,并校验enum
|
// 转换enum,并校验enum
|
||||||
ChatRoleClassifyEnum.valueOfClassify(req.getClassify());
|
ChatRoleClassifyEnum.valueOfClassify(req.getClassify());
|
||||||
ChatRoleVisibilityEnum.valueOfType(req.getVisibility());
|
ChatRoleVisibilityEnum.valueOfType(req.getVisibility());
|
||||||
ChatRoleSourceEnum.valueOfType(req.getRoleSource());
|
ChatRoleSourceEnum.valueOfType(req.getRoleSource());
|
||||||
// 检查角色是否存在
|
// 检查角色是否存在
|
||||||
validateChatRoleExists(req.getId());
|
validateChatRoleExists(id);
|
||||||
// 转换do
|
// 转换do
|
||||||
AiChatRoleDO updateChatRole = ChatRoleConvert.INSTANCE.convertAiChatRoleDO(req);
|
AiChatRoleDO updateChatRole = ChatRoleConvert.INSTANCE.convertAiChatRoleDO(req);
|
||||||
|
updateChatRole.setId(id);
|
||||||
aiChatRoleMapper.updateById(updateChatRole);
|
aiChatRoleMapper.updateById(updateChatRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public class ChatRoleAddReq extends PageParam {
|
|||||||
private String classify;
|
private String classify;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Schema(description = "发布状态,0表示仅自己可见,1表示公开,2表示禁用")
|
@Schema(description = "发布状态,private 表示仅自己可见,public表示公开,disable表示禁用\n")
|
||||||
private String visibility;
|
private String visibility;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@ -16,11 +16,6 @@ import lombok.experimental.Accessors;
|
|||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class ChatRoleUpdateReq extends PageParam {
|
public class ChatRoleUpdateReq extends PageParam {
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Schema(description = "编号")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Schema(description = "模型编号,关联到角色使用的特定模型")
|
@Schema(description = "模型编号,关联到角色使用的特定模型")
|
||||||
private String modelId;
|
private String modelId;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user