roleModel = new \app\user\model\Role(); } public function index(){ $p = $this->request->get('page', 0); $nick = $this->request->get('n'); $where = []; if($nick) $where['nickname'] = ['like', "%$nick%"]; $info = $this->roleModel->getInfo($p, $where); $page = $this->roleModel->getPage($where); $this->assign("info", $info); $this->assign("page", $page); return $this->fetch(); } public function edit(){ $id = $this->request->get('id'); $info = $this->roleModel->getRoleById($id); $this->assign("info", $info); return $this->fetch(); } public function set(){ $id = $this->request->get('id'); $rule = new Rule(); $array = $rule->getInfo(); $info = $rule->getRuleById($id); $role = $this->roleModel->getRoleById($id); $group = explode(",", $role['rules']); $this->assign("group", $group); $this->assign("array", $array); $this->assign("info", $info); return $this->fetch(); } public function update(){ $data = $this->request->post(); $data['rules'] = implode(',', $data['rules']); $res = $this->roleModel->update($data); if($res){ $this->success('保存成功!', 'index'); }else{ $this->error("保存失败!"); } } public function save(){ $res = $this->roleModel->addAndSave(); if($res){ $this->success('保存成功!', 'index'); }else{ $this->error('保存失败!'); } } public function delete(){ $res = $this->roleModel->remove(); if($res){ $this->success('删除成功!', 'index'); }else{ $this->error('删除失败!'); } } }