['follow_type'], '%like%' => ['theme', 'contacts', 'executor'], ]; } /** * @notes 获取项目日志管理列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2023/12/14 09:17 */ public function lists(): array { $params = $this->request->param(); $where = []; if(isset($params['project_name']) && $params['project_name'] != ''){ $projectIds = Project::where('name','like','%'.$params['project_name'].'%')->column('id'); $where[] = ['project_id','in',$projectIds]; } if(isset($params['add_user_name']) && $params['add_user_name'] != ''){ $adminIds = Admin::where('name','like','%'.$params['add_user_name'].'%')->column('id'); $where[] = ['add_user_id','in',$adminIds]; } return ProjectLogs::where($this->searchWhere)->where($where) ->field(['id','project_id','content','annex','add_user_id','create_time']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($item){ $project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty(); $admin = Admin::field('name')->where('id',$item['add_user_id'])->findOrEmpty(); $item['project_name'] = $project['name']; $item['project_code'] = $project['project_code']; $item['add_user_name'] = $admin['name']; return $item; }) ->toArray(); } /** * @notes 获取项目日志管理数量 * @return int * @author likeadmin * @date 2023/12/14 09:17 */ public function count(): int { $params = $this->request->param(); $where = []; if(isset($params['project_name']) && $params['project_name'] != ''){ $projectIds = Project::where('name','like','%'.$params['project_name'].'%')->column('id'); $where[] = ['project_id','in',$projectIds]; } if(isset($params['add_user_name']) && $params['add_user_name'] != ''){ $adminIds = Admin::where('name','like','%'.$params['add_user_name'].'%')->column('id'); $where[] = ['add_user_id','in',$adminIds]; } return ProjectLogs::where($this->searchWhere)->where($where)->count(); } }