systemrolesModel = new SystemRole; $this->orgModel = new orgModel; } /** * @title: 统一创建查询条件 * @desc: * @param {*} * @return {*} * @Author: Rock * @Date: 2022-04-07 14:17:11 * @LastEditTime: Do not edit */ private function createWhere() { $data = $this->request->param(); $where = []; if(!$this->userinfo['is_developer']){ $codeNotIn = ['DEVELOPER']; $where[] = ['code','NOT IN',$codeNotIn]; } if(!empty($data['keyword'])){ $where[] = ['type_name','LIKE',"%".$data['keyword']."%"]; } return $where; } /** * @title: 系统角色类型列表 * @param {int} {pageNo} {非必填,默认值为1} {页码} * @param {int} {pageSize} {非必填,默认值为10} {每页数量} * @param {string} {keyword} {非必填} {类型名称搜索} * @return array * @Author: wangkewei * @Date: 2021/5/18 10:10 */ public function getList($pageNo=1,$pageSize=10) { $where = $this->createWhere(); $list = $this->systemrolesModel->where($where)->paginate(['page'=>$pageNo,'list_rows'=>$pageSize]); return pageRes(1,"获取成功",$list->total(),$list->items()); } /** * @title: 获取系统角色类型列表,不分页 * @desc: * @param {*} * @return {*} * @Author: Rock * @Date: 2021-09-06 21:01:55 * @LastEditTime: Do not edit */ public function getListNoPage() { $data = $this->request->param(); $where = $this->createWhere(); $list = $this->systemrolesModel->where($where)->select(); return res(1,"获取成功",$list); } /** * @title: 系统角色类型编辑 * @param array * @return array * @Author: wangkewei * @Date: 2021/5/18 10:11 */ public function doEdit() { $data = $this->request->param(); $this->systemrolesModel->replace()->save($data); slog(1,"编辑了系统角色类型".$data['type_name']); return res(1,"保存成功"); } /** * @title: 系统角色类型删除 * @param {int} {type_id} {必填} {类型ID} * @return array * @Author: wangkewei * @Date: 2021/5/18 10:12 */ public function doDelete(int $type_id=0) { $info = $this->systemrolesModel->where("type_id",$type_id)->find(); if(empty($info)){ return res(1,"删除成功"); } $info->delete(); slog(1,"删除了系统角色类型".$info->type_name); return res(1,"删除成功"); } }