12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace app\user\controller;
- use app\base\controller\Base;
- class User extends Base{
-
- private $userModel;
-
- public function _initialize(){
- parent::_initialize();
-
- $this->userModel = new \app\user\model\User();
- }
-
- public function index(){
- $p = $this->request->get('page', 0);
- $nick = $this->request->get('n');
- $where = [];
-
- if($nick) $where['nickname'] = ['like', "%$nick%"];
-
- $info = $this->userModel->getInfo($p, $where);
- $page = $this->userModel->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 save(){
- $res = $this->adminModel->addAndSave();
-
- if($res){
- $this->success('保存成功!', 'index');
- }else{
- $this->error('保存失败!');
- }
- }
-
- }
|