Merge branch 'wx-dev' of https://github.com/rymcu/forest into wx-dev

This commit is contained in:
ronger 2022-01-04 22:51:54 +08:00
commit 02bfeefd5b
2 changed files with 12 additions and 3 deletions

View File

@ -294,6 +294,7 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.5.RELEASE</version>
</plugin>
</plugins>
<finalName>forest</finalName>

View File

@ -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;
@ -286,7 +285,7 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
throw new BaseApiException(ErrorCode.INVALID_TOKEN);
}
StringBuilder shareUrl = new StringBuilder(article.getArticlePermalink());
shareUrl.append("?s=").append(user.getNickname());
shareUrl.append("?s=").append(user.getAccount());
Map map = new HashMap(1);
map.put("shareUrl", shareUrl);
return map;
@ -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)) {