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