|
@@ -21,6 +21,7 @@ use App\Models\PostShare;
|
|
|
use App\Models\Topic;
|
|
|
use App\Service\AliYunVodService;
|
|
|
use App\Service\DetectionService;
|
|
|
+use App\Traits\CmsTrait;
|
|
|
use App\Traits\PostTrait;
|
|
|
use App\Traits\UserTrait;
|
|
|
use Illuminate\Database\QueryException;
|
|
@@ -35,6 +36,7 @@ class PostRepositories
|
|
|
{
|
|
|
use UserTrait;
|
|
|
use PostTrait;
|
|
|
+ use CmsTrait;
|
|
|
public function __construct(Post $post,
|
|
|
PostData $postData,
|
|
|
PostImgs $postImgs,
|
|
@@ -319,6 +321,34 @@ class PostRepositories
|
|
|
$id = $request['id'];
|
|
|
}
|
|
|
$where[] = ['type', 'video'];
|
|
|
+ if(isset($request['type'])){
|
|
|
+ if($request['type'] == 'hot'){
|
|
|
+ $ids = Redis::get('hotVideoIds');
|
|
|
+ if(!$ids){
|
|
|
+ $ids = $this->hotVideoIds();
|
|
|
+ if(!$ids){
|
|
|
+ $ids = '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Log::debug('热门视频ids'.$ids);
|
|
|
+ return $this->post
|
|
|
+ ->join('post_data', 'post_data.post_id', '=', 'post.id')
|
|
|
+ ->select('post.*', DB::raw("IF (post.id = {$id},1,0) as sort"))
|
|
|
+ ->where($where)
|
|
|
+ ->whereIn('post.id', explode(',', $ids))
|
|
|
+ ->orderBy('sort', 'desc')
|
|
|
+ ->orderByRaw(DB::raw("FIELD(post.id,{$ids})"))
|
|
|
+ ->paginate($perPage);
|
|
|
+ }elseif($request['type'] == 'one'){
|
|
|
+ $where[] = ['post.id', $id];
|
|
|
+ return $this->post
|
|
|
+ ->join('post_data', 'post_data.post_id', '=', 'post.id')
|
|
|
+ ->select('post.*')
|
|
|
+ ->where($where)
|
|
|
+ ->paginate($perPage);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
return $this->post
|
|
|
->join('post_data', 'post_data.post_id', '=', 'post.id')
|
|
|
->select('post.*', DB::raw("IF (post.id = {$id},1,0) as sort"))
|