From 02826bda3f00e2b4926c75f361fc00b7e7132e56 Mon Sep 17 00:00:00 2001 From: smallchill Date: Sun, 8 Dec 2019 21:57:09 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=98=BE=E7=A4=BAbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springblade/common/constant/CommonConstant.java | 10 ++++++++++ .../system/service/impl/MenuServiceImpl.java | 6 ++++-- .../system/service/impl/RoleServiceImpl.java | 6 +++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/blade-common/src/main/java/org/springblade/common/constant/CommonConstant.java b/blade-common/src/main/java/org/springblade/common/constant/CommonConstant.java index 534d5740..b27ab07c 100644 --- a/blade-common/src/main/java/org/springblade/common/constant/CommonConstant.java +++ b/blade-common/src/main/java/org/springblade/common/constant/CommonConstant.java @@ -58,5 +58,15 @@ public interface CommonConstant { */ String SORT_FIELD = "sort"; + /** + * 数据权限类型 + */ + Integer DATA_SCOPE_CATEGORY = 1; + + /** + * 接口权限类型 + */ + Integer API_SCOPE_CATEGORY = 2; + } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/MenuServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/MenuServiceImpl.java index 499d9947..99095166 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/MenuServiceImpl.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/MenuServiceImpl.java @@ -46,6 +46,8 @@ import org.springframework.stereotype.Service; import java.util.*; import java.util.stream.Collectors; +import static org.springblade.common.constant.CommonConstant.API_SCOPE_CATEGORY; +import static org.springblade.common.constant.CommonConstant.DATA_SCOPE_CATEGORY; import static org.springblade.core.cache.constant.CacheConstant.MENU_CACHE; /** @@ -139,13 +141,13 @@ public class MenuServiceImpl extends ServiceImpl implements IM @Override public List dataScopeTreeKeys(String roleIds) { - List roleScopes = roleScopeService.list(Wrappers.query().lambda().in(RoleScope::getRoleId, Func.toLongList(roleIds))); + List roleScopes = roleScopeService.list(Wrappers.query().lambda().eq(RoleScope::getScopeCategory, DATA_SCOPE_CATEGORY).in(RoleScope::getRoleId, Func.toLongList(roleIds))); return roleScopes.stream().map(roleScope -> Func.toStr(roleScope.getScopeId())).collect(Collectors.toList()); } @Override public List apiScopeTreeKeys(String roleIds) { - List roleScopes = roleScopeService.list(Wrappers.query().lambda().in(RoleScope::getRoleId, Func.toLongList(roleIds))); + List roleScopes = roleScopeService.list(Wrappers.query().lambda().eq(RoleScope::getScopeCategory, API_SCOPE_CATEGORY).in(RoleScope::getRoleId, Func.toLongList(roleIds))); return roleScopes.stream().map(roleScope -> Func.toStr(roleScope.getScopeId())).collect(Collectors.toList()); } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RoleServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RoleServiceImpl.java index de9335a9..3c1f856d 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RoleServiceImpl.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RoleServiceImpl.java @@ -43,6 +43,9 @@ import javax.validation.constraints.NotEmpty; import java.util.ArrayList; import java.util.List; +import static org.springblade.common.constant.CommonConstant.API_SCOPE_CATEGORY; +import static org.springblade.common.constant.CommonConstant.DATA_SCOPE_CATEGORY; + /** * 服务实现类 * @@ -56,9 +59,6 @@ public class RoleServiceImpl extends ServiceImpl implements IR private IRoleMenuService roleMenuService; private IRoleScopeService roleScopeService; - private static Integer DATA_SCOPE_CATEGORY = 1; - private static Integer API_SCOPE_CATEGORY = 2; - @Override public IPage selectRolePage(IPage page, RoleVO role) { return page.setRecords(baseMapper.selectRolePage(page, role));