Commit 8371a0d0 authored by hongguangwu's avatar hongguangwu

MVP1.7.14-优化采用用户组控制数据权限的菜单,账号若无用户组,不允许看数据。

parent 65707b1d
...@@ -36,8 +36,11 @@ public class MenuUtil { ...@@ -36,8 +36,11 @@ public class MenuUtil {
private static final String START_STR = "start"; private static final String START_STR = "start";
public void setAuthSql(YifuUser user, BaseEntity entity) { public void setAuthSql(YifuUser user, BaseEntity entity) {
// 是否无权限,默认否
boolean noAuth = false;
// 普通用户: // 普通用户:
if (user != null && Common.isNotNull(user.getId()) && CommonConstants.ONE_STRING.equals(user.getSystemFlag())) { if (user != null && Common.isNotNull(user.getId())) {
if (CommonConstants.ONE_STRING.equals(user.getSystemFlag())) {
// 菜单id // 菜单id
String menuId = entity.getMId(); String menuId = entity.getMId();
if (Common.isEmpty(menuId)) { if (Common.isEmpty(menuId)) {
...@@ -60,6 +63,11 @@ public class MenuUtil { ...@@ -60,6 +63,11 @@ public class MenuUtil {
obj = cache.get(linkId + CommonConstants.DOWN_LINE_STRING + menuId); obj = cache.get(linkId + CommonConstants.DOWN_LINE_STRING + menuId);
if (Common.isEmpty(obj)) { if (Common.isEmpty(obj)) {
linkId = user.getUserGroup(); linkId = user.getUserGroup();
// 无用户组,直接返回阻断sql
if (Common.isEmpty(linkId)) {
entity.setAuthSql( " and 1=2 ");
return;
}
linkType = 0; // 用户组 linkType = 0; // 用户组
cache = cacheManager.getCache(CacheConstants.DATA_AUTH_DETAILS + linkType); cache = cacheManager.getCache(CacheConstants.DATA_AUTH_DETAILS + linkType);
if (cache != null) { if (cache != null) {
...@@ -85,7 +93,7 @@ public class MenuUtil { ...@@ -85,7 +93,7 @@ public class MenuUtil {
if (sql.contains("#settleDomainId")) { if (sql.contains("#settleDomainId")) {
// 获取人员项目权限 // 获取人员项目权限
R<TSettleDomainListVo> res = HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl() R<TSettleDomainListVo> res = HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl()
, daprArchivesProperties.getAppId(),"/tsettledomain/getSettleDomainIdsByUserId" , daprArchivesProperties.getAppId(), "/tsettledomain/getSettleDomainIdsByUserId"
, user.getId(), TSettleDomainListVo.class, SecurityConstants.FROM_IN); , user.getId(), TSettleDomainListVo.class, SecurityConstants.FROM_IN);
StringBuilder deptStr = new StringBuilder(); StringBuilder deptStr = new StringBuilder();
if (res != null && CommonConstants.SUCCESS == res.getCode() if (res != null && CommonConstants.SUCCESS == res.getCode()
...@@ -100,9 +108,9 @@ public class MenuUtil { ...@@ -100,9 +108,9 @@ public class MenuUtil {
} }
String userIds = "0"; String userIds = "0";
if (sql.contains(START_STR)) { if (sql.contains(START_STR)) {
String deptIds = StringUtils.substringBetween(sql,START_STR, "end"); String deptIds = StringUtils.substringBetween(sql, START_STR, "end");
R<String> userIdR = HttpDaprUtil.invokeMethodPost(daprUpmsProperties.getAppUrl() R<String> userIdR = HttpDaprUtil.invokeMethodPost(daprUpmsProperties.getAppUrl()
,daprUpmsProperties.getAppId(),"/user/inner/getUserIdByDeptIds",deptIds , daprUpmsProperties.getAppId(), "/user/inner/getUserIdByDeptIds", deptIds
, String.class, SecurityConstants.FROM_IN); , String.class, SecurityConstants.FROM_IN);
if (userIdR != null && CommonConstants.SUCCESS == userIdR.getCode()) { if (userIdR != null && CommonConstants.SUCCESS == userIdR.getCode()) {
userIds = userIdR.getData(); userIds = userIdR.getData();
...@@ -112,8 +120,8 @@ public class MenuUtil { ...@@ -112,8 +120,8 @@ public class MenuUtil {
} }
if (sql.contains("#deptId")) { if (sql.contains("#deptId")) {
R<String> userIdR = HttpDaprUtil.invokeMethodPost(daprUpmsProperties.getAppUrl() R<String> userIdR = HttpDaprUtil.invokeMethodPost(daprUpmsProperties.getAppUrl()
,daprUpmsProperties.getAppId(),"/user/inner/getUserIdByDeptIds" , daprUpmsProperties.getAppId(), "/user/inner/getUserIdByDeptIds"
,String.valueOf(user.getDeptId()), String.class, SecurityConstants.FROM_IN); , String.valueOf(user.getDeptId()), String.class, SecurityConstants.FROM_IN);
if (userIdR != null && CommonConstants.SUCCESS == userIdR.getCode()) { if (userIdR != null && CommonConstants.SUCCESS == userIdR.getCode()) {
userIds = userIdR.getData(); userIds = userIdR.getData();
} }
...@@ -125,7 +133,16 @@ public class MenuUtil { ...@@ -125,7 +133,16 @@ public class MenuUtil {
} }
} }
} }
} else {
noAuth = true;
}
}
} else {
noAuth = true;
} }
// 无权限的,默认无数据
if (noAuth) {
entity.setAuthSql( " and 1=2 ");
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment