tsurumure 6 meses atrás
pai
commit
0a6f77ec69

+ 3 - 0
src/main/java/com/backendsys/modules/ai/chat/controller/ChatController.java

@@ -2,6 +2,7 @@ package com.backendsys.modules.ai.chat.controller;
 
 import com.backendsys.modules.ai.chat.entity.Chat;
 import com.backendsys.modules.ai.chat.service.ChatService;
+import com.backendsys.modules.common.config.security.utils.SecurityUtil;
 import com.backendsys.modules.common.utils.Result;
 import io.swagger.v3.oas.annotations.Operation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -33,6 +34,8 @@ public class ChatController {
     @PreAuthorize("@sr.hasPermission('31')")
     @GetMapping("/api/ai/chat/getChatList")
     public Result getChatList(@Validated(Chat.Detail.class) Chat chat) {
+        chat.setUser_id(SecurityUtil.getUserId());
+        chat.setDel_flag(-1);
         return Result.success().put("data", chatService.selectChatList(chat));
     }
 

+ 3 - 0
src/main/java/com/backendsys/modules/ai/chat/controller/ChatHistoryController.java

@@ -3,6 +3,7 @@ package com.backendsys.modules.ai.chat.controller;
 import com.backendsys.modules.ai.chat.entity.Chat;
 import com.backendsys.modules.ai.chat.entity.ChatHistory;
 import com.backendsys.modules.ai.chat.service.ChatHistoryService;
+import com.backendsys.modules.common.config.security.utils.SecurityUtil;
 import com.backendsys.modules.common.utils.Result;
 import io.swagger.v3.oas.annotations.Operation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -25,6 +26,8 @@ public class ChatHistoryController {
     @GetMapping("/api/ai/chat/getChatHistoryList")
     public Result getChatHistoryList() {
         ChatHistory history = new ChatHistory();
+        history.setUser_id(SecurityUtil.getUserId());
+        history.setDel_flag(-1);
         return Result.success().put("data", chatHistoryService.selectChatHistoryList(history));
     }
 

+ 1 - 0
src/main/java/com/backendsys/modules/ai/chat/entity/Chat.java

@@ -23,6 +23,7 @@ public class Chat {
     @NotEmpty(message = "history_code 不能为空", groups = { Detail.class, Delete.class })
     private String history_code;
 
+    @NotEmpty(message = "model 不能为空", groups = { Create.class })
     @RangeStringArray(message="模型取值有误,范围应是(HUNYUAN, DEEPSEEK)", value = {"HUNYUAN", "DEEPSEEK"}, groups = { Create.class, Update.class })
     private String model;
     private String model_version;

+ 2 - 2
src/main/java/com/backendsys/modules/ai/chat/service/impl/ChatServiceImpl.java

@@ -172,14 +172,14 @@ public class ChatServiceImpl implements ChatService {
         String history_code = chat.getHistory_code();
 
         ChatHistory chatHistory = chatHistoryDao.selectOne(new LambdaQueryWrapper<ChatHistory>()
-                .eq(ChatHistory::getDel_flag, -1)
+                .eq(ChatHistory::getDel_flag, chat.getDel_flag())
                 .eq(ChatHistory::getHistory_code, history_code));
         if (chatHistory == null) throw new CustException("对话历史不存在");
 
         PageUtils.startPage();  // 分页
         LambdaQueryWrapper<Chat> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(Chat::getHistory_code, history_code);
-        wrapper.eq(Chat::getDel_flag, -1);
+        wrapper.eq(Chat::getDel_flag, chat.getDel_flag());
         wrapper.orderByAsc(Chat::getCreate_time);
         List<Chat> list = chatDao.selectList(wrapper);
 

+ 1 - 1
src/main/resources/mapper/ai/chat/ChatHistoryDao.xml

@@ -12,7 +12,7 @@
         ch.create_time,
         ch.update_time
     </sql>
-<!--   java.util.LinkedHashMap -->
+
     <resultMap id="resultMapChatHistory" type="com.backendsys.modules.ai.chat.entity.ChatHistory">
         <id property="id" column="id" jdbcType="BIGINT" />
         <result property="history_code" column="history_code" />