diff --git a/app/admin/controller/Post.php b/app/admin/controller/Post.php index 2a3576c..40458cc 100644 --- a/app/admin/controller/Post.php +++ b/app/admin/controller/Post.php @@ -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(); } diff --git a/app/model/Post.php b/app/model/Post.php index ffac4fe..eac90ed 100644 --- a/app/model/Post.php +++ b/app/model/Post.php @@ -24,6 +24,11 @@ class Post extends Base public const CACHE_KEY_HITS = 'cache_hits_'; + public const LIST_POST_PLATFORM_STATUS = [ + 0 => '未发表', + 1 => '已发表', + ]; + public static $autoClearCache = [ ]; @@ -265,12 +270,13 @@ class Post extends Base return $value; } - public function getPostPlatformDataArrayAttr() + public function getPostPlatformDataArrayAttr() { $data = $this->getData('post_platform_data'); if (empty($data)) { return []; } + return json_decode($data, true); } } diff --git a/view/admin/post/index_output.html b/view/admin/post/index_output.html index d758b52..41efa1c 100644 --- a/view/admin/post/index_output.html +++ b/view/admin/post/index_output.html @@ -37,12 +37,32 @@
+| 排序 | 状态 | +平台状态 | 操作 | @@ -77,6 +98,17 @@{$vo.desc_short} | {$vo.sort} | {$vo.status_name} | ++ {if $vo.platform_status == 0 } + {$vo.platform_status_title} + + {else /} + {$vo.platform_status_title} + {/if} + |
|
|---|