This commit is contained in:
weiz 2024-04-02 14:50:49 +08:00
parent 628d35f789
commit 730bc1c318

View File

@ -11,68 +11,68 @@
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists\material;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\material\MaterialClassify;
use app\common\lists\ListsSearchInterface;
/**
* 材料分类列表
* Class MaterialClassifyLists
* @package app\adminapi\listsmaterial
*/
class MaterialClassifyLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/01/04 09:47
*/
public function setSearch(): array
{
return [
'%like%' => ['name'],
];
}
/**
* @notes 获取材料分类列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/01/04 09:47
*/
public function lists(): array
{
$data = MaterialClassify::where($this->searchWhere)
->field(['id', 'pid', 'name'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'asc'])
->select()
->toArray();
return buildTree($data,'pid');
}
/**
* @notes 获取材料分类数量
* @return int
* @author likeadmin
* @date 2024/01/04 09:47
*/
public function count(): int
{
return MaterialClassify::where($this->searchWhere)->count();
}
}
namespace app\adminapi\lists\material;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\material\MaterialClassify;
/**
* 材料分类列表
* Class MaterialClassifyLists
* @package app\adminapi\listsmaterial
*/
class MaterialClassifyLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/01/04 09:47
*/
public function setSearch(): array
{
return [
'%like%' => ['name'],
];
}
/**
* @notes 获取材料分类列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/01/04 09:47
*/
public function lists(): array
{
$data = MaterialClassify::where($this->searchWhere)
->field(['id', 'pid', 'name'])
// ->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'asc'])
->select()
->toArray();
return buildTree($data, 'pid');
}
/**
* @notes 获取材料分类数量
* @return int
* @author likeadmin
* @date 2024/01/04 09:47
*/
public function count(): int
{
return MaterialClassify::where($this->searchWhere)->count();
}
}