Browse Source

修复数据权限显示bug

test
smallchill 5 years ago
parent
commit
02826bda3f
  1. 10
      blade-common/src/main/java/org/springblade/common/constant/CommonConstant.java
  2. 6
      blade-service/blade-system/src/main/java/org/springblade/system/service/impl/MenuServiceImpl.java
  3. 6
      blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RoleServiceImpl.java

10
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;
}

6
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<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());
}

6
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<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));

Loading…
Cancel
Save