first commit
This commit is contained in:
90
app/adminapi/lists/item/ItemLists.php
Normal file
90
app/adminapi/lists/item/ItemLists.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\lists\item;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\item\Item;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\service\FileService;
|
||||
|
||||
|
||||
/**
|
||||
* 项目列表
|
||||
* Class ItemLists
|
||||
* @package app\adminapi\listsitem
|
||||
*/
|
||||
class ItemLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author BD
|
||||
* @date 2024/01/16 13:23
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['type', 'is_show'],
|
||||
'%like%' => ['title'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取项目列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author BD
|
||||
* @date 2024/01/16 13:23
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$items = Item::where($this->searchWhere)
|
||||
->append(['vip_name'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach ($items as &$item) {
|
||||
$item['langs'] = json_decode($item['langs'], JSON_UNESCAPED_UNICODE);
|
||||
foreach ($item['langs'] as &$content_lang) {
|
||||
$content_lang['image'] = FileService::getFileUrl($content_lang['image']);
|
||||
$content_lang['content'] = get_file_domain($content_lang['content']);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取项目数量
|
||||
* @return int
|
||||
* @author BD
|
||||
* @date 2024/01/16 13:23
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Item::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user