mirror of https://gitee.com/y_project/RuoYi.git
支持手机号码、邮箱登录
parent
a624ac009e
commit
fab59267ed
|
@ -62,18 +62,7 @@ create table sys_user (
|
|||
-- 初始化-用户信息表数据
|
||||
-- ----------------------------
|
||||
insert into sys_user values(1, 106, 'admin', '若依', 'ry@163.com', '15888888888', '1', '', '29c67a30398638269fe600f73a054934', '111111', 'Y', 0, '正常', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
|
||||
insert into sys_user values(2, 108, 'ry', '若依', 'ry@163.com', '15888888888', '1', '', '8e6d98b90472783cc73c17047ddccf36', '222222', 'N', 0, '正常', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
|
||||
insert into sys_user values(3, 106, 'ly', '刘一', 'ry@163.com', '15888888888', '0', '', '648b02ef941c587a2f18a297a88a4d2f', '123456', 'N', 0, '正常', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
|
||||
insert into sys_user values(4, 106, 'ce', '陈二', 'ry@163.com', '15888888888', '0', '', '9cee0cee6868803bee994cb38512f32a', '123456', 'N', 0, '正常', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
|
||||
insert into sys_user values(5, 106, 'zs', '张三', 'ry@163.com', '15888888888', '0', '', 'eba13c577181da9df8133b580302b542', '123456', 'N', 0, '正常', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
|
||||
insert into sys_user values(6, 106, 'ls', '李四', 'ry@163.com', '15888888888', '0', '', '15e31a50b42934e08587a137d9c22beb', '123456', 'N', 0, '正常', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
|
||||
insert into sys_user values(7, 106, 'ww', '王五', 'ry@163.com', '15888888888', '0', '', 'a4e07697413f78f286650a0682899e32', '123456', 'N', 0, '正常', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
|
||||
insert into sys_user values(8, 106, 'zl', '赵六', 'ry@163.com', '15888888888', '0', '', '047e1daf6e2ac6b6d706f81bb21f67ec', '123456', 'N', 0, '正常', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
|
||||
insert into sys_user values(9, 106, 'sq', '孙七', 'ry@163.com', '15888888888', '0', '', '7ff6776ff40c5c0eadc6c4c52555268b', '123456', 'N', 0, '正常', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
|
||||
insert into sys_user values(10, 106, 'zb', '周八', 'ry@163.com', '15888888888', '0', '', 'd41dca20a574699eaa851a6b7e7cb12f', '123456', 'N', 0, '正常', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
|
||||
insert into sys_user values(11, 106, 'wj', '吴九', 'ry@163.com', '15888888888', '0', '', 'cfa9a24ab0c402cc2898795c2c3a973d', '123456', 'N', 0, '正常', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
|
||||
insert into sys_user values(12, 106, 'ys', '阳十', 'ry@163.com', '15888888888', '0', '', '700a6f8c57d894bfba7692283b345db8', '123456', 'N', 0, '正常', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
|
||||
|
||||
insert into sys_user values(2, 108, 'ry', '若依', 'ry@qq.com', '15666666666', '1', '', '8e6d98b90472783cc73c17047ddccf36', '222222', 'N', 0, '正常', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
|
||||
|
||||
-- ----------------------------
|
||||
-- 3、岗位信息表
|
|
@ -29,9 +29,33 @@ public class UserConstants
|
|||
public static final int USERNAME_MIN_LENGTH = 2;
|
||||
public static final int USERNAME_MAX_LENGTH = 20;
|
||||
|
||||
/** 名称是否唯一的返回结果码 */
|
||||
public final static String NAME_UNIQUE = "0";
|
||||
public final static String NAME_NOT_UNIQUE = "1";
|
||||
/** 登录名称是否唯一的返回结果码 */
|
||||
public final static String USER_NAME_UNIQUE = "0";
|
||||
public final static String USER_NAME_NOT_UNIQUE = "1";
|
||||
|
||||
/** 手机号码是否唯一的返回结果 */
|
||||
public final static String USER_PHONE_UNIQUE = "0";
|
||||
public final static String USER_PHONE_NOT_UNIQUE = "1";
|
||||
|
||||
/** e-mail 是否唯一的返回结果 */
|
||||
public final static String USER_EMAIL_UNIQUE = "0";
|
||||
public final static String USER_EMAIL_NOT_UNIQUE = "1";
|
||||
|
||||
/** 部门名称是否唯一的返回结果码 */
|
||||
public final static String DEPT_NAME_UNIQUE = "0";
|
||||
public final static String DEPT_NAME_NOT_UNIQUE = "1";
|
||||
|
||||
/** 角色名称是否唯一的返回结果码 */
|
||||
public final static String ROLE_NAME_UNIQUE = "0";
|
||||
public final static String ROLE_NAME_NOT_UNIQUE = "1";
|
||||
|
||||
/** 菜单名称是否唯一的返回结果码 */
|
||||
public final static String MENU_NAME_UNIQUE = "0";
|
||||
public final static String MENU_NAME_NOT_UNIQUE = "1";
|
||||
|
||||
/** 字典类型是否唯一的返回结果码 */
|
||||
public final static String DICT_TYPE_UNIQUE = "0";
|
||||
public final static String DICT_TYPE_NOT_UNIQUE = "1";
|
||||
|
||||
/**
|
||||
* 密码长度限制
|
||||
|
@ -39,4 +63,14 @@ public class UserConstants
|
|||
public static final int PASSWORD_MIN_LENGTH = 5;
|
||||
public static final int PASSWORD_MAX_LENGTH = 20;
|
||||
|
||||
/**
|
||||
* 手机号码格式限制
|
||||
*/
|
||||
public static final String MOBILE_PHONE_NUMBER_PATTERN = "^0{0,1}(13[0-9]|15[0-9]|14[0-9]|18[0-9])[0-9]{8}$";
|
||||
|
||||
/**
|
||||
* 邮箱格式限制
|
||||
*/
|
||||
public static final String EMAIL_PATTERN = "^((([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.?";
|
||||
|
||||
}
|
||||
|
|
|
@ -64,8 +64,18 @@ public class LoginService
|
|||
}
|
||||
|
||||
// 查询用户信息
|
||||
User user = userService.selectUserByName(username);
|
||||
User user = userService.selectUserByLoginName(username);
|
||||
|
||||
if (user == null && maybeMobilePhoneNumber(username))
|
||||
{
|
||||
user = userService.selectUserByPhoneNumber(username);
|
||||
}
|
||||
|
||||
if (user == null && maybeEmail(username))
|
||||
{
|
||||
user = userService.selectUserByEmail(username);
|
||||
}
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
SystemLogUtils.log(username, CommonConstant.LOGIN_FAIL, MessageUtils.message("user.not.exists"));
|
||||
|
@ -79,9 +89,27 @@ public class LoginService
|
|||
SystemLogUtils.log(username, CommonConstant.LOGIN_FAIL, MessageUtils.message("user.blocked", user.getRefuseDes()));
|
||||
throw new UserBlockedException(user.getRefuseDes());
|
||||
}
|
||||
|
||||
|
||||
SystemLogUtils.log(username, CommonConstant.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
|
||||
return user;
|
||||
}
|
||||
|
||||
private boolean maybeEmail(String username)
|
||||
{
|
||||
if (!username.matches(UserConstants.EMAIL_PATTERN))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean maybeMobilePhoneNumber(String username)
|
||||
{
|
||||
if (!username.matches(UserConstants.MOBILE_PHONE_NUMBER_PATTERN))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -145,8 +145,8 @@ public class DeptServiceImpl implements IDeptService
|
|||
if (StringUtils.isNotNull(info) && StringUtils.isNotNull(info.getDeptId())
|
||||
&& info.getDeptId().longValue() != deptId.longValue())
|
||||
{
|
||||
return UserConstants.NAME_NOT_UNIQUE;
|
||||
return UserConstants.DEPT_NAME_NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.NAME_UNIQUE;
|
||||
return UserConstants.DEPT_NAME_UNIQUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,8 +107,8 @@ public class DictTypeServiceImpl implements IDictTypeService
|
|||
DictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType());
|
||||
if (StringUtils.isNotNull(dictType) && dictType.getDictId() != dictId)
|
||||
{
|
||||
return UserConstants.NAME_NOT_UNIQUE;
|
||||
return UserConstants.DICT_TYPE_NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.NAME_UNIQUE;
|
||||
return UserConstants.DICT_TYPE_UNIQUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -267,9 +267,9 @@ public class MenuServiceImpl implements IMenuService
|
|||
if (StringUtils.isNotNull(info) && StringUtils.isNotNull(info.getMenuId())
|
||||
&& info.getMenuId().longValue() != menuId.longValue())
|
||||
{
|
||||
return UserConstants.NAME_NOT_UNIQUE;
|
||||
return UserConstants.MENU_NAME_NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.NAME_UNIQUE;
|
||||
return UserConstants.MENU_NAME_UNIQUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -205,9 +205,9 @@ public class RoleServiceImpl implements IRoleService
|
|||
Role info = roleMapper.checkRoleNameUnique(role.getRoleName());
|
||||
if (StringUtils.isNotNull(info) && StringUtils.isNotNull(info.getRoleId()) && info.getRoleId() != roleId)
|
||||
{
|
||||
return UserConstants.NAME_NOT_UNIQUE;
|
||||
return UserConstants.ROLE_NAME_NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.NAME_UNIQUE;
|
||||
return UserConstants.ROLE_NAME_UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -171,16 +171,46 @@ public class UserController extends BaseController
|
|||
/**
|
||||
* 校验用户名
|
||||
*/
|
||||
@PostMapping("/checkUserNameUnique")
|
||||
@PostMapping("/checkLoginNameUnique")
|
||||
@ResponseBody
|
||||
public String checkUserNameUnique(User user)
|
||||
public String checkLoginNameUnique(User user)
|
||||
{
|
||||
String uniqueFlag = "0";
|
||||
if (user != null)
|
||||
{
|
||||
uniqueFlag = userService.checkUserNameUnique(user.getLoginName());
|
||||
uniqueFlag = userService.checkLoginNameUnique(user.getLoginName());
|
||||
}
|
||||
return uniqueFlag;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验手机号码
|
||||
*/
|
||||
@PostMapping("/checkPhoneUnique")
|
||||
@ResponseBody
|
||||
public String checkPhoneUnique(User user)
|
||||
{
|
||||
String uniqueFlag = "0";
|
||||
if (user != null)
|
||||
{
|
||||
uniqueFlag = userService.checkPhoneUnique(user);
|
||||
}
|
||||
return uniqueFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验手机号码
|
||||
*/
|
||||
@PostMapping("/checkEmailUnique")
|
||||
@ResponseBody
|
||||
public String checkEmailUnique(User user)
|
||||
{
|
||||
String uniqueFlag = "0";
|
||||
if (user != null)
|
||||
{
|
||||
uniqueFlag = userService.checkEmailUnique(user);
|
||||
}
|
||||
return uniqueFlag;
|
||||
}
|
||||
}
|
|
@ -25,7 +25,23 @@ public interface UserMapper
|
|||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public User selectUserByName(String userName);
|
||||
public User selectUserByLoginName(String userName);
|
||||
|
||||
/**
|
||||
* 通过手机号码查询用户
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public User selectUserByPhoneNumber(String phoneNumber);
|
||||
|
||||
/**
|
||||
* 通过邮箱查询用户
|
||||
*
|
||||
* @param email 邮箱
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public User selectUserByEmail(String email);
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
|
@ -73,6 +89,23 @@ public interface UserMapper
|
|||
* @param loginName 登录名称
|
||||
* @return 结果
|
||||
*/
|
||||
public int checkUserNameUnique(String loginName);
|
||||
public int checkLoginNameUnique(String loginName);
|
||||
|
||||
|
||||
/**
|
||||
* 校验手机号码是否唯一
|
||||
*
|
||||
* @param phonenumber 手机号码
|
||||
* @return 结果
|
||||
*/
|
||||
public User checkPhoneUnique(String phonenumber);
|
||||
|
||||
|
||||
/**
|
||||
* 校验email是否唯一
|
||||
*
|
||||
* @param email 用户邮箱
|
||||
* @return 结果
|
||||
*/
|
||||
public User checkEmailUnique(String email);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,23 @@ public interface IUserService
|
|||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public User selectUserByName(String userName);
|
||||
public User selectUserByLoginName(String userName);
|
||||
|
||||
/**
|
||||
* 通过手机号码查询用户
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public User selectUserByPhoneNumber(String phoneNumber);
|
||||
|
||||
/**
|
||||
* 通过邮箱查询用户
|
||||
*
|
||||
* @param email 邮箱
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public User selectUserByEmail(String email);
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
|
@ -81,7 +97,25 @@ public interface IUserService
|
|||
* @param loginName 登录名称
|
||||
* @return 结果
|
||||
*/
|
||||
public String checkUserNameUnique(String loginName);
|
||||
public String checkLoginNameUnique(String loginName);
|
||||
|
||||
|
||||
/**
|
||||
* 校验手机号码是否唯一
|
||||
*
|
||||
* @param phonenumber 登录名称
|
||||
* @return 结果
|
||||
*/
|
||||
public String checkPhoneUnique(User user);
|
||||
|
||||
|
||||
/**
|
||||
* 校验email是否唯一
|
||||
*
|
||||
* @param email 登录名称
|
||||
* @return 结果
|
||||
*/
|
||||
public String checkEmailUnique(User user);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询用户所属角色组
|
||||
|
|
|
@ -66,9 +66,33 @@ public class UserServiceImpl implements IUserService
|
|||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public User selectUserByName(String userName)
|
||||
public User selectUserByLoginName(String userName)
|
||||
{
|
||||
return userMapper.selectUserByName(userName);
|
||||
return userMapper.selectUserByLoginName(userName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过手机号码查询用户
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public User selectUserByPhoneNumber(String phoneNumber)
|
||||
{
|
||||
return userMapper.selectUserByPhoneNumber(phoneNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过邮箱查询用户
|
||||
*
|
||||
* @param email 邮箱
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public User selectUserByEmail(String email)
|
||||
{
|
||||
return userMapper.selectUserByEmail(email);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -227,18 +251,56 @@ public class UserServiceImpl implements IUserService
|
|||
/**
|
||||
* 校验用户名称是否唯一
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param loginName 用户名
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String checkUserNameUnique(String loginName)
|
||||
public String checkLoginNameUnique(String loginName)
|
||||
{
|
||||
int count = userMapper.checkUserNameUnique(loginName);
|
||||
int count = userMapper.checkLoginNameUnique(loginName);
|
||||
if (count > 0)
|
||||
{
|
||||
return UserConstants.NAME_NOT_UNIQUE;
|
||||
return UserConstants.USER_NAME_NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.NAME_UNIQUE;
|
||||
return UserConstants.USER_NAME_UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户名称是否唯一
|
||||
*
|
||||
* @param phonenumber 用户名
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String checkPhoneUnique(User user)
|
||||
{
|
||||
Long userId = user.getUserId();
|
||||
User info = userMapper.checkPhoneUnique(user.getPhonenumber());
|
||||
if (StringUtils.isNotNull(info) && StringUtils.isNotNull(info.getUserId())
|
||||
&& info.getUserId().longValue() != userId.longValue())
|
||||
{
|
||||
return UserConstants.USER_PHONE_NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.USER_PHONE_UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验email是否唯一
|
||||
*
|
||||
* @param email 用户名
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String checkEmailUnique(User user)
|
||||
{
|
||||
Long userId = user.getUserId();
|
||||
User info = userMapper.checkEmailUnique(user.getEmail());
|
||||
if (StringUtils.isNotNull(info) && StringUtils.isNotNull(info.getUserId())
|
||||
&& info.getUserId().longValue() != userId.longValue())
|
||||
{
|
||||
return UserConstants.USER_EMAIL_NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.USER_EMAIL_UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -66,7 +66,7 @@ shiro:
|
|||
# 首页地址
|
||||
indexUrl: /index
|
||||
# 验证码开关
|
||||
captchaEbabled: true
|
||||
captchaEbabled: false
|
||||
# 验证码类型 math 数组计算 char 字符
|
||||
captchaType: math
|
||||
cookie:
|
||||
|
|
|
@ -45,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectUserByName" parameterType="String" resultMap="UserResult">
|
||||
<select id="selectUserByLoginName" parameterType="String" resultMap="UserResult">
|
||||
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.refuse_des, u.create_time,
|
||||
d.dept_id, d.parent_id, d.dept_name, d.order_num, d.status as dept_status
|
||||
from sys_user u
|
||||
|
@ -54,10 +54,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
where u.login_name = #{userName}
|
||||
</select>
|
||||
|
||||
<select id="checkUserNameUnique" parameterType="String" resultType="int">
|
||||
<select id="selectUserByPhoneNumber" parameterType="String" resultMap="UserResult">
|
||||
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.refuse_des, u.create_time,
|
||||
d.dept_id, d.parent_id, d.dept_name, d.order_num, d.status as dept_status
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
left join sys_user_role ur on u.user_id = ur.user_id
|
||||
where u.phonenumber = #{phonenumber}
|
||||
</select>
|
||||
|
||||
<select id="selectUserByEmail" parameterType="String" resultMap="UserResult">
|
||||
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.refuse_des, u.create_time,
|
||||
d.dept_id, d.parent_id, d.dept_name, d.order_num, d.status as dept_status
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
left join sys_user_role ur on u.user_id = ur.user_id
|
||||
where u.email = #{email}
|
||||
</select>
|
||||
|
||||
<select id="checkLoginNameUnique" parameterType="String" resultType="int">
|
||||
select count(*) from sys_user where login_name=#{loginName}
|
||||
</select>
|
||||
|
||||
<select id="checkPhoneUnique" parameterType="String" resultMap="UserResult">
|
||||
select user_id, phonenumber from sys_user where phonenumber=#{phonenumber}
|
||||
</select>
|
||||
|
||||
<select id="checkEmailUnique" parameterType="String" resultMap="UserResult">
|
||||
select user_id, email from sys_user where email=#{email}
|
||||
</select>
|
||||
|
||||
<select id="selectUserById" parameterType="Long" resultMap="UserResult">
|
||||
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.refuse_des, u.create_time,
|
||||
d.dept_id, d.parent_id, d.dept_name, d.order_num, d.status as dept_status
|
||||
|
|
|
@ -5,7 +5,7 @@ $("#form-user-add").validate({
|
|||
minlength: 2,
|
||||
maxlength: 20,
|
||||
remote: {
|
||||
url: ctx + "system/user/checkUserNameUnique",
|
||||
url: ctx + "system/user/checkLoginNameUnique",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: {
|
||||
|
@ -32,16 +32,50 @@ $("#form-user-add").validate({
|
|||
},
|
||||
email:{
|
||||
required:true,
|
||||
email:true
|
||||
email:true,
|
||||
remote: {
|
||||
url: ctx + "system/user/checkEmailUnique",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: {
|
||||
name: function () {
|
||||
return $.trim($("#email").val());
|
||||
}
|
||||
},
|
||||
dataFilter: function (data, type) {
|
||||
if (data == "0") return true;
|
||||
else return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
phonenumber:{
|
||||
required:true,
|
||||
remote: {
|
||||
url: ctx + "system/user/checkPhoneUnique",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: {
|
||||
name: function () {
|
||||
return $.trim($("#phonenumber").val());
|
||||
}
|
||||
},
|
||||
dataFilter: function (data, type) {
|
||||
if (data == "0") return true;
|
||||
else return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
messages: {
|
||||
"loginName": {
|
||||
remote: "用户已经存在"
|
||||
}
|
||||
},
|
||||
"email": {
|
||||
remote: "Email已经存在"
|
||||
},
|
||||
"phonenumber":{
|
||||
remote: "手机号码已经存在"
|
||||
}
|
||||
},
|
||||
submitHandler:function(form){
|
||||
add();
|
||||
|
|
|
@ -8,12 +8,54 @@ $("#form-user-edit").validate({
|
|||
},
|
||||
email:{
|
||||
required:true,
|
||||
email:true
|
||||
email:true,
|
||||
remote: {
|
||||
url: ctx + "system/user/checkEmailUnique",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: {
|
||||
"userId": function() {
|
||||
return $("input[name='userId']").val();
|
||||
},
|
||||
"email": function() {
|
||||
return $("input[name='email']").val();
|
||||
}
|
||||
},
|
||||
dataFilter: function (data, type) {
|
||||
if (data == "0") return true;
|
||||
else return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
phonenumber:{
|
||||
required:true,
|
||||
remote: {
|
||||
url: ctx + "system/user/checkPhoneUnique",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: {
|
||||
"userId": function() {
|
||||
return $("input[name='userId']").val();
|
||||
},
|
||||
"phonenumber": function() {
|
||||
return $("input[name='phonenumber']").val();
|
||||
}
|
||||
},
|
||||
dataFilter: function (data, type) {
|
||||
if (data == "0") return true;
|
||||
else return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
messages: {
|
||||
"email": {
|
||||
remote: "Email已经存在"
|
||||
},
|
||||
"phonenumber":{
|
||||
remote: "手机号码已经存在"
|
||||
}
|
||||
},
|
||||
submitHandler:function(form){
|
||||
update();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">邮箱:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="email">
|
||||
<input class="form-control" type="text" name="email" id="email">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">邮箱:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="email" th:value="${user.email}">
|
||||
<input class="form-control" type="text" name="email" id="email" th:value="${user.email}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
|
Loading…
Reference in New Issue