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() 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']) $model_list = ModelPost::with(['categorys.category', 'tags.tag'])
->where('type', $this->request->param('type', 1)) ->where('type', $this->request->param('type', 1))
->order('id desc'); ->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([ $list = $model_list->paginate([
'query' => $this->request->get(), '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('list', $list);
View::assign('platform_type', $platform_type);
return View::fetch(); return View::fetch();
} }

View File

@@ -24,6 +24,11 @@ class Post extends Base
public const CACHE_KEY_HITS = 'cache_hits_'; public const CACHE_KEY_HITS = 'cache_hits_';
public const LIST_POST_PLATFORM_STATUS = [
0 => '未发表',
1 => '已发表',
];
public static $autoClearCache = [ public static $autoClearCache = [
]; ];
@@ -271,6 +276,7 @@ class Post extends Base
if (empty($data)) { if (empty($data)) {
return []; return [];
} }
return json_decode($data, true); return json_decode($data, true);
} }
} }

View File

@@ -37,12 +37,32 @@
</div> </div>
<div class="main-container"> <div class="main-container">
<div> <div>
<a <div class="layui-tab layui-tab-brief">
href="{:url('create',['type'=>$Request.param.type,'category_id'=>$Request.param.category_id])}" <ul class="layui-tab-title">
class="layui-btn" <li class="platform-status-">
>添加</a> <a href="{:url('indexOutput',['platform_type'=>$platform_type,'type'=>$Request.param.type,'platform_status'=>''])}">全部</a>
</li>
<li class="platform-status-1">
<a
href="{:url('indexOutput',['platform_type'=>$platform_type,'type'=>$Request.param.type,'platform_status'=>'1'])}"
class=""
>已发表</a>
</li>
<li class="platform-status-0">
<a
href="{:url('indexOutput',['platform_type'=>$platform_type,'type'=>$Request.param.type,'platform_status'=>'0'])}"
class=""
>未发表</a>
</li>
</ul>
<div class="layui-tab-content">
</div>
</div>
</div> </div>
</div> </div>
<script>
$('.platform-status-{$Request.param.platform_status}').addClass('layui-this')
</script>
<div> <div>
<table <table
class="layui-table" class="layui-table"
@@ -56,6 +76,7 @@
<th>简介</th> <th>简介</th>
<th>排序</th> <th>排序</th>
<th>状态</th> <th>状态</th>
<th>平台状态</th>
<th>操作</th> <th>操作</th>
</tr> </tr>
@@ -77,6 +98,17 @@
<td style="max-width: 200px;">{$vo.desc_short}</td> <td style="max-width: 200px;">{$vo.desc_short}</td>
<td>{$vo.sort}</td> <td>{$vo.sort}</td>
<td>{$vo.status_name}</td> <td>{$vo.status_name}</td>
<td>
{if $vo.platform_status == 0 }
{$vo.platform_status_title}
{else /}
<a
href="{$vo.post_platform_data_array[$platform_type]}"
target="_blank"
>{$vo.platform_status_title}</a>
{/if}
</td>
<td> <td>
<div class="layui-btn-container"> <div class="layui-btn-container">