Kaynağa Gözat

Merge branch 'develop'

wzq 5 yıl önce
ebeveyn
işleme
5ba983ef73

+ 15 - 0
app/Http/Controllers/Post/PostController.php

@@ -143,6 +143,21 @@ class PostController extends Controller
         return $this->postRepository->getType($request->all());
     }
 
+    /**
+     * 获取关注分类用户uids
+     */
+    public function getCategoryUids(Request $request)
+    {
+        $validator = Validator::make($request->all(), [
+            'category' => 'required|string'
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+
+        return $this->postRepository->getCategoryUids($request->all());
+    }
+
     /**
      * 评论列表
      */

+ 20 - 0
app/Repositories/Post/PostRepository.php

@@ -11,6 +11,7 @@ namespace App\Repositories\Post;
 
 use App\Models\Behavior;
 use App\Models\CategoryTopic;
+use App\Models\MemberFollowTopic;
 use App\Models\Post;
 use App\Models\PostComment;
 use App\Models\PostData;
@@ -47,6 +48,7 @@ class PostRepository
                                 RabbitMqUtil $rabbitMqUtil,
                                 Behavior $behavior,
                                 CategoryTopic $categoryTopic,
+                                MemberFollowTopic $memberFollowTopic,
                                 PostStatistics $postStatistics,
                                 PostStore $postStore,
                                 PostStoreImgs $postStoreImgs,
@@ -60,6 +62,7 @@ class PostRepository
         $this->rabbitMqUtil = $rabbitMqUtil;
         $this->behavior = $behavior;
         $this->categoryTopic = $categoryTopic;
+        $this->memberFollowTopic = $memberFollowTopic;
         $this->topic = $topic;
         $this->postStatistics = $postStatistics;
         $this->postStore = $postStore;
@@ -603,6 +606,23 @@ class PostRepository
         ]);
     }
 
+    /**
+     * 获取关注分类用户uids
+     */
+    public function getCategoryUids($request)
+    {
+        $categoryIds = json_decode($request['category'], true);
+        $topicIds = $this->categoryTopic->whereIn('category_id', $categoryIds)->pluck('topic_id')->toArray();
+        $uids = $this->memberFollowTopic->whereIn('topic_id', $topicIds)->pluck('uid')->toArray();
+        $uids = array_unique($uids);
+        sort($uids);
+        return Response::create([
+            'message' => '成功',
+            'status_code' => 200,
+            'data' => $uids
+        ]);
+    }
+
     /**
      * 评论列表
      */

+ 3 - 0
routes/api.php

@@ -18,6 +18,9 @@ $api->version('v1', [
 ], function ($api) {
 
 
+    //获取关注分类用户uids
+    $api->get('post/getCategoryUids', 'Post\PostController@getCategoryUids');
+
     $api->group(['middleware' => 'jwt.chxq_auth'], function ($api) {
         //配置
         $api->get('config', 'ConfigController@index');