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); + } }