123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- namespace app\user\controller;
- use think\Db;
- use app\base\controller\Base;
- use app\user\model\Role;
- use app\user\model\RoleRule;
- class Index extends Base{
-
- private $adminModel;
-
- public function _initialize(){
- parent::_initialize();
-
- $this->adminModel = new \app\user\model\Admin();
- }
-
- public function index(){
- $p = $this->request->get('page', 0);
- $nick = $this->request->get('n');
- $where = [];
-
- if($nick) $where['nickname'] = ['like', "%$nick%"];
-
- $info = $this->adminModel->getInfo($p, $where);
- $page = $this->adminModel->getPage($where);
-
- $this->assign("info", $info);
- $this->assign("page", $page);
- return $this->fetch();
- }
-
- public function edit(){
- $id = $this->request->get('id');
- $info = $this->adminModel->getAdminById($id);
-
- $this->assign("info", $info);
- return $this->fetch('edit');
- }
-
- public function reset(){
- $id = $this->request->get('id');
-
- $this->assign("id", $id);
- return $this->fetch('reset');
- }
-
- public function pass(){
- $res = $this->adminModel->resetPwd();
-
- if(is_int($res)){
- $this->success('更改成功!', 'index');
- }else{
- $this->error('更改失败!'.$res);
- }
- }
-
- public function group(){
- $id = $this->request->get('id');
- $admin = $this->adminModel->getAdminById($id);
- $role = new Role();
- $info = $role->getAllRole();
- $rule = new RoleRule();
- $array = $rule->getRidByAid($id);
-
- $this->assign('array', $array);
- $this->assign('admin', $admin);
- $this->assign('info', $info);
- return $this->fetch();
- }
-
- public function rule(){
- $info = new RoleRule();
- $info->addAndSave();
-
- $this->success('保存成功!', 'index');
- }
-
- public function delete(){
- $res = $this->adminModel->remove();
-
- if($res){
- $this->success('删除成功!', 'index');
- }else{
- $this->error('删除失败!');
- }
- }
-
- public function save(){
- $res = $this->adminModel->addAndSave();
-
- if($res){
- $this->success('保存成功!', 'index');
- }else{
- $this->error('保存失败!');
- }
- }
-
- }
|