From f6b6ad3f58392b1641db4c8e20507b961f41c208 Mon Sep 17 00:00:00 2001 From: ronger Date: Thu, 16 May 2024 20:23:03 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E5=AE=8C=E5=96=84=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=9D=83=E9=99=90=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/rymcu/forest/service/UserService.java | 2 ++ .../com/rymcu/forest/service/impl/ArticleServiceImpl.java | 5 ++--- .../java/com/rymcu/forest/service/impl/UserServiceImpl.java | 5 +++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/rymcu/forest/service/UserService.java b/src/main/java/com/rymcu/forest/service/UserService.java index aef1747..f8a8e27 100644 --- a/src/main/java/com/rymcu/forest/service/UserService.java +++ b/src/main/java/com/rymcu/forest/service/UserService.java @@ -197,4 +197,6 @@ public interface UserService extends Service { * @return */ Set findUserPermissions(User user); + + boolean hasAdminPermission(String account); } diff --git a/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java index afe2e32..7faed05 100644 --- a/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java @@ -59,7 +59,6 @@ public class ArticleServiceImpl extends AbstractService
implements Arti private static final int MAX_PREVIEW = 200; private static final String DEFAULT_STATUS = "0"; private static final String DEFAULT_TOPIC_URI = "news"; - private static final int ADMIN_ROLE_WEIGHTS = 2; @Resource private ApplicationEventPublisher applicationEventPublisher; @@ -116,8 +115,8 @@ public class ArticleServiceImpl extends AbstractService
implements Arti String reservedTag = checkTags(articleTags); boolean notification = false; if (StringUtils.isNotBlank(reservedTag)) { - Integer roleWeights = userService.findRoleWeightsByUser(user.getIdUser()); - if (roleWeights > ADMIN_ROLE_WEIGHTS) { + boolean isAdmin = userService.hasAdminPermission(user.getEmail()); + if (!isAdmin) { throw new UltraViresException(StringEscapeUtils.unescapeJava(reservedTag) + "标签为系统保留标签!"); } else { notification = true; 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 7233ce4..2e5b854 100644 --- a/src/main/java/com/rymcu/forest/service/impl/UserServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/UserServiceImpl.java @@ -332,4 +332,9 @@ public class UserServiceImpl extends AbstractService implements UserServic permissions.add("user"); return permissions; } + + @Override + public boolean hasAdminPermission(String account) { + return userMapper.hasAdminPermission(account); + } }