67 lines
1.5 KiB
PHP
67 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace app\admin\lists\goods;
|
|
|
|
|
|
use app\admin\lists\BaseAdminDataLists;
|
|
use app\common\model\goods\Goodsclass;
|
|
use app\common\lists\ListsSearchInterface;
|
|
|
|
|
|
/**
|
|
* 商品分类列表
|
|
* Class GoodsclassLists
|
|
* @package app\admin\listsgoods
|
|
*/
|
|
class GoodsclassLists extends BaseAdminDataLists implements ListsSearchInterface
|
|
{
|
|
|
|
|
|
/**
|
|
* @notes 设置搜索条件
|
|
* @return \string[][]
|
|
* @author likeadmin
|
|
* @date 2024/04/23 10:27
|
|
*/
|
|
public function setSearch(): array
|
|
{
|
|
return [
|
|
'=' => ['pid', 'name', 'data', 'pic', 'sort'],
|
|
];
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 获取商品分类列表
|
|
* @return array
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @author likeadmin
|
|
* @date 2024/04/23 10:27
|
|
*/
|
|
public function lists(): array
|
|
{
|
|
$lists= Goodsclass::where($this->searchWhere)
|
|
->field(['id', 'pid', 'name', 'data', 'pic', 'sort'])
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
->order(['id' => 'desc'])
|
|
->select()
|
|
->toArray();
|
|
return linear_to_tree($lists, 'children');
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 获取商品分类数量
|
|
* @return int
|
|
* @author likeadmin
|
|
* @date 2024/04/23 10:27
|
|
*/
|
|
public function count(): int
|
|
{
|
|
return Goodsclass::where($this->searchWhere)->count();
|
|
}
|
|
|
|
} |