mirror of
				https://github.com/YunaiV/ruoyi-vue-pro.git
				synced 2025-10-31 02:28:03 +08:00 
			
		
		
		
	【优化】删除没用的 chat message service
This commit is contained in:
		| @ -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<AiChatMessageRespVO> list(AiChatMessageReq req); | ||||
|  | ||||
|     /** | ||||
|      * message - 删除 | ||||
|      * | ||||
|      * @param chatConversationId | ||||
|      * @param id | ||||
|      */ | ||||
|     void delete(Long chatConversationId, Long id); | ||||
| } | ||||
| @ -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<AiChatMessageRespVO> list(AiChatMessageReq req) { | ||||
|         // 查询 | ||||
|         LambdaQueryWrapperX<AiChatMessageDO> queryWrapperX = new LambdaQueryWrapperX<>(); | ||||
|         queryWrapperX.eq(AiChatMessageDO::getConversationId, req.getChatConversationId()); | ||||
|         // 默认排序 | ||||
|         queryWrapperX.orderByDesc(AiChatMessageDO::getId); | ||||
|         PageResult<AiChatMessageDO> pageResult = aiChatMessageMapper.selectPage(req, queryWrapperX); | ||||
|         // 转换 res | ||||
|         List<AiChatMessageRespVO> 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; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 cherishsince
					cherishsince