rkljw 16 tuntia sitten
vanhempi
sitoutus
74f73b3fa4
2 muutettua tiedostoa jossa 34 lisäystä ja 0 poistoa
  1. 33 0
      app/JsonRpc/ChatService.php
  2. 1 0
      app/JsonRpc/ChatServiceInterface.php

+ 33 - 0
app/JsonRpc/ChatService.php

@@ -1165,4 +1165,37 @@ class ChatService implements ChatServiceInterface
         $result = ChatTopicClass::where(['id' => $data['id']])->first();
         return Result::success($result);
     }
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getBusinessDistrictList(array $data): array
+    {
+        $query = ChatGroupsMember::innerJoin('chat_topics', 'chat_topics.group_id', '=', 'chat_groups_member.group_id')
+            ->leftJoin('chat_topic_class', 'chat_topic_class.id', '=', 'chat_topics.type')
+            ->where(['chat_groups_member.user_id' => $data['user_id']])
+            ->when($data, function ($query) use ($data) {
+                if(!empty($data['type'])){
+                    $query->where(['chat_topics.type' => $data['type']]);
+                }
+                if(!empty($data['title'])){
+                    $query->where(['chat_topics.title','like','%'.$data['title'].'%']);
+                }
+                if(!empty($data['created_at'])){
+                    $query->whereDate('chat_topics.created_at', $data['created_at']);
+                }
+            })
+            ->select('chat_topics.*', 'chat_topic_class.topicname')
+            ->orderBy('chat_topics.created_at', 'desc');
+            $total = $query->count();
+            $list = $query->forPage($data['page'], $data['page_size'])->get();
+            $result = [
+                'list' => $list,
+                'total' => $total,
+                'page' => $data['page'],
+                'page_size' => $data['page_size'],
+            ];
+        return  Result::success($result);
+    }
 }

+ 1 - 0
app/JsonRpc/ChatServiceInterface.php

@@ -222,5 +222,6 @@ interface ChatServiceInterface
     public function updateTopicClass(array $data): array;
     public function deleteTopicClass(array $data): array;
     public function getTopicClassInfo(array $data): array;
+    public function getBusinessDistrictList(array $data): array;
 
 }