增加chat role 可见性修改

This commit is contained in:
cherishsince 2024-04-24 17:19:34 +08:00
parent c44f558e3d
commit 591002f059
2 changed files with 28 additions and 7 deletions

View File

@ -73,22 +73,37 @@ public class ChatRoleServiceImpl implements ChatRoleService {
ChatRoleVisibilityEnum.valueOfType(req.getVisibility());
ChatRoleSourceEnum.valueOfType(req.getRoleSource());
// 检查角色是否存在
AiChatRoleDO aiChatRoleDO = aiChatRoleMapper.selectById(req.getId());
if (aiChatRoleDO == null) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.AI_CHAT_ROLE_NOT_EXIST);
}
validateChatRoleExists(req.getId());
// 转换do
AiChatRoleDO updateChatRole = ChatRoleConvert.INSTANCE.convertAiChatRoleDO(req);
aiChatRoleMapper.updateById(updateChatRole);
}
@Override
public void updateVisibility(ChatRoleUpdateVisibilityReq req) {
// 转换enum并校验enum
ChatRoleVisibilityEnum.valueOfType(req.getVisibility());
// 检查角色是否存在
validateChatRoleExists(req.getId());
// 更新
aiChatRoleMapper.updateById(new AiChatRoleDO()
.setId(req.getId())
.setVisibility(req.getVisibility())
);
}
@Override
public void delete(Long chatRoleId) {
}
private AiChatRoleDO validateChatRoleExists(Long id) {
AiChatRoleDO aiChatRoleDO = aiChatRoleMapper.selectById(id);
if (aiChatRoleDO == null) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.AI_CHAT_ROLE_NOT_EXIST);
}
return aiChatRoleDO;
}
}

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.ai.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.experimental.Accessors;
@ -15,6 +16,11 @@ import lombok.experimental.Accessors;
@Accessors(chain = true)
public class ChatRoleUpdateVisibilityReq extends PageParam {
@Schema(description = "查询")
private String search;
@NotNull
@Schema(description = "编号")
private Long id;
@NotNull
@Schema(description = "发布状态0表示仅自己可见1表示公开2表示禁用")
private String visibility;
}