💩 修改文章标签进行鉴权
This commit is contained in:
parent
8795621531
commit
e7e672a7b7
@ -1,7 +1,6 @@
|
||||
package com.rymcu.forest.service.impl;
|
||||
|
||||
import com.rymcu.forest.core.constant.NotificationConstant;
|
||||
import com.rymcu.forest.core.constant.ProjectConstant;
|
||||
import com.rymcu.forest.core.service.AbstractService;
|
||||
import com.rymcu.forest.dto.*;
|
||||
import com.rymcu.forest.entity.Article;
|
||||
@ -323,7 +322,7 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
||||
Map map = new HashMap(2);
|
||||
Article article = articleMapper.selectByPrimaryKey(idArticle);
|
||||
if (Objects.nonNull(article)) {
|
||||
if (isAuthor(article.getArticleAuthorId())) {
|
||||
if (isAuthor(article.getArticleAuthorId()) || hasAdminPermission()) {
|
||||
article.setArticleTags(tags);
|
||||
articleMapper.updateArticleTags(idArticle, tags);
|
||||
tagService.saveTagArticle(article, "");
|
||||
@ -339,6 +338,15 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
||||
return map;
|
||||
}
|
||||
|
||||
private boolean hasAdminPermission() throws BaseApiException {
|
||||
User user = UserUtils.getCurrentUserByToken();
|
||||
if (Objects.nonNull(user)) {
|
||||
Integer userRoleWeight = userService.findRoleWeightsByUser(user.getIdUser());
|
||||
return userRoleWeight <= ADMIN_ROLE_WEIGHTS;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isAuthor(Integer idUser) throws BaseApiException {
|
||||
User user = UserUtils.getCurrentUserByToken();
|
||||
if (Objects.nonNull(user)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user