This commit is contained in:
weiz 2024-04-09 10:40:29 +08:00
parent 2d683824b0
commit 7a8cf5f7bd

View File

@ -11,68 +11,70 @@
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists\dept;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\dept\Orgs;
use app\common\lists\ListsSearchInterface;
/**
* Orgs列表
* Class OrgsLists
* @package app\adminapi\lists
*/
class OrgsLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/12/09 10:55
*/
public function setSearch(): array
{
return [
'=' => ['status'],
'%like%' => ['name', 'master'],
];
}
/**
* @notes 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2023/12/09 10:55
*/
public function lists(): array
{
return Orgs::where($this->searchWhere)
->field(['id', 'name', 'master', 'status','create_time'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取数量
* @return int
* @author likeadmin
* @date 2023/12/09 10:55
*/
public function count(): int
{
return Orgs::where($this->searchWhere)->count();
}
}
namespace app\adminapi\lists\dept;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\dept\Orgs;
/**
* Orgs列表
* Class OrgsLists
* @package app\adminapi\lists
*/
class OrgsLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/12/09 10:55
*/
public function setSearch(): array
{
return [
'=' => ['status'],
'%like%' => ['name', 'master'],
];
}
/**
* @notes 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2023/12/09 10:55
*/
public function lists(): array
{
return Orgs::where($this->searchWhere)
->field(['id', 'name', 'master', 'status', 'create_time'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($data) {
$data['status_text'] = $data->status_text;
})
->toArray();
}
/**
* @notes 获取数量
* @return int
* @author likeadmin
* @date 2023/12/09 10:55
*/
public function count(): int
{
return Orgs::where($this->searchWhere)->count();
}
}