修复后台无法修改用户储存容量的bug

This commit is contained in:
wispx
2018-12-07 16:02:04 +08:00
parent cce5c1e221
commit 7a93c179da
2 changed files with 12 additions and 11 deletions
+2 -2
View File
@@ -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()
+10 -9
View File
@@ -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) {