From e7e672a7b75cab23f491bd7f28bc3f12c304032a Mon Sep 17 00:00:00 2001 From: ronger Date: Tue, 4 Jan 2022 10:32:56 +0800 Subject: [PATCH 1/3] =?UTF-8?q?:poop:=20=E4=BF=AE=E6=94=B9=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E6=A0=87=E7=AD=BE=E8=BF=9B=E8=A1=8C=E9=89=B4=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../forest/service/impl/ArticleServiceImpl.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 be8d1aa..3652be2 100644 --- a/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java @@ -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
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
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)) { From d7923abfd7ce879a1efb466bf31718562d2c8d54 Mon Sep 17 00:00:00 2001 From: ronger Date: Tue, 4 Jan 2022 10:33:54 +0800 Subject: [PATCH 2/3] :art: update pom.xml --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index d153741..2d6927e 100644 --- a/pom.xml +++ b/pom.xml @@ -294,6 +294,7 @@ org.springframework.boot spring-boot-maven-plugin + 2.3.5.RELEASE forest From d84133c47a0c7512bb258e75f46281f61141d01a Mon Sep 17 00:00:00 2001 From: ronger Date: Tue, 4 Jan 2022 10:39:03 +0800 Subject: [PATCH 3/3] =?UTF-8?q?:art:=20=E6=96=87=E7=AB=A0=E5=88=86?= =?UTF-8?q?=E4=BA=AB=E6=8E=A5=E5=8F=A3=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/rymcu/forest/service/impl/ArticleServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 3652be2..be9d57b 100644 --- a/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java @@ -285,7 +285,7 @@ public class ArticleServiceImpl extends AbstractService
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;