request->isPost()){ return $this->fail('请求方式错误'); } $params = $this->request->post(['page_no','page_size', 'account', 'mobile', 'company_id']); $where = []; if(isset($params['company_id']) && $params['company_id'] > 0){ $where[] = ['company_id', '=', $params['company_id']]; } if(isset($params['account']) && $params['account'] != ''){ $where[] = ['account', '=', $params['account']]; } if(isset($params['mobile']) && $params['mobile'] != ''){ $where[] = ['mobile', 'like', '%'.$params['mobile'].'%']; } $pageNo = !empty($params['page_no']) ? $params['page_no'] : 1; $pageSize = !empty($params['page_size']) ? $params['page_size'] : 20; $field = "id,id contract,sn,nickname,sex,avatar,account,mobile,channel,create_time,admin_id,company_id,street,street as street_name,is_contract"; $lists = User::where($where) ->with(['company']) ->page($pageNo, $pageSize) ->field($field) ->order('id desc') ->select() ->toArray(); foreach ($lists as &$item) { $item['channel'] = UserTerminalEnum::getTermInalDesc($item['channel']); } $count = User::where($where)->count(); $result = [ 'lists' => $lists, 'count' => $count, 'page_no' => $pageNo, 'page_size' => $pageSize ]; return $this->success('请求成功',$result); } public function roleLists() { if(!$this->request->isPost()){ return $this->fail('请求方式错误'); } $params = $this->request->post(['page_no','page_size']); $pageNo = !empty($params['page_no']) ? $params['page_no'] : 1; $pageSize = !empty($params['page_size']) ? $params['page_size'] : 20; $lists = UserRole::field(['id', 'name', 'desc', 'menu_arr', 'sort']) ->page($pageNo, $pageSize) ->order(['id' => 'desc']) ->select() ->toArray(); $count = UserRole::count(); $result = [ 'lists' => $lists, 'count' => $count, 'page_no' => $pageNo, 'page_size' => $pageSize ]; return $this->success('请求成功',$result); } }