From fe63bda4c7afc96dabe9da560777b31089b7c984 Mon Sep 17 00:00:00 2001 From: cherishsince Date: Thu, 16 May 2024 12:10:03 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=A2=9E=E5=8A=A0=E3=80=91=E6=B8=85?= =?UTF-8?q?=E7=A9=BA=20Chat=20=E5=AF=B9=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/chat/AiChatConversationController.java | 7 +++++++ .../service/chat/AiChatConversationService.java | 6 ++++++ .../chat/AiChatConversationServiceImpl.java | 16 +++++++++++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/AiChatConversationController.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/AiChatConversationController.java index 6838fcf5b..9d0cd74c8 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/AiChatConversationController.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/AiChatConversationController.java @@ -69,6 +69,13 @@ public class AiChatConversationController { return success(true); } + @DeleteMapping("/delete-my-all-except-pinned") + @Operation(summary = "删除所有对话(置顶除外)") + @Parameter(name = "id", required = true, description = "会话编号", example = "1024") + public CommonResult deleteMyAllExceptPinned() { + chatConversationService.deleteMyAllExceptPinned(getLoginUserId()); + return success(true); + } // ========== 会话管理 ========== } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/chat/AiChatConversationService.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/chat/AiChatConversationService.java index a17b173e5..f93572e66 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/chat/AiChatConversationService.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/chat/AiChatConversationService.java @@ -62,4 +62,10 @@ public interface AiChatConversationService { */ AiChatConversationDO validateExists(Long id); + /** + * 删除 - 所有对话,置顶除外 + * + * @param loginUserId + */ + void deleteMyAllExceptPinned(Long loginUserId); } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/chat/AiChatConversationServiceImpl.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/chat/AiChatConversationServiceImpl.java index f209a700f..85dd57afd 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/chat/AiChatConversationServiceImpl.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/chat/AiChatConversationServiceImpl.java @@ -4,8 +4,8 @@ import cn.hutool.core.lang.Assert; import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.ai.controller.admin.chat.vo.conversation.AiChatConversationCreateMyReqVO; -import cn.iocoder.yudao.module.ai.controller.admin.chat.vo.conversation.AiChatConversationRespVO; import cn.iocoder.yudao.module.ai.controller.admin.chat.vo.conversation.AiChatConversationUpdateMyReqVO; import cn.iocoder.yudao.module.ai.dal.dataobject.chat.AiChatConversationDO; import cn.iocoder.yudao.module.ai.dal.dataobject.model.AiChatModelDO; @@ -21,8 +21,9 @@ import org.springframework.validation.annotation.Validated; import java.time.LocalDateTime; import java.util.List; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.*; -import static cn.iocoder.yudao.module.ai.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.ai.ErrorCodeConstants.CHAT_CONVERSATION_MODEL_ERROR; +import static cn.iocoder.yudao.module.ai.ErrorCodeConstants.CHAT_CONVERSATION_NOT_EXISTS; /** * AI 聊天对话 Service 实现类 @@ -124,4 +125,13 @@ public class AiChatConversationServiceImpl implements AiChatConversationService return conversation; } + @Override + public void deleteMyAllExceptPinned(Long loginUserId) { + chatConversationMapper.delete( + new LambdaQueryWrapperX() + .eq(AiChatConversationDO::getUserId, loginUserId) + .eq(AiChatConversationDO::getPinned, false) + ); + } + }