|
@@ -10,6 +10,7 @@ namespace App\Repositories;
|
|
|
|
|
|
|
|
|
use App\Models\Behavior;
|
|
|
+use App\Models\CategoryTopic;
|
|
|
use App\Models\MemberFollowTopic;
|
|
|
use App\Models\Post;
|
|
|
use App\Models\PostCollect;
|
|
@@ -50,6 +51,7 @@ class PostRepositories
|
|
|
DetectionService $detectionService,
|
|
|
AliYunVodService $aliYunVodService,
|
|
|
MemberFollowTopic $memberFollowTopic,
|
|
|
+ CategoryTopic $categoryTopic,
|
|
|
Topic $topic)
|
|
|
{
|
|
|
$this->post = $post;
|
|
@@ -62,6 +64,7 @@ class PostRepositories
|
|
|
$this->detectionService = $detectionService;
|
|
|
$this->topic = $topic;
|
|
|
$this->memberFollowTopic = $memberFollowTopic;
|
|
|
+ $this->categoryTopic = $categoryTopic;
|
|
|
$this->aliYunVodService = $aliYunVodService;
|
|
|
}
|
|
|
|
|
@@ -507,11 +510,28 @@ class PostRepositories
|
|
|
$blacklist = [];
|
|
|
}
|
|
|
|
|
|
- return $this->post->where(function ($query) use ($blacklist) {
|
|
|
- if ($blacklist) {
|
|
|
- $query->whereNotIn('uid', $blacklist);
|
|
|
- }
|
|
|
- })
|
|
|
+ $topicIds = [];
|
|
|
+ if(isset($request['category_id']) && $request['category_id']){
|
|
|
+ $topicIds = $this->categoryTopic->where('category_id', $request['category_id'])->pluck('topic_id')->toArray();
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->post
|
|
|
+ ->where(function ($query) use ($blacklist) {
|
|
|
+ if ($blacklist) {
|
|
|
+ $query->whereNotIn('uid', $blacklist);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ->where(function ($query) use ($topicIds) {
|
|
|
+ if ($topicIds) {
|
|
|
+ foreach ($topicIds as $key => $id) {
|
|
|
+ if ($key == 0) {
|
|
|
+ $query = $query->whereRaw('FIND_IN_SET(' . $id . ', topic_ids)');
|
|
|
+ } else {
|
|
|
+ $query = $query->orWhereRaw('FIND_IN_SET(' . $id . ', topic_ids)');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
->where('is_hide', 0)
|
|
|
->orderBy('is_suggest', 'desc')
|
|
|
->orderBy('weight', 'desc')
|