WokerTask/app/api/lists/approve/ApproveLists.php

62 lines
1.6 KiB
PHP
Raw Permalink Normal View History

2023-12-27 14:06:33 +08:00
<?php
namespace app\api\lists\approve;
use app\api\lists\BaseApiDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\Approve;
use app\common\model\user\User;
class ApproveLists extends BaseApiDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/08/31 11:08
*/
public function setSearch(): array
{
$param = $this->request->param();
if (isset($param['check_status']) && $param['check_status'] == 0) {
return [
'=' =>['type']
];
} else {
return [
'=' =>['type', 'check_status']
];
}
}
public function queryWhere()
{
$where = [];
// if (isset($param['type']) && $param['type'] == 2) {
$adminId = User::where(['id' => $this->userId])->with('company')->value('admin_id');
$where[] = ['check_admin_ids', '=', $adminId]; // 只有片区经理才能查看
// }
return $where;
}
public function lists(): array
{
return Approve::where($this->searchWhere)
->where($this->queryWhere())
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->withAttr('extend',function ($value, $data) {
return json_decode($data['extend'], true);
})
->select()
->toArray();
}
public function count(): int
{
return Approve::where($this->searchWhere)->count();
}
}