🐛 完善用户权限判断
This commit is contained in:
parent
0d890c302b
commit
f6b6ad3f58
@ -197,4 +197,6 @@ public interface UserService extends Service<User> {
|
||||
* @return
|
||||
*/
|
||||
Set<String> findUserPermissions(User user);
|
||||
|
||||
boolean hasAdminPermission(String account);
|
||||
}
|
||||
|
@ -59,7 +59,6 @@ public class ArticleServiceImpl extends AbstractService<Article> 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<Article> 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;
|
||||
|
@ -332,4 +332,9 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
||||
permissions.add("user");
|
||||
return permissions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAdminPermission(String account) {
|
||||
return userMapper.hasAdminPermission(account);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user