Browse Source

数据权限

4.0
yaoq 2 years ago
parent
commit
c0928eaf33
2 changed files with 13 additions and 10 deletions
  1. +5
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/role/RoleHandler.java
  2. +8
    -6
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/role/RoleRightContent.java

+ 5
- 4
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/role/RoleHandler.java View File

@@ -237,16 +237,17 @@ public class RoleHandler {
Menu menu = MenuCache.getInstance().get(item.getMenu());
if (menu == null) return SwListData.create(list, 0);
RoleRightContent rc = new RoleRightContent(role.getPrivilege());
Map<String, Object> data = rc.getDataRight(item.getId());
Map<String,Map<String, Object>> data = rc.getDataRight(item.getId());

for (String f : menu.getRightSet(BpmEnum.MenuRightType.DATA.value)) {
if (StringUtil.isEmpty(f)) continue;
SwMap row = new SwMap();
row.put("key", f);
row.put("key_text", DataRightDefineCache.getInstance().get(f).getName());
if (data.containsKey("value")) {
row.put("value", data.get("value"));
row.put("value_text", DataRightGroupCache.getInstance().get(data.get("value").toString()).getName());
if (data.containsKey(f)) {
Map<String,Object> right = data.get(f);
row.put("value", right.get("value"));
row.put("value_text", DataRightGroupCache.getInstance().get(right.get("value").toString()).getName());
}
list.add(row);
}


+ 8
- 6
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/role/RoleRightContent.java View File

@@ -61,7 +61,7 @@ public class RoleRightContent {
public String getFuncRight(long key) {
RoleRight right = getRoleRight(key);
if (right == null) return "";
return StringUtil.join(right.getRightFunc(),",");
return StringUtil.join(right.getRightFunc(), ",");
}

public String getMenuRight() {
@@ -70,8 +70,9 @@ public class RoleRightContent {
map.values().forEach(roleRight -> {
if (roleRight.getMenu() == 1) menus.add(roleRight.getId() + "");
});
return StringUtil.join(menus,",");
return StringUtil.join(menus, ",");
}

public Set<Long> getMenuRightIds() {
Set<Long> ids = new HashSet<>();
if (map.size() == 0) return ids;
@@ -80,6 +81,7 @@ public class RoleRightContent {
});
return ids;
}

public String getFieldRight(long key, int type) {
RoleRight right = getRoleRight(key);
if (right == null) return "";
@@ -89,17 +91,17 @@ public class RoleRightContent {
cache.forEach((k, v) -> {
if (v == type) fields.add(k);
});
return StringUtil.join(fields,",");
return StringUtil.join(fields, ",");
}

public Map<String, Object> getDataRight(long key) {
public Map<String, Map<String, Object>> getDataRight(long key) {
RoleRight right = getRoleRight(key);
if (right == null) return new HashMap<>();
List<Map<String, Object>> list = right.getRightData();
if (list == null || list.size() == 0) return new HashMap<>();
Map<String, Object> cache = new HashMap<>();
Map<String, Map<String, Object>> cache = new HashMap<>();
list.forEach(k -> {
cache.putAll(k);
cache.put(k.get("key").toString(), k);
});
return cache;
}


Loading…
Cancel
Save