diff --git a/src/main/java/com/rymcu/vertical/service/impl/UserServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/UserServiceImpl.java index 3a007ee..3efeabe 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/UserServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/UserServiceImpl.java @@ -53,7 +53,7 @@ public class UserServiceImpl extends AbstractService implements UserServic } @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public Map register(String email, String password, String code) { Map map = new HashMap(2); map.put("message","验证码无效!"); @@ -88,6 +88,7 @@ public class UserServiceImpl extends AbstractService implements UserServic } private String checkNickname(String nickname) { + nickname = formatNickname(nickname); Integer result = userMapper.selectCountByNickName(nickname); if (result > 0) { StringBuilder stringBuilder = new StringBuilder(nickname); @@ -183,6 +184,7 @@ public class UserServiceImpl extends AbstractService implements UserServic @Transactional(rollbackFor = Exception.class) public Map updateUserInfo(UserInfoDTO user) { Map map = new HashMap(1); + user.setNickname(formatNickname(user.getNickname())); Integer number = userMapper.checkNicknameByIdUser(user.getIdUser(), user.getNickname()); if (number > 0) { map.put("message", "该昵称已使用!"); @@ -203,6 +205,10 @@ public class UserServiceImpl extends AbstractService implements UserServic return map; } + private String formatNickname(String nickname) { + return nickname.replaceAll(".", ""); + } + @Override public Map checkNickname(Integer idUser, String nickname) { Map map = new HashMap(1);