feat: 增加姓名字段;修改登录账号为可修改;

This commit is contained in:
augushong
2025-03-21 14:19:04 +08:00
parent 7baa427038
commit 65e13e506a
6 changed files with 92 additions and 9 deletions

View File

@@ -84,6 +84,9 @@ class AdminBase extends AdminController
$post['password'] = password(sysconfig('site', 'site_default_password', '123456'));
$this->validate($post, $rule);
if (empty($post['nickname'])) {
$post['nickname'] = $post['username'];
}
try {
$model_admin = SystemAdmin::where('username', $post['username'])->find();
@@ -117,11 +120,21 @@ class AdminBase extends AdminController
if (isset($row['password'])) {
unset($row['password']);
}
if (empty($post['nickname'])) {
$post['nickname'] = $post['username'];
}
try {
$model_admin = SystemAdmin::where('username', $post['username'])
->where('id', '<>', $id)
->find();
if (!empty($model_admin)) {
throw new \Exception('同名用户已存在');
}
$save = $row->save($post);
TriggerService::updateMenu($id);
} catch (\Exception $e) {
$this->error('保存失败');
$this->error('保存失败' . $e->getMessage());
}
$save ? $this->success('保存成功') : $this->error('保存失败');
}