浏览代码

修改接口:自助建站-ai会话-删除聊天记录

FengR 1 月之前
父节点
当前提交
cdd170a86b
共有 2 个文件被更改,包括 19 次插入4 次删除
  1. 17 4
      app/JsonRpc/PublicRpcService.php
  2. 2 0
      app/JsonRpc/PublicRpcServiceInterface.php

+ 17 - 4
app/JsonRpc/PublicRpcService.php

@@ -4556,16 +4556,29 @@ class PublicRpcService implements PublicRpcServiceInterface
      */
     public function delAiChatRecord(array $data): array
     {
-        $chat_id = $data['chat_id'];
+        $session_id = $data['session_id'];
         $user_id = $data['user_id'];
-        $chat = AiChat::where('chat_id',$chat_id)->where('user_id',$user_id)->first();
+        $chat = AiChat::where('session_id',$session_id)->where('user_id',$user_id)->orderBy('send_time','desc')->first();
         if(empty($chat)){
             return Result::error('此用户的聊天记录不存在!');
         }
-        $del_chat = AiChat::where('chat_id',$chat_id)->where('user_id',$user_id)->delete();
+        $del_chat = AiChat::where('chat_id',$chat['chat_id'])->where('user_id',$user_id)->delete();
         if(empty($del_chat)){
             return Result::error('删除失败!');
         }
-        return Result::success(['删除成功']);
+        return Result::success('删除成功'.$chat['chat_id']);
+    }
+    /**
+     * 自助建站-ai会话-给模板添加导航
+     */
+    public function addTemplateCates(array $data): array
+    {
+        $session_id = $data['session_id'];
+        $user_id = $data['user_id'];
+        $chat = AiChat::where('session_id',$session_id)->where('user_id',$user_id)->orderBy('send_time','asc')->get()->all();
+        if(empty($chat)){
+            return Result::error('此用户的聊天记录不存在!');
+        }
+        return Result::success($chat);
     }
 }

+ 2 - 0
app/JsonRpc/PublicRpcServiceInterface.php

@@ -248,4 +248,6 @@ interface PublicRpcServiceInterface
     public function getAITemplate(array $data): array;
     //自助建站-ai会话-删除聊天记录
     public function delAiChatRecord(array $data): array;
+    // 自助建站-ai会话-给模板添加导航
+    public function addTemplateCates(array $data): array;
 }