Commit 591002f0593e3d9515634bc870a8c27d690f36ba
1 parent
c44f558e
增加chat role 可见性修改
Showing
2 changed files
with
28 additions
and
7 deletions
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/ChatRoleServiceImpl.java
| ... | ... | @@ -73,22 +73,37 @@ public class ChatRoleServiceImpl implements ChatRoleService { |
| 73 | 73 | ChatRoleVisibilityEnum.valueOfType(req.getVisibility()); |
| 74 | 74 | ChatRoleSourceEnum.valueOfType(req.getRoleSource()); |
| 75 | 75 | // 检查角色是否存在 |
| 76 | - AiChatRoleDO aiChatRoleDO = aiChatRoleMapper.selectById(req.getId()); | |
| 77 | - if (aiChatRoleDO == null) { | |
| 78 | - throw ServiceExceptionUtil.exception(ErrorCodeConstants.AI_CHAT_ROLE_NOT_EXIST); | |
| 79 | - } | |
| 76 | + validateChatRoleExists(req.getId()); | |
| 80 | 77 | // 转换do |
| 81 | 78 | AiChatRoleDO updateChatRole = ChatRoleConvert.INSTANCE.convertAiChatRoleDO(req); |
| 82 | 79 | aiChatRoleMapper.updateById(updateChatRole); |
| 83 | 80 | } |
| 84 | 81 | |
| 82 | + | |
| 85 | 83 | @Override |
| 86 | 84 | public void updateVisibility(ChatRoleUpdateVisibilityReq req) { |
| 87 | - | |
| 85 | + // 转换enum,并校验enum | |
| 86 | + ChatRoleVisibilityEnum.valueOfType(req.getVisibility()); | |
| 87 | + // 检查角色是否存在 | |
| 88 | + validateChatRoleExists(req.getId()); | |
| 89 | + // 更新 | |
| 90 | + aiChatRoleMapper.updateById(new AiChatRoleDO() | |
| 91 | + .setId(req.getId()) | |
| 92 | + .setVisibility(req.getVisibility()) | |
| 93 | + ); | |
| 88 | 94 | } |
| 89 | 95 | |
| 90 | 96 | @Override |
| 91 | 97 | public void delete(Long chatRoleId) { |
| 92 | 98 | |
| 93 | 99 | } |
| 100 | + | |
| 101 | + private AiChatRoleDO validateChatRoleExists(Long id) { | |
| 102 | + AiChatRoleDO aiChatRoleDO = aiChatRoleMapper.selectById(id); | |
| 103 | + if (aiChatRoleDO == null) { | |
| 104 | + throw ServiceExceptionUtil.exception(ErrorCodeConstants.AI_CHAT_ROLE_NOT_EXIST); | |
| 105 | + } | |
| 106 | + return aiChatRoleDO; | |
| 107 | + } | |
| 108 | + | |
| 94 | 109 | } | ... | ... |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleUpdateVisibilityReq.java
| ... | ... | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.ai.vo; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | +import jakarta.validation.constraints.NotNull; | |
| 5 | 6 | import lombok.Data; |
| 6 | 7 | import lombok.experimental.Accessors; |
| 7 | 8 | |
| ... | ... | @@ -15,6 +16,11 @@ import lombok.experimental.Accessors; |
| 15 | 16 | @Accessors(chain = true) |
| 16 | 17 | public class ChatRoleUpdateVisibilityReq extends PageParam { |
| 17 | 18 | |
| 18 | - @Schema(description = "查询") | |
| 19 | - private String search; | |
| 19 | + @NotNull | |
| 20 | + @Schema(description = "编号") | |
| 21 | + private Long id; | |
| 22 | + | |
| 23 | + @NotNull | |
| 24 | + @Schema(description = "发布状态,0表示仅自己可见,1表示公开,2表示禁用") | |
| 25 | + private String visibility; | |
| 20 | 26 | } | ... | ... |