Skip to content

Commit

Permalink
fix: 新增用户重复bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lerry903 committed Jun 7, 2019
1 parent 0573cae commit a40c031
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.utils.ExcelUtil;
Expand Down Expand Up @@ -118,6 +119,9 @@ public AjaxResult addSave(SysUser user) {
if (ObjectUtils.allNotNull(user.getUserId()) && SysUser.isAdmin(user.getUserId())) {
return error("不允许修改超级管理员用户");
}
if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(user.getLoginName()))){
return error("保存用户'" + user.getLoginName() + "'失败,账号已存在");
}
user.setSalt(ShiroUtils.randomSalt());
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
user.setCreateBy(ShiroUtils.getLoginName());
Expand Down
23 changes: 12 additions & 11 deletions ruoyi-admin/src/main/resources/templates/system/user/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('新增用户')" />
<th:block th:include="include :: select2-css" />
<th:block th:include="include :: select2-css" />
</head>
<body>
<div class="form-content">
Expand All @@ -14,7 +14,7 @@ <h4 class="form-header h4">基本信息</h4>
<div class="form-group">
<label class="col-sm-4 control-label"><span style="color: red; ">*</span>用户名称:</label>
<div class="col-sm-8">
<input name="userName" autocomplete="off" placeholder="请输入用户名称" class="form-control" type="text" maxlength="30" required>
<input name="userName" placeholder="请输入用户名称" class="form-control" type="text" maxlength="30" required>
</div>
</div>
</div>
Expand All @@ -35,15 +35,15 @@ <h4 class="form-header h4">基本信息</h4>
<div class="form-group">
<label class="col-sm-4 control-label"><span style="color: red; ">*</span>手机号码:</label>
<div class="col-sm-8">
<input name="phonenumber" autocomplete="off" placeholder="请输入手机号码" class="form-control" type="text" maxlength="11" required>
<input name="phonenumber" placeholder="请输入手机号码" class="form-control" type="text" maxlength="11" required>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label"><span style="color: red; ">*</span>邮箱:</label>
<div class="col-sm-8">
<input name="email" autocomplete="off" class="form-control email" type="text" maxlength="50" placeholder="请输入邮箱" required>
<input name="email" class="form-control email" type="text" maxlength="50" placeholder="请输入邮箱" required>
</div>
</div>
</div>
Expand All @@ -53,15 +53,15 @@ <h4 class="form-header h4">基本信息</h4>
<div class="form-group">
<label class="col-sm-4 control-label"><span style="color: red; ">*</span>登录账号:</label>
<div class="col-sm-8">
<input name="loginName" placeholder="请输入登录账号" autocomplete="off" class="form-control required" type="text" maxlength="30" required>
<input name="loginName" placeholder="请输入登录账号" class="form-control required" type="text" maxlength="30" required>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label"><span style="color: red; ">*</span>登录密码:</label>
<div class="col-sm-8">
<input name="password" placeholder="请输入登录密码" autocomplete="off" class="form-control" type="password" th:value="${@config.getKey('sys.user.initPassword')}" required>
<input name="password" placeholder="请输入登录密码" class="form-control" type="password" th:value="${@config.getKey('sys.user.initPassword')}" required>
</div>
</div>
</div>
Expand All @@ -84,9 +84,9 @@ <h4 class="form-header h4">基本信息</h4>
<label class="col-sm-4 control-label">用户状态:</label>
<div class="col-sm-8">
<label class="toggle-switch switch-solid">
<input type="checkbox" id="status" checked>
<span></span>
</label>
<input type="checkbox" id="status" checked>
<span></span>
</label>
</div>
</div>
</div>
Expand All @@ -96,7 +96,7 @@ <h4 class="form-header h4">基本信息</h4>
<div class="form-group">
<label class="col-xs-2 control-label">岗位:</label>
<div class="col-xs-4">
<select id="post" class="form-control select2-hidden-accessible" multiple="">
<select id="post" class="form-control select2-multiple" multiple>
<option th:each="post:${posts}" th:value="${post.postId}" th:text="${post.postName}" th:disabled="${post.status == '1'}"></option>
</select>
</div>
Expand All @@ -121,13 +121,14 @@ <h4 class="form-header h4">其他信息</h4>
<div class="form-group">
<label class="col-xs-2 control-label">备注:</label>
<div class="col-xs-10">
<textarea name="remark" autocomplete="off" maxlength="500" class="form-control" rows="3"></textarea>
<textarea name="remark" maxlength="500" class="form-control" rows="3"></textarea>
</div>
</div>
</div>
</div>
</form>
</div>

<div class="row">
<div class="col-sm-offset-5 col-sm-10">
<button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
Expand Down
18 changes: 9 additions & 9 deletions ruoyi-admin/src/main/resources/templates/system/user/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改用户')" />
<th:block th:include="include :: select2-css" />
<th:block th:include="include :: select2-css" />
</head>
<body>
<div class="form-content">
Expand All @@ -15,7 +15,7 @@ <h4 class="form-header h4">基本信息</h4>
<div class="form-group">
<label class="col-sm-4 control-label"><span style="color: red; ">*</span>用户名称:</label>
<div class="col-sm-8">
<input name="userName" autocomplete="off" placeholder="请输入用户名称" class="form-control" type="text" maxlength="30" th:field="*{userName}" required>
<input name="userName" placeholder="请输入用户名称" class="form-control" type="text" maxlength="30" th:field="*{userName}" required>
</div>
</div>
</div>
Expand All @@ -36,15 +36,15 @@ <h4 class="form-header h4">基本信息</h4>
<div class="form-group">
<label class="col-sm-4 control-label"><span style="color: red; ">*</span>手机号码:</label>
<div class="col-sm-8">
<input name="phonenumber" autocomplete="off" placeholder="请输入手机号码" class="form-control" type="text" maxlength="11" th:field="*{phonenumber}" required>
<input name="phonenumber" placeholder="请输入手机号码" class="form-control" type="text" maxlength="11" th:field="*{phonenumber}" required>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label"><span style="color: red; ">*</span>邮箱:</label>
<div class="col-sm-8">
<input name="email" autocomplete="off" class="form-control email" type="text" maxlength="50" placeholder="请输入邮箱" th:field="*{email}" required>
<input name="email" class="form-control email" type="text" maxlength="50" placeholder="请输入邮箱" th:field="*{email}" required>
</div>
</div>
</div>
Expand All @@ -63,9 +63,9 @@ <h4 class="form-header h4">基本信息</h4>
<label class="col-sm-4 control-label">用户状态:</label>
<div class="col-sm-8">
<label class="toggle-switch switch-solid">
<input type="checkbox" id="status" th:checked="${user.status == '0' ? true : false}">
<span></span>
</label>
<input type="checkbox" id="status" th:checked="${user.status == '0' ? true : false}">
<span></span>
</label>
</div>
</div>
</div>
Expand All @@ -75,7 +75,7 @@ <h4 class="form-header h4">基本信息</h4>
<div class="form-group">
<label class="col-sm-4 control-label">岗位:</label>
<div class="col-sm-8">
<select id="post" class="form-control select2-hidden-accessible" multiple="">
<select id="post" class="form-control select2-multiple" multiple>
<option th:each="post:${posts}" th:value="${post.postId}" th:text="${post.postName}" th:selected="${post.flag}" th:disabled="${post.status == '1'}"></option>
</select>
</div>
Expand Down Expand Up @@ -112,7 +112,7 @@ <h4 class="form-header h4">其他信息</h4>
<div class="form-group">
<label class="col-xs-2 control-label">备注:</label>
<div class="col-xs-10">
<textarea name="remark" autocomplete="off" maxlength="500" class="form-control" rows="3">[[*{remark}]]</textarea>
<textarea name="remark" maxlength="500" class="form-control" rows="3">[[*{remark}]]</textarea>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('用户个人信息')" />
<style type="text/css">


</style>
</head>

<body class="gray-bg" style="font: 14px Helvetica Neue, Helvetica, PingFang SC, 微软雅黑, Tahoma, Arial, sans-serif !important;">
Expand Down Expand Up @@ -68,19 +64,19 @@ <h5>基本资料</h5>
<div class="form-group">
<label class="col-sm-2 control-label">用户名称:</label>
<div class="col-sm-10">
<input type="text" autocomplete="off" class="form-control" name="userName" th:field="*{userName}" placeholder="请输入用户名称">
<input type="text" class="form-control" name="userName" th:field="*{userName}" placeholder="请输入用户名称">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">手机号码:</label>
<div class="col-sm-10">
<input type="text" autocomplete="off" class="form-control" name="phonenumber" maxlength="11" th:field="*{phonenumber}" placeholder="请输入手机号码">
<input type="text" class="form-control" name="phonenumber" maxlength="11" th:field="*{phonenumber}" placeholder="请输入手机号码">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">邮箱:</label>
<div class="col-sm-10">
<input type="text" autocomplete="off" class="form-control" name="email" th:field="*{email}" placeholder="请输入邮箱">
<input type="text" class="form-control" name="email" th:field="*{email}" placeholder="请输入邮箱">
</div>
</div>
<div class="form-group">
Expand Down Expand Up @@ -220,7 +216,6 @@ <h5>基本资料</h5>
}
}


/*用户管理-修改密码*/
$("#form-user-resetPwd").validate({
onkeyup: false,
Expand Down

0 comments on commit a40c031

Please sign in to comment.