feat: 完成平台发表情况查询

This commit is contained in:
augushong
2025-05-05 11:33:00 +08:00
parent bf2af3a4b7
commit 81e079c8f9
3 changed files with 68 additions and 5 deletions

View File

@@ -44,15 +44,40 @@ class Post extends Common
public function indexOutput()
{
$platform_type = $this->request->param('platform_type', '');
if (empty($platform_type)) {
$this->error('参数platform_type不能为空');
}
$platform_status = $this->request->param('platform_status', '');
$model_list = ModelPost::with(['categorys.category', 'tags.tag'])
->where('type', $this->request->param('type', 1))
->order('id desc');
if($platform_status == 1){
$model_list = $model_list->where('post_platform_status', 'like', "%,{$platform_type},%");
}else if ($platform_status === '0'){
$model_list = $model_list->where('post_platform_status', 'not like', "%,{$platform_type},%");
}
$list = $model_list->paginate([
'query' => $this->request->get(),
]);
foreach ($list as $model_post) {
if (empty($model_post->post_platform_status)) {
$model_post->platform_status = 0;
} else {
if (strpos($model_post->post_platform_status, ",$platform_type,") === false) {
$model_post->platform_status = 0;
} else {
$model_post->platform_status = 1;
}
}
$model_post->platform_status_title = ModelPost::LIST_POST_PLATFORM_STATUS[$model_post->platform_status];
}
View::assign('list', $list);
View::assign('platform_type', $platform_type);
return View::fetch();
}