123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <?php
- namespace app\admin\controller;
- use library\Controller;
- use library\tools\Data;
- use think\Db;
- class User extends Controller
- {
-
- public $table = 'SystemUser';
-
- public function index()
- {
- $this->title = '系统用户管理';
- $query = $this->_query($this->table)->like('username,phone,mail')->equal('status');
- $query->dateBetween('login_at,create_at')->where(['is_deleted' => '0'])->order('id desc')->page();
- }
-
- protected function _index_page_filter(&$data)
- {
- dump($data);
- $level = [
- '0' => '业主',
- '1' => '德叔客户',
- '2' => '分销客户',
- ];
- foreach($data as &$v) {
- }
- }
-
- public function add()
- {
- $this->applyCsrfToken();
- $this->_form($this->table, 'form');
- }
-
- public function edit()
- {
- $this->applyCsrfToken();
- $this->_form($this->table, 'form');
- }
-
- public function pass()
- {
- $this->applyCsrfToken();
- if ($this->request->isGet()) {
- $this->verify = false;
- $this->_form($this->table, 'pass');
- } else {
- $post = $this->request->post();
- if ($post['password'] !== $post['repassword']) {
- $this->error('两次输入的密码不一致!');
- }
- if (Data::save($this->table, ['id' => $post['id'], 'password' => md5($post['password'])], 'id')) {
- $this->success('密码修改成功,下次请使用新密码登录!', '');
- } else {
- $this->error('密码修改失败,请稍候再试!');
- }
- }
- }
-
- public function _form_filter(&$data)
- {
- if ($this->request->isPost()) {
-
- $data['authorize'] = (isset($data['authorize']) && is_array($data['authorize'])) ? join(',', $data['authorize']) : '';
-
- if (isset($data['id'])) unset($data['username']);
- elseif (Db::name($this->table)->where(['username' => $data['username'], 'is_deleted' => '0'])->count() > 0) {
- $this->error("账号{$data['username']}已经存在,请使用其它账号!");
- }
- } else {
- $data['authorize'] = explode(',', isset($data['authorize']) ? $data['authorize'] : '');
- $this->authorizes = Db::name('SystemAuth')->where(['status' => '1'])->order('sort desc,id desc')->select();
- }
- }
-
- public function forbid()
- {
- if (in_array('10000', explode(',', $this->request->post('id')))) {
- $this->error('系统超级账号禁止操作!');
- }
- $this->applyCsrfToken();
- $this->_save($this->table, ['status' => '0']);
- }
-
- public function resume()
- {
- $this->applyCsrfToken();
- $this->_save($this->table, ['status' => '1']);
- }
-
- public function remove()
- {
- if (in_array('10000', explode(',', $this->request->post('id')))) {
- $this->error('系统超级账号禁止删除!');
- }
- $this->applyCsrfToken();
- $this->_delete($this->table);
- }
- }
|