chat角色增加 add 方法

This commit is contained in:
cherishsince 2024-04-24 17:09:24 +08:00
parent 410893bc29
commit 4cc87539d8
3 changed files with 25 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.ai.convert;
import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatRoleDO;
import cn.iocoder.yudao.module.ai.vo.ChatRoleAddReq;
import cn.iocoder.yudao.module.ai.vo.ChatRoleListRes;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@ -26,4 +27,12 @@ public interface ChatRoleConvert {
* @return
*/
List<ChatRoleListRes> convertChatRoleListRes(List<AiChatRoleDO> roleList);
/**
* 转换 - AiChatRoleDO
*
* @param req
* @return
*/
AiChatRoleDO convertAiChatRoleDO(ChatRoleAddReq req);
}

View File

@ -28,7 +28,7 @@ public interface ChatRoleService {
* @param req
* @return
*/
ChatRoleListRes add(ChatRoleAddReq req);
void add(ChatRoleAddReq req);
/**
* chat角色 - 修改

View File

@ -3,8 +3,12 @@ package cn.iocoder.yudao.module.ai.service.impl;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.ai.convert.ChatRoleConvert;
import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatRoleDO;
import cn.iocoder.yudao.module.ai.enums.ChatRoleClassifyEnum;
import cn.iocoder.yudao.module.ai.enums.ChatRoleSourceEnum;
import cn.iocoder.yudao.module.ai.enums.ChatRoleVisibilityEnum;
import cn.iocoder.yudao.module.ai.mapper.AiChatRoleMapper;
import cn.iocoder.yudao.module.ai.service.ChatRoleService;
import cn.iocoder.yudao.module.ai.vo.*;
@ -47,8 +51,17 @@ public class ChatRoleServiceImpl implements ChatRoleService {
}
@Override
public ChatRoleListRes add(ChatRoleAddReq req) {
return null;
public void add(ChatRoleAddReq req) {
// 转换enum并校验enum
ChatRoleClassifyEnum.valueOfClassify(req.getClassify());
ChatRoleVisibilityEnum.valueOfType(req.getVisibility());
ChatRoleSourceEnum.valueOfType(req.getRoleSource());
// 转换do
AiChatRoleDO insertAiChatRoleDO = ChatRoleConvert.INSTANCE.convertAiChatRoleDO(req);
insertAiChatRoleDO.setUserId(SecurityFrameworkUtils.getLoginUserId());
insertAiChatRoleDO.setUseCount(0);
// 保存
aiChatRoleMapper.insert(insertAiChatRoleDO);
}
@Override