From 19f47dee0deaa01ed6c20f946c8b049213ab5c6e Mon Sep 17 00:00:00 2001 From: ronger Date: Fri, 15 Mar 2024 16:34:38 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E6=98=B5=E7=A7=B0=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rymcu/forest/service/impl/UserServiceImpl.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/rymcu/forest/service/impl/UserServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/UserServiceImpl.java index bae90bf..7233ce4 100644 --- a/src/main/java/com/rymcu/forest/service/impl/UserServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/UserServiceImpl.java @@ -188,11 +188,11 @@ public class UserServiceImpl extends AbstractService implements UserServic @Override @Transactional(rollbackFor = Exception.class) public UserInfoDTO updateUserInfo(UserInfoDTO user) throws ServiceException { - user.setNickname(formatNickname(user.getNickname())); - Integer number = userMapper.checkNicknameByIdUser(user.getIdUser(), user.getNickname()); - if (number > 0) { + boolean number = checkNicknameByIdUser(user.getIdUser(), user.getNickname()); + if (number) { throw new NicknameOccupyException("该昵称已使用!"); } + user.setNickname(formatNickname(user.getNickname())); if (FileDataType.BASE64.equals(user.getAvatarType())) { String avatarUrl = UploadController.uploadBase64File(user.getAvatarUrl(), FilePath.AVATAR); user.setAvatarUrl(avatarUrl); @@ -216,11 +216,11 @@ public class UserServiceImpl extends AbstractService implements UserServic } public boolean checkNicknameByIdUser(Long idUser, String nickname) { - Integer number = userMapper.checkNicknameByIdUser(idUser, nickname); - if (number > 0) { - return false; + if (StringUtils.isBlank(formatNickname(nickname))) { + throw new IllegalArgumentException("昵称不能为空!"); } - return true; + Integer number = userMapper.checkNicknameByIdUser(idUser, nickname); + return number <= 0; } @Override