From 7fae5c0a7d5f8d04bd05db9c98d2d402865a22a3 Mon Sep 17 00:00:00 2001 From: cherishsince Date: Tue, 7 May 2024 11:00:49 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=B2=A1=E7=94=A8=E7=9A=84=20chat=20message=20service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ai/service/AiChatMessageService.java | 30 -------- .../impl/AiChatMessageServiceImpl.java | 69 ------------------- 2 files changed, 99 deletions(-) delete mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatMessageService.java delete mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatMessageServiceImpl.java diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatMessageService.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatMessageService.java deleted file mode 100644 index 77450c63b..000000000 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatMessageService.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.ai.service; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.ai.controller.admin.chat.vo.message.AiChatMessageRespVO; - -/** - * chat message - * - * @author fansili - * @time 2024/4/24 17:25 - * @since 1.0 - */ -public interface AiChatMessageService { - - /** - * message - 列表 - * - * @param req - * @return - */ - PageResult list(AiChatMessageReq req); - - /** - * message - 删除 - * - * @param chatConversationId - * @param id - */ - void delete(Long chatConversationId, Long id); -} diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatMessageServiceImpl.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatMessageServiceImpl.java deleted file mode 100644 index 2c86aa8a1..000000000 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatMessageServiceImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.module.ai.service.impl; - -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; -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.ErrorCodeConstants; -import cn.iocoder.yudao.module.ai.convert.AiChatMessageConvert; -import cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatConversationDO; -import cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatMessageDO; -import cn.iocoder.yudao.module.ai.dal.mysql.AiChatConversationMapper; -import cn.iocoder.yudao.module.ai.dal.mysql.AiChatMessageMapper; -import cn.iocoder.yudao.module.ai.service.AiChatMessageService; -import cn.iocoder.yudao.module.ai.controller.admin.chat.vo.message.AiChatMessageRespVO; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * chat message - * - * @author fansili - * @time 2024/4/24 17:25 - * @since 1.0 - */ -@AllArgsConstructor -@Service -@Slf4j -public class AiChatMessageServiceImpl implements AiChatMessageService { - - private final AiChatMessageMapper aiChatMessageMapper; - private final AiChatConversationMapper aiChatConversationMapper; - - @Override - public PageResult list(AiChatMessageReq req) { - // 查询 - LambdaQueryWrapperX queryWrapperX = new LambdaQueryWrapperX<>(); - queryWrapperX.eq(AiChatMessageDO::getConversationId, req.getChatConversationId()); - // 默认排序 - queryWrapperX.orderByDesc(AiChatMessageDO::getId); - PageResult pageResult = aiChatMessageMapper.selectPage(req, queryWrapperX); - // 转换 res - List messageListResList = AiChatMessageConvert.INSTANCE.convert(pageResult.getList()); - return new PageResult(messageListResList, pageResult.getTotal()); - } - - @Override - public void delete(Long chatConversationId, Long id) { - // 获取登录用户 - Long loginUserId = SecurityFrameworkUtils.getLoginUserId(); - // 校验 ChatConversation - validateChatConversation(chatConversationId, loginUserId); - // 删除 - aiChatMessageMapper.deleteByConversationAndId(chatConversationId, id); - } - - private AiChatConversationDO validateChatConversation(Long chatConversationId, Long loginUserId) { - AiChatConversationDO aiChatConversationDO = aiChatConversationMapper.selectById(chatConversationId); - if (aiChatConversationDO == null) { - throw ServiceExceptionUtil.exception(ErrorCodeConstants.AI_CHAT_CONTINUE_NOT_EXIST); - } - if (!aiChatConversationDO.getUserId().equals(loginUserId)) { - throw ServiceExceptionUtil.exception(ErrorCodeConstants.AI_CHAT_CONVERSATION_NOT_YOURS); - } - return aiChatConversationDO; - } -}