12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace Admin\Controller;
- use Common\Controller\AdminController;
- class ManagerController extends AdminController {
- public function __construct(){
- parent::__construct();
- }
-
- public function index(){
- $keyword = I('get.keyword','');
- $condition = array();
- if (!empty($keyword)){
- $condition['admin_account'] = array('LIKE','%'.$keyword.'%');
- $this->assign('keyword',$keyword);
- }
- $count = M('Admin')->where($condition)->count();
- //分页
- $Page = new \Think\Page($count);
- $show = $Page->show();
- $userList = M('Admin')->where($condition)->field()->order('admin_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
- $this->assign('page',$show);
- $this->assign('list',$userList);
- $this->display();
- }
-
- public function edit(){
- $step = I('step','');
- if (empty($step)){
- $this->display();
- }else if($step==2){
- $adminAccount = I('admin_account');
- $newPwd = I('new_pwd');
- $newRepwd = I('new_repwd');
- $groupId = I('group_id');
- if (mb_strlen($adminAccount,'UTF8')<6 || mb_strlen($adminAccount,'UTF8')>20){
- $this->error('用户名长度6到20之间');
- }
- if (mb_strlen($newPwd,'UTF8')<6 || mb_strlen($newPwd,'UTF8')>20){
- $this->error('新密码长度6到20之间');
- }
- if ($newPwd!==$newRepwd){
- $this->error('两次输入的新密码不一致,请重新输入');
- }
- $info = M('Admin')->where(array('admin_account'=>$adminAccount))->field('admin_id')->find();
- if ($info!=NULL){
- $this->error('用户名已经存在');
- }
- $saveData = array(
- 'admin_account'=>$adminAccount,
- 'admin_pwd'=>md5($newPwd),
- 'group_id'=>$groupId,
- 'operate_dt'=>time(),
- );
- M('Admin')->add($saveData);
- $this->success('创建账号成功','/admin/manager/index');
- }
- }
-
- public function del(){
- $adminId = I('admin_id');
- M('Admin')->where(array('admin_id'=>$adminId))->delete();
- $this->success('删除成功','/admin/manager/index');
- }
- }
|