mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-01 15:32:48 +08:00
增加默认密码;修改curd返回异常信息;去除admin表username唯一值;
This commit is contained in:
@@ -74,6 +74,8 @@ abstract class BaseController
|
||||
if (is_array($validate)) {
|
||||
$v = new Validate();
|
||||
$v->rule($validate);
|
||||
} else if ($validate instanceof Validate) {
|
||||
$v = $validate;
|
||||
} else {
|
||||
if (strpos($validate, '.')) {
|
||||
// 支持场景
|
||||
|
||||
@@ -11,6 +11,8 @@ use app\common\controller\AdminController;
|
||||
use app\admin\service\annotation\ControllerAnnotation;
|
||||
use app\admin\service\annotation\NodeAnotation;
|
||||
use think\App;
|
||||
use think\facade\Validate;
|
||||
use think\validate\ValidateRule;
|
||||
|
||||
/**
|
||||
* Class Admin
|
||||
@@ -76,12 +78,23 @@ class Admin extends AdminController
|
||||
$post = $this->request->post();
|
||||
$authIds = $this->request->post('auth_ids', []);
|
||||
$post['auth_ids'] = implode(',', array_keys($authIds));
|
||||
$rule = [];
|
||||
$rule = Validate::rule('username|用户登录名', ValidateRule::isRequire());
|
||||
$post['password'] = password(sysconfig('site', 'site_default_password', '123456'));
|
||||
$this->validate($post, $rule);
|
||||
|
||||
|
||||
|
||||
try {
|
||||
|
||||
$model_admin = SystemAdmin::where('username', $post['username'])->find();
|
||||
|
||||
if (!empty($model_admin)) {
|
||||
throw new \Exception('同名用户已存在');
|
||||
}
|
||||
|
||||
$save = $this->model->save($post);
|
||||
} catch (\Exception $e) {
|
||||
$this->error('保存失败');
|
||||
$this->error('保存失败:' . $e->getMessage());
|
||||
}
|
||||
$save ? $this->success('保存成功') : $this->error('保存失败');
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ trait Curd
|
||||
try {
|
||||
$save = $row->save($post);
|
||||
} catch (\Exception $e) {
|
||||
$this->error('保存失败');
|
||||
$this->error('保存失败:' . $e->getMessage());
|
||||
}
|
||||
$save ? $this->success('保存成功') : $this->error('保存失败');
|
||||
}
|
||||
@@ -98,7 +98,7 @@ trait Curd
|
||||
try {
|
||||
$save = $row->delete();
|
||||
} catch (\Exception $e) {
|
||||
$this->error('删除失败');
|
||||
$this->error('删除失败:' . $e->getMessage());
|
||||
}
|
||||
$save ? $this->success('删除成功') : $this->error('删除失败');
|
||||
}
|
||||
@@ -156,7 +156,7 @@ trait Curd
|
||||
$post['field'] => $post['value'],
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
$this->error($e->getMessage());
|
||||
$this->error('修改失败:' . $e->getMessage());
|
||||
}
|
||||
$this->success('保存成功');
|
||||
}
|
||||
|
||||
@@ -49,6 +49,13 @@
|
||||
<tip>填写站点域名。以http://或https://开头,内置的定时任务用到了这个配置项,修改之后需要重启定时任务</tip>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">默认密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="site_default_password" class="layui-input" placeholder="请输入默认密码" value="{:sysconfig('site','site_default_password')}">
|
||||
<tip>添加账号时自动填充的密码,默认为:123456 。建议填写为您系统特有的默认密码规则,比如:ul-aa@@123</tip>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">js脚本</label>
|
||||
<div class="layui-input-block">
|
||||
|
||||
@@ -32,13 +32,13 @@ class SystemAdmin extends Migrator
|
||||
->setComment('系统用户表')
|
||||
->addColumn(Column::char('auth_ids')->setDefault('')->setComment('角色权限ID'))
|
||||
->addColumn(Column::char('head_img')->setDefault('')->setComment('头像'))
|
||||
->addColumn(Column::char('username', 50)->setDefault('')->setUnique()->setComment('用户登录名'))
|
||||
->addColumn(Column::char('username', 50)->setDefault('')->setComment('用户登录名'))
|
||||
->addColumn(Column::char('password', 40)->setDefault('')->setComment('用户密码'))
|
||||
->addColumn(Column::char('phone',16)->setDefault('')->setComment('联系手机号'))
|
||||
->addColumn(Column::char('remark')->setDefault('')->setComment('备注说明'))
|
||||
->addColumn(Column::bigInteger('login_num')->setUnsigned()->setDefault(0)->setComment('登录次数'))
|
||||
->addColumn(Column::integer('sort')->setDefault(0)->setComment('排序'))
|
||||
->addColumn(Column::tinyInteger('status')->setLimit(1)->setUnsigned()->setDefault(0)->setComment('状态 {radio} (0:禁用,1:启用,)'))
|
||||
->addColumn(Column::tinyInteger('status')->setLimit(1)->setUnsigned()->setDefault(1)->setComment('状态 {radio} (0:禁用,1:启用,)'))
|
||||
->addColumn(Column::integer('create_time')->setLimit(11)->setUnsigned()->setDefault(0)->setComment('创建时间'))
|
||||
->addColumn(Column::integer('update_time')->setLimit(11)->setUnsigned()->setDefault(0))
|
||||
->addColumn(Column::integer('delete_time')->setLimit(11)->setUnsigned()->setDefault(0))
|
||||
|
||||
Reference in New Issue
Block a user