TaskSystem/app/api/controller/TaskController.php
2023-08-15 18:06:11 +08:00

38 lines
1.3 KiB
PHP

<?php
namespace app\api\controller;
use app\common\model\task\Task;
class TaskController extends BaseApiController{
public function lists(){
$param = Request()->param();
[$page, $limit] = $this->getPage();
if($this->userInfo['admin_id']!=0){
$where[]=['company_id','=',$this->userInfo['company_id']];
}else{
$where[]=['director_uid','=',$this->userId];
// $where[]=['status','in',[1,2,3,5]];
}
if(isset($param['date_time']) && $param['date_time']!=''){
$time=strtotime($param['date_time']);
$end=$time+86399;
$where[]=['start_time','between',[$time,$end]];
}else{
$time=strtotime(date('Y-m-d'));
$end=$time+86399;
$where[]=['start_time','between',[$time,$end]];
}
if(isset($param['status']) && $param['status']>0){
$where[]=['status','=',$param['status']];
}
$res=Task::where($where)
->field(['id', 'title','money','template_id','director_uid', 'company_id', 'start_time', 'end_time', 'director_uid', 'type', 'status', 'content','extend'])
->page($page,25)
->order(['id' => 'desc','status'=>'asc'])
->select()
->toArray();
return $this->success('ok', $res);
}
}