From 7a93c179da0175bcb7fdae4c7714ec44d7196b8b Mon Sep 17 00:00:00 2001 From: wispx <1591788658@qq.com> Date: Fri, 7 Dec 2018 16:02:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8E=E5=8F=B0=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E5=82=A8=E5=AD=98?= =?UTF-8?q?=E5=AE=B9=E9=87=8F=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/model/Users.php | 4 ++-- application/index/controller/admin/Users.php | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/application/common/model/Users.php b/application/common/model/Users.php index 45424a1b..bc098444 100644 --- a/application/common/model/Users.php +++ b/application/common/model/Users.php @@ -31,9 +31,9 @@ class Users extends Model return request()->ip(); } - public function setQuotaAttr() + public function setQuotaAttr($quota) { - return Config::where('name', 'user_initial_quota')->value('value'); + return $quota ? $quota : Config::where('name', 'user_initial_quota')->value('value'); } public function setTokenAttr() diff --git a/application/index/controller/admin/Users.php b/application/index/controller/admin/Users.php index 189bae5a..804a392a 100644 --- a/application/index/controller/admin/Users.php +++ b/application/index/controller/admin/Users.php @@ -8,7 +8,7 @@ namespace app\index\controller\admin; -use app\common\model\Users as UserModel; +use app\common\model\Users as UsersModel; use think\Exception; /** @@ -21,7 +21,7 @@ class Users extends Base { public function index($state = '', $keyword = '', $limit = 15) { - $model = new UserModel(); + $model = new UsersModel(); if (!empty($state)) { $model = $model->where('state', $state); } @@ -55,7 +55,7 @@ class Users extends Base return $this->error('不能删除自己的账号!'); } } - if (!UserModel::destroy($id)) { + if (!UsersModel::destroy($id)) { return $this->error('删除失败'); } return $this->success('删除成功'); @@ -75,7 +75,7 @@ class Users extends Base return $this->error('不能冻结自己的账号!'); } } - $model = new UserModel(); + $model = new UsersModel(); if (!$model->where('id', 'in', $id)->update(['state' => 0])) { return $this->error('冻结失败'); } @@ -87,10 +87,9 @@ class Users extends Base { if ($this->request->isPost()) { $id = $this->request->post('id'); - if (!$user = UserModel::get($id)) { + if (!$user = UsersModel::get($id)) { return $this->error('数据获取失败'); } - $user->use_quota = $user->use_quota; unset($user->password); return $this->success('成功', null, $user); } @@ -105,8 +104,10 @@ class Users extends Base if (true !== $validate) { throw new Exception($validate); } - if (!$data['password']) unset($data['password']); - UserModel::update($data); + if (!$data['password']) unset($data['password'], $data['password_confirm']); + if (!UsersModel::update($data)) { + throw new Exception('修改失败'); + } } catch (Exception $e) { return $this->error($e->getMessage()); } @@ -119,7 +120,7 @@ class Users extends Base if ($this->request->isPost()) { $id = $this->request->post('id'); $state = $this->request->post('state'); - if (!$user = UserModel::get($id)) { + if (!$user = UsersModel::get($id)) { return $this->error('数据获取失败'); } if ($user->id === $this->user->id) {