Commit 7fae5c0a7d5f8d04bd05db9c98d2d402865a22a3
1 parent
8de98a15
【优化】删除没用的 chat message service
Showing
2 changed files
with
0 additions
and
99 deletions
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatMessageService.java deleted
| 1 | -package cn.iocoder.yudao.module.ai.service; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | -import cn.iocoder.yudao.module.ai.controller.admin.chat.vo.message.AiChatMessageRespVO; | |
| 5 | - | |
| 6 | -/** | |
| 7 | - * chat message | |
| 8 | - * | |
| 9 | - * @author fansili | |
| 10 | - * @time 2024/4/24 17:25 | |
| 11 | - * @since 1.0 | |
| 12 | - */ | |
| 13 | -public interface AiChatMessageService { | |
| 14 | - | |
| 15 | - /** | |
| 16 | - * message - 列表 | |
| 17 | - * | |
| 18 | - * @param req | |
| 19 | - * @return | |
| 20 | - */ | |
| 21 | - PageResult<AiChatMessageRespVO> list(AiChatMessageReq req); | |
| 22 | - | |
| 23 | - /** | |
| 24 | - * message - 删除 | |
| 25 | - * | |
| 26 | - * @param chatConversationId | |
| 27 | - * @param id | |
| 28 | - */ | |
| 29 | - void delete(Long chatConversationId, Long id); | |
| 30 | -} |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatMessageServiceImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.ai.service.impl; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; | |
| 4 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | -import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; | |
| 7 | -import cn.iocoder.yudao.module.ai.ErrorCodeConstants; | |
| 8 | -import cn.iocoder.yudao.module.ai.convert.AiChatMessageConvert; | |
| 9 | -import cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatConversationDO; | |
| 10 | -import cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatMessageDO; | |
| 11 | -import cn.iocoder.yudao.module.ai.dal.mysql.AiChatConversationMapper; | |
| 12 | -import cn.iocoder.yudao.module.ai.dal.mysql.AiChatMessageMapper; | |
| 13 | -import cn.iocoder.yudao.module.ai.service.AiChatMessageService; | |
| 14 | -import cn.iocoder.yudao.module.ai.controller.admin.chat.vo.message.AiChatMessageRespVO; | |
| 15 | -import lombok.AllArgsConstructor; | |
| 16 | -import lombok.extern.slf4j.Slf4j; | |
| 17 | -import org.springframework.stereotype.Service; | |
| 18 | - | |
| 19 | -import java.util.List; | |
| 20 | - | |
| 21 | -/** | |
| 22 | - * chat message | |
| 23 | - * | |
| 24 | - * @author fansili | |
| 25 | - * @time 2024/4/24 17:25 | |
| 26 | - * @since 1.0 | |
| 27 | - */ | |
| 28 | -@AllArgsConstructor | |
| 29 | -@Service | |
| 30 | -@Slf4j | |
| 31 | -public class AiChatMessageServiceImpl implements AiChatMessageService { | |
| 32 | - | |
| 33 | - private final AiChatMessageMapper aiChatMessageMapper; | |
| 34 | - private final AiChatConversationMapper aiChatConversationMapper; | |
| 35 | - | |
| 36 | - @Override | |
| 37 | - public PageResult<AiChatMessageRespVO> list(AiChatMessageReq req) { | |
| 38 | - // 查询 | |
| 39 | - LambdaQueryWrapperX<AiChatMessageDO> queryWrapperX = new LambdaQueryWrapperX<>(); | |
| 40 | - queryWrapperX.eq(AiChatMessageDO::getConversationId, req.getChatConversationId()); | |
| 41 | - // 默认排序 | |
| 42 | - queryWrapperX.orderByDesc(AiChatMessageDO::getId); | |
| 43 | - PageResult<AiChatMessageDO> pageResult = aiChatMessageMapper.selectPage(req, queryWrapperX); | |
| 44 | - // 转换 res | |
| 45 | - List<AiChatMessageRespVO> messageListResList = AiChatMessageConvert.INSTANCE.convert(pageResult.getList()); | |
| 46 | - return new PageResult(messageListResList, pageResult.getTotal()); | |
| 47 | - } | |
| 48 | - | |
| 49 | - @Override | |
| 50 | - public void delete(Long chatConversationId, Long id) { | |
| 51 | - // 获取登录用户 | |
| 52 | - Long loginUserId = SecurityFrameworkUtils.getLoginUserId(); | |
| 53 | - // 校验 ChatConversation | |
| 54 | - validateChatConversation(chatConversationId, loginUserId); | |
| 55 | - // 删除 | |
| 56 | - aiChatMessageMapper.deleteByConversationAndId(chatConversationId, id); | |
| 57 | - } | |
| 58 | - | |
| 59 | - private AiChatConversationDO validateChatConversation(Long chatConversationId, Long loginUserId) { | |
| 60 | - AiChatConversationDO aiChatConversationDO = aiChatConversationMapper.selectById(chatConversationId); | |
| 61 | - if (aiChatConversationDO == null) { | |
| 62 | - throw ServiceExceptionUtil.exception(ErrorCodeConstants.AI_CHAT_CONTINUE_NOT_EXIST); | |
| 63 | - } | |
| 64 | - if (!aiChatConversationDO.getUserId().equals(loginUserId)) { | |
| 65 | - throw ServiceExceptionUtil.exception(ErrorCodeConstants.AI_CHAT_CONVERSATION_NOT_YOURS); | |
| 66 | - } | |
| 67 | - return aiChatConversationDO; | |
| 68 | - } | |
| 69 | -} |