Browse Source

开发清空聊天历史功能提交

zsy 3 tuần trước cách đây
mục cha
commit
26d65d4f0c

+ 5 - 0
src/main/java/com/rf/AIquantum/dialogue/dao/repository/ChatHistoryRepository.java

@@ -33,4 +33,9 @@ public interface ChatHistoryRepository extends BaseRepository<ChatHistoryEntity,
     @Modifying
     @Query(value = "DELETE FROM t_chat_history WHERE dialogue_id = ?1 AND create_time >= ?2  ", nativeQuery = true)
     void deleteByDialogueIdAndCreateTime(String dialogueId, String createTime);
+
+    @Transactional
+    @Modifying
+    @Query(value = "DELETE FROM t_chat_history WHERE dialogue_id = ?1 ", nativeQuery = true)
+    void deleteByDialogueId(String dialogueId);
 }

+ 7 - 0
src/main/java/com/rf/AIquantum/dialogue/rest/ChatHistoryController.java

@@ -110,4 +110,11 @@ public class ChatHistoryController extends BaseController {
         return success(chatHistoryEntity);
     }
 
+    @GetMapping("/clearChats")
+    @ApiOperation(value = "清空聊天记录",notes = "参数包括:dialogueId:对话id")
+    public Result clearChats(@RequestParam String dialogueId){
+        this.chatHistoryService.deleteByDialogueId(dialogueId);
+        return success();
+    }
+
 }

+ 2 - 0
src/main/java/com/rf/AIquantum/dialogue/service/ChatHistoryService.java

@@ -20,4 +20,6 @@ public interface ChatHistoryService {
     Page<ChatHistoryEntity> findByDialogueIdAndStatus(int pageNum, int pageSize, String dialogueId, int status);
 
     void deleteByDialogueIdAndCreateTime(String dialogueId, String createTime);
+
+    void deleteByDialogueId(String dialogueId);
 }

+ 5 - 0
src/main/java/com/rf/AIquantum/dialogue/service/impl/ChatHistoryServiceImpl.java

@@ -47,4 +47,9 @@ public class ChatHistoryServiceImpl implements ChatHistoryService {
     public void deleteByDialogueIdAndCreateTime(String dialogueId, String createTime) {
         this.chatHistoryRepository.deleteByDialogueIdAndCreateTime(dialogueId,createTime);
     }
+
+    @Override
+    public void deleteByDialogueId(String dialogueId) {
+        this.chatHistoryRepository.deleteByDialogueId(dialogueId);
+    }
 }