Kaynağa Gözat

:zap: 修复数据权限显示bug

smallchill 6 yıl önce
ebeveyn
işleme
99ab40dc62

+ 10 - 0
src/main/java/org/springblade/common/constant/CommonConstant.java

@@ -65,5 +65,15 @@ public interface CommonConstant {
 	 */
 	String SORT_FIELD = "sort";
 
+	/**
+	 * 数据权限类型
+	 */
+	Integer DATA_SCOPE_CATEGORY = 1;
+
+	/**
+	 * 接口权限类型
+	 */
+	Integer API_SCOPE_CATEGORY = 2;
+
 
 }

+ 4 - 2
src/main/java/org/springblade/modules/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;
 
 /**
@@ -149,13 +151,13 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IM
 
 	@Override
 	public List<String> dataScopeTreeKeys(String roleIds) {
-		List<RoleScope> roleScopes = roleScopeService.list(Wrappers.<RoleScope>query().lambda().in(RoleScope::getRoleId, Func.toLongList(roleIds)));
+		List<RoleScope> roleScopes = roleScopeService.list(Wrappers.<RoleScope>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<String> apiScopeTreeKeys(String roleIds) {
-		List<RoleScope> roleScopes = roleScopeService.list(Wrappers.<RoleScope>query().lambda().in(RoleScope::getRoleId, Func.toLongList(roleIds)));
+		List<RoleScope> roleScopes = roleScopeService.list(Wrappers.<RoleScope>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());
 	}
 

+ 3 - 3
src/main/java/org/springblade/modules/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<RoleMapper, Role> 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<RoleVO> selectRolePage(IPage<RoleVO> page, RoleVO role) {
 		return page.setRecords(baseMapper.selectRolePage(page, role));