Commit 2d85f204 by 张晋雄

修改用户昵称重复的问题

parent ad4eb0fc
...@@ -27,7 +27,8 @@ public enum UserErrorCode implements IErrorCode { ...@@ -27,7 +27,8 @@ public enum UserErrorCode implements IErrorCode {
BINDING_EMAIL_VERIFY_CODE_ERROR(10014, "邮箱验证码错误"), BINDING_EMAIL_VERIFY_CODE_ERROR(10014, "邮箱验证码错误"),
BINDING_MOBILE_VERIFY_CODE_ERROR(10015, "手机验证码错误"), BINDING_MOBILE_VERIFY_CODE_ERROR(10015, "手机验证码错误"),
NON_LOCAL_AUTH_INFO(10016, "该手机未注册"), NON_LOCAL_AUTH_INFO(10016, "该手机未注册"),
USER_NOT_EXISTS(10017, "要查看的用户不存在"); USER_NOT_EXISTS(10017, "要查看的用户不存在"),
USER_NICK_NAME_USED(10018,"该昵称已存在");
UserErrorCode(long code, String msg) { UserErrorCode(long code, String msg) {
this.code = code; this.code = code;
......
...@@ -214,6 +214,15 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU ...@@ -214,6 +214,15 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
boolean userNickUpdate = !StringUtils.isEmpty(user.getNickName()); boolean userNickUpdate = !StringUtils.isEmpty(user.getNickName());
boolean userAvatarUpdate = !StringUtils.isEmpty(user.getUserAvatar()); boolean userAvatarUpdate = !StringUtils.isEmpty(user.getUserAvatar());
//查询昵称是否重复
if(null != user.getNickName()){
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("nick_name", user.getNickName());
if( null != getOne(queryWrapper)){
throw new UserServiceException(UserErrorCode.USER_NICK_NAME_USED);
}
}
updateById(user); updateById(user);
if (userNickUpdate) { if (userNickUpdate) {
......
...@@ -4,7 +4,7 @@ spring: ...@@ -4,7 +4,7 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/beyond_clouds?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true url: jdbc:mysql://127.0.0.1:3306/beyond_clouds?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true
username: root username: root
password: 197442 password: 2018006709
# 邮箱 # 邮箱
mail: mail:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment