From 7399dca13296f13bfce8880312bb663c60cf78dc Mon Sep 17 00:00:00 2001 From: ronger Date: Fri, 17 Dec 2021 19:58:41 +0800 Subject: [PATCH 1/3] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E5=85=B3?= =?UTF-8?q?=E6=B3=A8=E6=8F=90=E9=86=92=E9=93=BE=E6=8E=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/rymcu/forest/util/NotificationUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/rymcu/forest/util/NotificationUtils.java b/src/main/java/com/rymcu/forest/util/NotificationUtils.java index 9f5c9a4..93de7d0 100644 --- a/src/main/java/com/rymcu/forest/util/NotificationUtils.java +++ b/src/main/java/com/rymcu/forest/util/NotificationUtils.java @@ -116,7 +116,7 @@ public class NotificationUtils { notificationDTO.setDataTitle("关注提醒"); if (Objects.nonNull(follow)) { user = userService.findById(follow.getFollowerId().toString()); - notificationDTO.setDataUrl(getFollowLink(follow.getFollowingType(), user.getNickname())); + notificationDTO.setDataUrl(getFollowLink(follow.getFollowingType(), user.getAccount())); notificationDTO.setAuthor(genAuthor(user)); } break; From fa2212164e9f901edfbba41d4cf6ed0f75cdab08 Mon Sep 17 00:00:00 2001 From: ronger Date: Fri, 17 Dec 2021 20:16:43 +0800 Subject: [PATCH 2/3] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E8=B4=A6=E5=8F=B7=E9=87=8D=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/rymcu/forest/mapper/UserMapper.java | 7 +++++++ .../forest/service/impl/UserServiceImpl.java | 15 ++++++++++++--- src/main/java/mapper/UserMapper.xml | 3 +++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/rymcu/forest/mapper/UserMapper.java b/src/main/java/com/rymcu/forest/mapper/UserMapper.java index dc2d4c2..d2f42e8 100644 --- a/src/main/java/com/rymcu/forest/mapper/UserMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/UserMapper.java @@ -158,4 +158,11 @@ public interface UserMapper extends Mapper { * @return */ boolean hasAdminPermission(@Param("email") String email); + + /** + * 验证账号是否重复 + * @param account + * @return + */ + Integer selectCountByAccount(@Param("account") String account); } \ No newline at end of file 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 4fb3ca7..013522e 100644 --- a/src/main/java/com/rymcu/forest/service/impl/UserServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/UserServiceImpl.java @@ -65,9 +65,8 @@ public class UserServiceImpl extends AbstractService implements UserServic } else { user = new User(); String nickname = email.split("@")[0]; - nickname = checkNickname(nickname); - user.setNickname(nickname); - user.setAccount(nickname); + user.setNickname(checkNickname(nickname)); + user.setAccount(checkAccount(nickname)); user.setEmail(email); user.setPassword(Utils.entryptPassword(password)); user.setCreatedTime(new Date()); @@ -101,6 +100,16 @@ public class UserServiceImpl extends AbstractService implements UserServic return nickname; } + private String checkAccount(String account) { + account = formatNickname(account); + Integer result = userMapper.selectCountByAccount(account); + if (result > 0) { + StringBuilder stringBuilder = new StringBuilder(account); + return checkNickname(stringBuilder.append("_").append(System.currentTimeMillis()).toString()); + } + return account; + } + @Override public Map login(String account, String password) { Map map = new HashMap(1); diff --git a/src/main/java/mapper/UserMapper.xml b/src/main/java/mapper/UserMapper.xml index 4dc17f4..11b203c 100644 --- a/src/main/java/mapper/UserMapper.xml +++ b/src/main/java/mapper/UserMapper.xml @@ -116,5 +116,8 @@ select if(count(fur.id_role) = 0, false, true) from forest_user_role fur join forest_user fu on fur.id_user = fu.id where fu.email = #{email} and exists(select id_role from forest_role fr where instr(fr.input_code, 'admin') > 0 and fr.id = fur.id_role) + \ No newline at end of file From c2967818ae67f5bfc7e2704538043adc05a82b90 Mon Sep 17 00:00:00 2001 From: ronger Date: Tue, 21 Dec 2021 11:38:39 +0800 Subject: [PATCH 3/3] Update pom.xml --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 1b8df32..57e38bc 100644 --- a/pom.xml +++ b/pom.xml @@ -163,7 +163,7 @@ org.apache.logging.log4j log4j-to-slf4j - 2.16.0 + 2.17.0 org.apache.logging.log4j @@ -174,7 +174,7 @@ org.apache.logging.log4j log4j-api - 2.16.0 + 2.17.0 org.springframework.boot