更新获取待办事项接口

This commit is contained in:
yaooo 2023-11-04 17:43:07 +08:00
parent fbdd001b79
commit bf2d80253b
1 changed files with 53 additions and 0 deletions

View File

@ -83,4 +83,57 @@ class Common extends ApiController
];
$this->apiSuccess('获取成功', $subject);
}
//获取待办任务
public function get_task_list()
{
$this->uid = JWT_UID;
$where = array();
$whereOr = array();
$map1 = [];
$map2 = [];
$map3 = [];
$map1[] = ['admin_id', '=', $this->uid];
$map2[] = ['director_uid', '=', $this->uid];
$map3[] = ['', 'exp', Db::raw("FIND_IN_SET({$this->uid},assist_admin_ids)")];
if($this->isAuthProject($this->uid)==0){
$whereOr =[$map1,$map2,$map3];
}
$where[] = ['delete_time', '=', 0];
$list = Db::name('ProjectTask')
->where(function ($query) use ($whereOr) {
if (!empty($whereOr))
$query->whereOr($whereOr);
})
->where($where)
->withoutField('content,md_content')
->order('flow_status asc')
->order('id desc')
->limit(8)
->select()->toArray();
foreach ($list as $key => &$val) {
$val['director_name'] = Db::name('Admin')->where(['id' => $val['director_uid']])->value('name');
if($val['end_time']>0){
$val['end_time'] = date('Y-m-d', $val['end_time']);
}
else{
$val['end_time'] = '-';
}
$val['flow_name'] = \app\project\model\ProjectTask::$FlowStatus[(int) $val['flow_status']];
}
$res['data'] = $list;
$this->apiSuccess('获取成功', $res);
}
private function isAuthProject($uid)
{
if($uid == 1){
return 1;
}
$map = [];
$map[] = ['name', '=', 'project_admin'];
$map[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',uids)")];
$count = Db::name('DataAuth')->where($map)->count();
return $count;
}
}