AI 4 月之前
父節點
當前提交
5b91686662
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      app/JsonRpc/ChatService.php

+ 6 - 2
app/JsonRpc/ChatService.php

@@ -702,7 +702,7 @@ class ChatService implements ChatServiceInterface
             $where[] = ['chat_topics.title', 'like', '%' . $data['title'] . '%'];
         }
         if (!empty($data['user_id'])) {
-            $where[] = ['user_id', '=', $data['user_id']];
+            $where[] = ['chat_topics.user_id', '=', $data['user_id']];
         }
         if (!empty($data['status'])) {
             $where[] = ['chat_topics.status', '=', $data['status']];
@@ -716,7 +716,11 @@ class ChatService implements ChatServiceInterface
         var_dump($where);
         $result = ChatTopic::where($where)
             ->leftJoin('user', 'user.id', '=', 'chat_topics.user_id')
-            ->select('chat_topics.*', 'user.nickname', 'user.avatar', 'user.user_name')
+            ->leftJoin('chat_topics_reply', 'chat_topics.id', '=', 'chat_topics_reply.topic_id')
+            ->select('chat_topics.*', 'user.nickname', 'user.avatar', 'user.user_name'
+                ,
+                DB::raw('count(chat_topics_reply.id) as num'))
+            ->groupBy('chat_topics.id')
             ->paginate($data['page_size'], ['*'], 'page', $data['page'] ?? 1);
         return Result::success($result);
     }