Преглед изворни кода

Merge branch 'develop' of http://git.caihongxingqiu.net/rainbow/community-service into develop

zhangchangchun пре 5 година
родитељ
комит
0ec1314637

+ 1 - 1
app/Http/Controllers/V1/BeanDetailController.php

@@ -22,7 +22,7 @@ class BeanDetailController extends Controller
     public function beanDetail(Request $request)
     {
         $validator = Validator::make($request->all(), [
-            'type' => ['required',Rule::in([0,1, 2])],
+            'type' => ['required',Rule::in([0,1,2,3])],
         ]);
         if ($validator->fails()) {
             return $this->jsonError($validator->errors()->first());

+ 9 - 0
app/Http/Controllers/V1/BehaviorController.php

@@ -36,4 +36,13 @@ class BehaviorController extends Controller
         $row = $this->behaviorRepositories->getBehavior($request['identify']);
         return jsonSuccess($row);
     }
+
+    /**
+     * 获取所有行为
+     */
+    public function getAllBehavior()
+    {
+        $data = $this->behaviorRepositories->getAllBehavior();
+        return jsonSuccess($data);
+    }
 }

+ 5 - 44
app/Repositories/BeanRepository.php

@@ -66,7 +66,7 @@ class BeanRepository
             ->groupBy('related_content_id', 'content_author_id')->orderBy('count', 'desc')->limit(1)->get();
         $collent = $collent->toArray();
         foreach ($collent as $k=>$v){
-            $collent[$k]['type'] = 'collent';
+            $collent[$k]['type'] = 'collect';
         }
 
         //文章被喜欢最多用户
@@ -150,8 +150,6 @@ class BeanRepository
 
     public function rankingList($request)
     {
-        $yesterday_start = Carbon::now()->addDays(-1)->startOfDay()->toDateTimeString();
-        $yesterday_end = Carbon::now()->addDays(-1)->endOfDay()->toDateTimeString();
         if ($request['type'] == 0){//排行榜赚豆达人
             $yesterday = Carbon::yesterday()->toDateString();
             $all_beans = Redis::ZREVRANGEBYSCORE('user_rainbow_bean'.$yesterday, 100000000, 0, array('WITHSCORES'=>true,'limit' => array(0, 20)));
@@ -175,15 +173,8 @@ class BeanRepository
             return $new_arr;
 
         }elseif ($request['type'] == 1){//排行榜人脉达人
-//            $registered_most = Redis::get('yesterday_registered_most');
-//            $registered_mosts = json_decode($registered_most,true);
-
-            //昨日拉新最多前十人
-            $registered_most = RegisteredRecord::
-//                whereBetween('created_at', [$yesterday_start,$yesterday_end])
-                select(DB::raw('count(*) as count'),'superior_uid')
-                ->groupBy('superior_uid')->orderBy('count','desc')->limit(10)->get();
-            $registered_most = $registered_most->toArray();
+            $registered_mosts = Redis::get('yesterday_registered_most');
+            $registered_most = json_decode($registered_mosts,true);
 
             $superior_uid = array_column($registered_most,'superior_uid');
             $uids = implode(',', array_unique($superior_uid));
@@ -199,39 +190,9 @@ class BeanRepository
             return $registered_most;
 
         }else{//排行榜最佳作者
-//            $all_best_author = Redis::get('yesterday_best_author');
-//            $all_best_authors = json_decode($all_best_author,true);
-            //昨日文章产生彩虹豆最多前十人
-            $comment_author = CommentRecord::select(DB::raw('count(*) as count'),'generation_quantity','content_author_id','related_content_id')->groupBy('generation_quantity','related_content_id','content_author_id')
-                ->orderBy('generation_quantity','desc')
-                ->limit(10)
-                ->get();;
-            $comment_best_author = $comment_author->toArray();
-            foreach ($comment_best_author as $k=>$v){
-                $comment_best_author[$k]['type'] = 'comment';
-            }
-            $general_author = GeneralRecord::select(DB::raw('count(*) as count'),'generation_quantity','content_author_id','related_content_id')->groupBy('generation_quantity','related_content_id','content_author_id')
-                ->orderBy('generation_quantity','desc')
-                ->limit(10)
-                ->get();;;
-            $general_best_author = $general_author->toArray();
-            foreach ($general_best_author as $k=>$v){
-                $general_best_author[$k]['type'] = 'general';
-            }
-            $release_author =ReleaseRecord::
-//                ->where('created_at', '>=', $time)
-                select(DB::raw('count(*) as count'),'generation_quantity','uid as content_author_id','related_content_id')
-                ->groupBy('generation_quantity','content_author_id','related_content_id')->orderBy('generation_quantity','desc')->limit(10)->get();
-            $release_best_author = $release_author->toArray();
-            foreach ($release_best_author as $k=>$v){
-                $release_best_author[$k]['type'] = 'release';
-            }
-            $all_best_author = array_merge($comment_best_author,$general_best_author,$release_best_author);
-
-            $column = array_column($all_best_author,'generation_quantity');
-            array_multisort($column,SORT_DESC,$all_best_author);
+            $all_best_authors = Redis::get('yesterday_best_author');
+            $all_best_author = json_decode($all_best_authors,true);
 
-            $all_best_author = array_slice($all_best_author,0,10);
             $content_author_id = array_column($all_best_author,'content_author_id');
             $uids = implode(',', array_unique($content_author_id));
             $user_data = $this->getFollowMembersStatus($uids);

+ 8 - 0
app/Repositories/BehaviorRepositories.php

@@ -33,5 +33,13 @@ class BehaviorRepositories
         return [];
     }
 
+    /**
+     * 获取所有行为
+     */
+    public function getAllBehavior()
+    {
+        return Behavior::pluck('virus_behavior_id', 'behavior_identification');
+    }
+
 
 }

+ 0 - 37
app/Repositories/PostRepositories.php

@@ -20,7 +20,6 @@ use App\Models\PostLike;
 use App\Models\PostShare;
 use App\Models\Topic;
 use App\Service\DetectionService;
-use App\Service\RabbitMqUtil;
 use App\Traits\PostTrait;
 use App\Traits\UserTrait;
 use Illuminate\Database\QueryException;
@@ -42,7 +41,6 @@ class PostRepositories
                                 PostCollect $postCollect,
                                 PostShare $postShare,
                                 DetectionService $detectionService,
-                                RabbitMqUtil $rabbitMqUtil,
                                 Topic $topic)
     {
         $this->post = $post;
@@ -52,7 +50,6 @@ class PostRepositories
         $this->postCollect = $postCollect;
         $this->postShare = $postShare;
         $this->detectionService = $detectionService;
-        $this->rabbitMqUtil = $rabbitMqUtil;
         $this->topic = $topic;
     }
 
@@ -227,44 +224,10 @@ class PostRepositories
             if(isset($request['reply_uid']) && isset($request['reply_username'])){
                 $data['reply_uid'] = $request['reply_uid'];
                 $data['reply_username'] = $request['reply_username'];
-                $this->rabbitMqUtil->push('add_message', [
-                    'uid' => $request['reply_uid'],
-                    'message_show_type' => 'post_reply_main',
-                    'param' => [
-                        'uid' => $userInfo['uid'],
-                        'username' => $userInfo['username'],
-                        'post_id' => $post->id,
-                        'cover' => $post->img,
-                        'content' => subtext($request['content'], 20),
-                    ]
-                ]);
             }else{
                 $data['reply_uid'] = 0;
                 $data['reply_username'] = '';
-                $this->rabbitMqUtil->push('add_message', [
-                    'uid' => $comment->uid,
-                    'message_show_type' => 'post_reply',
-                    'param' => [
-                        'uid' => $userInfo['uid'],
-                        'username' => $userInfo['username'],
-                        'post_id' => $post->id,
-                        'cover' => $post->img,
-                        'content' => subtext($request['content'], 20),
-                    ]
-                ]);
             }
-        }else{
-            $this->rabbitMqUtil->push('add_message', [
-                'uid' => $post->uid,
-                'message_show_type' => 'post_comment',
-                'param' => [
-                    'uid' => $userInfo['uid'],
-                    'username' => $userInfo['username'],
-                    'post_id' => $post->id,
-                    'cover' => $post->img,
-                    'content' => subtext($request['content'], 20),
-                ]
-            ]);
         }
 
         DB::beginTransaction();

+ 4 - 4
composer.json

@@ -32,14 +32,14 @@
         ],
         "psr-4": {
             "App\\": "app/"
-        },
-        "files" : [
-            "app/Helper/helper.php"
-        ]
+        }
     },
     "autoload-dev": {
         "classmap": [
             "tests/"
+        ],
+        "files" : [
+            "app/Helper/helper.php"
         ]
     },
     "scripts": {

+ 2 - 0
routes/api.php

@@ -18,6 +18,8 @@ $api->version('v1', [
 ], function ($api) {
     //根据行为标识查询行为
     $api->get('getBehaviorByIdentify', 'BehaviorController@getBehaviorByIdentify');
+    //获取所有行为
+    $api->get('getAllBehavior', 'BehaviorController@getAllBehavior');
     //登录+验签
     $api->group(['middleware' => ['chxq_jwt_auth']], function ($api) {
         //发布内容