🐛 用户昵称格式化(去除特殊字符)
This commit is contained in:
parent
9ad7fc3c68
commit
f0dd030657
@ -53,7 +53,7 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Map register(String email, String password, String code) {
|
public Map register(String email, String password, String code) {
|
||||||
Map map = new HashMap(2);
|
Map map = new HashMap(2);
|
||||||
map.put("message","验证码无效!");
|
map.put("message","验证码无效!");
|
||||||
@ -88,6 +88,7 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String checkNickname(String nickname) {
|
private String checkNickname(String nickname) {
|
||||||
|
nickname = formatNickname(nickname);
|
||||||
Integer result = userMapper.selectCountByNickName(nickname);
|
Integer result = userMapper.selectCountByNickName(nickname);
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
StringBuilder stringBuilder = new StringBuilder(nickname);
|
StringBuilder stringBuilder = new StringBuilder(nickname);
|
||||||
@ -183,6 +184,7 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Map updateUserInfo(UserInfoDTO user) {
|
public Map updateUserInfo(UserInfoDTO user) {
|
||||||
Map map = new HashMap(1);
|
Map map = new HashMap(1);
|
||||||
|
user.setNickname(formatNickname(user.getNickname()));
|
||||||
Integer number = userMapper.checkNicknameByIdUser(user.getIdUser(), user.getNickname());
|
Integer number = userMapper.checkNicknameByIdUser(user.getIdUser(), user.getNickname());
|
||||||
if (number > 0) {
|
if (number > 0) {
|
||||||
map.put("message", "该昵称已使用!");
|
map.put("message", "该昵称已使用!");
|
||||||
@ -203,6 +205,10 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String formatNickname(String nickname) {
|
||||||
|
return nickname.replaceAll(".", "");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map checkNickname(Integer idUser, String nickname) {
|
public Map checkNickname(Integer idUser, String nickname) {
|
||||||
Map map = new HashMap(1);
|
Map map = new HashMap(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user