Переглянути джерело

Merge remote-tracking branch 'origin/master'

master
FLYPHT 2 роки тому
джерело
коміт
639a0dd415
4 змінених файлів з 68 додано та 30 видалено
  1. +22
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/party/PartyCache.java
  2. +36
    -19
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/role/RoleHandler.java
  3. +9
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/role/RoleRightContent.java
  4. +1
    -7
      smtweb-framework/bpm/src/main/resources/static/event/bpm/sys/user/role/roleRight.js

+ 22
- 4
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/party/PartyCache.java Переглянути файл

@@ -3,6 +3,7 @@ package cc.smtweb.system.bpm.web.sys.user.party;
import cc.smtweb.framework.core.annotation.SwCache;
import cc.smtweb.framework.core.cache.AbstractEntityCache;
import cc.smtweb.framework.core.cache.CacheManager;
import cc.smtweb.framework.core.util.PubUtil;

import java.util.Set;

@@ -23,11 +24,28 @@ public class PartyCache extends AbstractEntityCache<Party> {

public PartyCache() {
//缓存key:按父ID
regList(mk_pr, "pt_parent_id");
regList(mk_pr, "pt_parent_id");
}

//缓存key:按父ID
public final Set<Party> getByPr(String key) {
return getListByKey(mk_pr, key);
//获取儿子
public final Set<Party> getChildren(Long key) {
return getListByKey(mk_pr, String.valueOf(key));
}

//获取顶级集合
public final Set<Party> getTopSet() {
return getChildren(-1L);
}

//是否顶级
public final boolean isTop(Long key) {
Party party = get(key);
return party != null && party.getParentId() <= 0;
}

//是否末级
public final boolean isLeaf(Long key) {
Set<Party> children = getChildren(key);
return PubUtil.isEmpty(children);
}
}

+ 36
- 19
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/role/RoleHandler.java Переглянути файл

@@ -22,6 +22,7 @@ import cc.smtweb.system.bpm.web.sys.user.menuPlan.MenuPlanItem;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
* @Author: tanghp
@@ -52,26 +53,38 @@ public class RoleHandler {
if (pageDataSet.name.equals(RIGHT_DATA)) {
long role_id = filter.readLong("role_id");
long mp_id = filter.readLong("mp_id");
if (role_id <= 0 || mp_id <= 0) return R.error("未指定角色或菜单!");
if (role_id <= 0) return R.error("未指定角色!");
SwMap formData = data.readMap("form");

Set<Long> set = formData.readLongSet("menu");
if (PubUtil.isEmpty(set)) return R.error("未选择菜单!");
Role role = RoleCache.getInstance().get(role_id);
MenuPlanItem item = MenuPlanCache.getInstance().getById(role.getSmpId(), mp_id);
RoleRightContent rc = new RoleRightContent(role.getPrivilege());
RoleRight right = rc.getRoleRight(item.getId());
if (right == null) {
right = new RoleRight();
right.setId(item.getId());
right.setMenuId(item.getMenu());
right.setMenu(1);
for (Long menu_id : set) {
MenuPlanItem item = MenuPlanCache.getInstance().getById(role.getSmpId(), menu_id);
RoleRight right = rc.getRoleRight(item.getId());
if (right == null) {
right = new RoleRight();
right.setId(item.getId());
right.setMenuId(item.getMenu());
right.setMenu(1);
}
rc.saveItem(right);
}
if (mp_id > 0) {
MenuPlanItem item = MenuPlanCache.getInstance().getById(role.getSmpId(), mp_id);
RoleRight right = rc.getRoleRight(item.getId());
if (right == null) {
right = new RoleRight();
right.setId(item.getId());
right.setMenuId(item.getMenu());
right.setMenu(1);
}
right.setFunc(formData.readStringSet("func"));
right.setData(formData.readListMap("data"));
right.setField(MenuCache.getInstance().get(item.getMenu()).getRightSet(SwEnum.MenuRightType.FIELD.value), formData.readStringSet("write"), formData.readStringSet("read"));
rc.saveItem(right);
}
right.setFunc(formData.readStringSet("func"));
right.setData(formData.readListMap("data"));
right.setField(MenuCache.getInstance().get(item.getMenu()).getRightSet(SwEnum.MenuRightType.FIELD.value), formData.readStringSet("write"), formData.readStringSet("read"));

rc.saveItem(right);
role.setPrivilege(rc.toContentStr());

DbEngine.getInstance().findDao(Role.ENTITY_NAME).updateEntity(role);
RoleCache.getInstance().put(role);
return R.success(DynRetBean.createBean(formData));
@@ -107,14 +120,18 @@ public class RoleHandler {
@Override
public SwMap loadData(SwMap filter, PageDataset pageDataSet) {
if (pageDataSet.name.equals(RIGHT_DATA)) {
SwMap bean = new SwMap();
long role_id = filter.readLong("role_id");
long mp_id = filter.readLong("mp_id");
if (role_id <= 0 || mp_id <= 0) return new SwMap();
if (role_id <= 0) return bean;
Role role = RoleCache.getInstance().get(role_id);
MenuPlanItem item = MenuPlanCache.getInstance().getById(role.getSmpId(), mp_id);
if (item == null) return new SwMap();
RoleRightContent rc = new RoleRightContent(role.getPrivilege());
SwMap bean = new SwMap();
if (mp_id <= 0) {
bean.put("menu", rc.getMenuRight());
return bean;
}
MenuPlanItem item = MenuPlanCache.getInstance().getById(role.getSmpId(), mp_id);
if (item == null) return bean;
bean.put("func", rc.getFuncRight(item.getId()));
bean.put("read", rc.getFieldRight(item.getId(), 1));
bean.put("write", rc.getFieldRight(item.getId(), 2));


+ 9
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/role/RoleRightContent.java Переглянути файл

@@ -57,6 +57,15 @@ public class RoleRightContent {
return PubUtil.getSqlInIds(right.getRightFunc());
}

public String getMenuRight() {
if (map.size() == 0) return "";
Set<String> menus = new HashSet<>();
map.values().forEach(roleRight -> {
if (roleRight.getMenu() == 1) menus.add(roleRight.getId() + "");
});
return PubUtil.getSqlInIds(menus);
}

public String getFieldRight(long key, int type) {
RoleRight right = getRoleRight(key);
if (right == null) return "";


+ 1
- 7
smtweb-framework/bpm/src/main/resources/static/event/bpm/sys/user/role/roleRight.js Переглянути файл

@@ -11,15 +11,9 @@ window.$swEvent.setup("bpm.sys.user.role.roleRight", {
const onBeforeSave = () => {
$model.rightData.setFormVal("data", $model.roleDataList.data.list.rows);
};
const onRoleSelect = (row) => {
if (this.temp_mp_id !== row["srl_id"]) {
$model.menuData.setFormVal("mp_id", "");
}
this.temp_mp_id = row["srl_id"];
}

return {
onBeforeSave,
onRoleSelect,
}
}
});

Завантаження…
Відмінити
Зберегти