Merge branch 'wx-dev' of https://github.com/rymcu/forest into wx-dev
This commit is contained in:
commit
02bfeefd5b
1
pom.xml
1
pom.xml
@ -294,6 +294,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>2.3.5.RELEASE</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<finalName>forest</finalName>
|
<finalName>forest</finalName>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.rymcu.forest.service.impl;
|
package com.rymcu.forest.service.impl;
|
||||||
|
|
||||||
import com.rymcu.forest.core.constant.NotificationConstant;
|
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.core.service.AbstractService;
|
||||||
import com.rymcu.forest.dto.*;
|
import com.rymcu.forest.dto.*;
|
||||||
import com.rymcu.forest.entity.Article;
|
import com.rymcu.forest.entity.Article;
|
||||||
@ -286,7 +285,7 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
throw new BaseApiException(ErrorCode.INVALID_TOKEN);
|
throw new BaseApiException(ErrorCode.INVALID_TOKEN);
|
||||||
}
|
}
|
||||||
StringBuilder shareUrl = new StringBuilder(article.getArticlePermalink());
|
StringBuilder shareUrl = new StringBuilder(article.getArticlePermalink());
|
||||||
shareUrl.append("?s=").append(user.getNickname());
|
shareUrl.append("?s=").append(user.getAccount());
|
||||||
Map map = new HashMap(1);
|
Map map = new HashMap(1);
|
||||||
map.put("shareUrl", shareUrl);
|
map.put("shareUrl", shareUrl);
|
||||||
return map;
|
return map;
|
||||||
@ -323,7 +322,7 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
Map map = new HashMap(2);
|
Map map = new HashMap(2);
|
||||||
Article article = articleMapper.selectByPrimaryKey(idArticle);
|
Article article = articleMapper.selectByPrimaryKey(idArticle);
|
||||||
if (Objects.nonNull(article)) {
|
if (Objects.nonNull(article)) {
|
||||||
if (isAuthor(article.getArticleAuthorId())) {
|
if (isAuthor(article.getArticleAuthorId()) || hasAdminPermission()) {
|
||||||
article.setArticleTags(tags);
|
article.setArticleTags(tags);
|
||||||
articleMapper.updateArticleTags(idArticle, tags);
|
articleMapper.updateArticleTags(idArticle, tags);
|
||||||
tagService.saveTagArticle(article, "");
|
tagService.saveTagArticle(article, "");
|
||||||
@ -339,6 +338,15 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
return map;
|
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 {
|
private boolean isAuthor(Integer idUser) throws BaseApiException {
|
||||||
User user = UserUtils.getCurrentUserByToken();
|
User user = UserUtils.getCurrentUserByToken();
|
||||||
if (Objects.nonNull(user)) {
|
if (Objects.nonNull(user)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user