Browse Source

热门视频ids

wzq 5 years ago
parent
commit
9d01172fe3

+ 8 - 0
app/Http/Controllers/V2/FloorController.php

@@ -40,4 +40,12 @@ class FloorController extends BaseController
         return $this->floorRepository->info();
         return $this->floorRepository->info();
     }
     }
 
 
+    /**
+     * 热门视频ids
+     */
+    public function hotVideoIds()
+    {
+        return $this->floorRepository->hotVideoIds();
+    }
+
 }
 }

+ 27 - 0
app/Repositories/FloorRepository.php

@@ -9,6 +9,7 @@ use App\Models\VideoGroup;
 use App\Models\VideoGroupInfo;
 use App\Models\VideoGroupInfo;
 use App\Traits\UserTrait;
 use App\Traits\UserTrait;
 use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Log;
+use Illuminate\Support\Facades\Redis;
 use Symfony\Component\HttpKernel\Exception\HttpException;
 use Symfony\Component\HttpKernel\Exception\HttpException;
 use Dingo\Api\Http\Response;
 use Dingo\Api\Http\Response;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\DB;
@@ -136,5 +137,31 @@ class FloorRepository
         return jsonSuccess($data);
         return jsonSuccess($data);
     }
     }
 
 
+    public function hotVideoIds()
+    {
+        $id = $this->floor
+            ->where('is_open', 1)
+            ->whereIn('floor_type', 2)
+            ->value('group_ids');
+        $data = '';
+        if($id){
+            //video
+            $videoIds = $this->videoGroup
+                ->join('video_group_info', 'video_group_info.video_group_id', '=', 'video_group.id')
+                ->where('video_group.id', $id)
+                ->orderBy('video_group_info.sort', 'asc')
+                ->pluck('video_group_info.post_id')
+                ->toArray();
+            if($videoIds){
+                $data = implode($videoIds, ',');
+                $key = 'hotVideoIds';
+                Redis::SET($key, $data);
+                Redis::EXPIRE($key, 600);
+            }
+        }
+        Log::debug('热门视频ids'.$data);
+        return jsonSuccess($data);
+    }
+
 }
 }
 
 

+ 2 - 0
routes/api.php

@@ -45,6 +45,8 @@ $api->version('v1', [
             $api->get('/floor/index', 'FloorController@index');
             $api->get('/floor/index', 'FloorController@index');
             //获取楼层信息
             //获取楼层信息
             $api->get('/floor/info', 'FloorController@info');
             $api->get('/floor/info', 'FloorController@info');
+            //热门视频ids
+            $api->get('/floor/hotVideoIds', 'FloorController@hotVideoIds');
             //获取推荐用户组内容
             //获取推荐用户组内容
             $api->get('memberList', 'MemberGroupController@memberList');
             $api->get('memberList', 'MemberGroupController@memberList');
         });
         });