model = new CampusPersonRole(); } /** * 获取角色关系列表 * @param array $where * @return array */ public function getPage(array $where = []) { $field = 'id,campus_id,person_id,role_id,dept_id,created_at,updated_at,deleted_at'; $order = 'id desc'; $search_model = $this->model->withSearch(["id","campus_id","person_id","role_id","dept_id"], $where)->with(['campus','personnel','sysRole','departments'])->field($field)->order($order); $list = $this->pageQuery($search_model); return $list; } /** * 获取角色关系信息 * @param int $id * @return array */ public function getInfo(int $id) { $field = 'id,campus_id,person_id,role_id,dept_id,created_at,updated_at,deleted_at'; $info = $this->model->field($field)->where([['id', "=", $id]])->with(['campus','personnel','sysRole','departments'])->findOrEmpty()->toArray(); return $info; } /** * 添加角色关系 * @param array $data * @return mixed */ public function add(array $data) { $res = $this->model->create($data); return $res->id; } /** * 角色关系编辑 * @param int $id * @param array $data * @return bool */ public function edit(int $id, array $data) { $this->model->where([['id', '=', $id]])->update($data); return true; } /** * 删除角色关系 * @param int $id * @return bool */ public function del(int $id) { $model = $this->model->where([['id', '=', $id]])->find(); $res = $model->delete(); return $res; } public function getCampusAll(){ $campusModel = new Campus(); return $campusModel->select()->toArray(); } public function getPersonnelAll(){ $personnelModel = new Personnel(); return $personnelModel->select()->toArray(); } public function getSysRoleAll(){ $sysRoleModel = new SysRole(); return $sysRoleModel->select()->toArray(); } public function getDepartmentsAll(){ $departmentsModel = new Departments(); return $departmentsModel->select()->toArray(); } }