Browse Source

统计用户内容

zhangchangchun 5 years ago
parent
commit
6e2ef79c8c

+ 4 - 2
app/Http/Controllers/V1/PostController.php

@@ -380,6 +380,8 @@ class PostController extends Controller
         $data = $this->postRepositories->getPostVideo($request['ids']);
         return jsonSuccess($data);
     }
-
-
+    //用户内容数统计
+    public function memberPostStatistics(Request $request){
+       return $this->postRepositories->memberPostStatistics();
+    }
 }

+ 11 - 1
app/Repositories/PostRepositories.php

@@ -28,6 +28,8 @@ use Illuminate\Support\Carbon;
 use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Redis;
 use Illuminate\Support\Facades\DB;
+use Tymon\JWTAuth\Facades\JWTAuth;
+
 
 class PostRepositories
 {
@@ -573,6 +575,14 @@ class PostRepositories
             ->where('type', 'video')
             ->get();
     }
-
+    //用户内容数,转发数,收藏数统计
+    public function memberPostStatistics(){
+        $token =  JWTAuth::decode(JWTAuth::getToken());
+        $postCount = $this->post->where('uid',$token['user']->uid)->count();
+        $postCollectCount = $this->postCollect->where('uid',$token['user']->uid)->count();
+        $postShareCount = $this->postShare->where('uid',$token['user']->uid)->count();
+        $data = ['post_count'=>$postCount,'share_count'=>$postShareCount,'collect_count'=>$postCollectCount];
+        return jsonSuccess($data);
+    }
 
 }

+ 2 - 0
routes/api.php

@@ -75,6 +75,8 @@ $api->version('v1', [
         $api->get('registeredMost', 'BeanDetailController@registeredMost');
         //排行榜最佳作者
         $api->get('bestAuthor', 'BeanDetailController@bestAuthor');
+        //用户发布数,收藏数,转发数
+        $api->get('post/memberPostStatistics', 'PostController@memberPostStatistics');
     });
     $api->get('excellentResidents', 'BeanDetailController@excellentResidents');