@@ -1,7 +1,6 @@ | |||||
package cc.smtweb.system.bpm.web.design.form.define; | package cc.smtweb.system.bpm.web.design.form.define; | ||||
import cc.smtweb.framework.core.common.SwEnum; | import cc.smtweb.framework.core.common.SwEnum; | ||||
import cc.smtweb.framework.core.exception.BizException; | |||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
import cc.smtweb.framework.core.db.vo.ModelField; | import cc.smtweb.framework.core.db.vo.ModelField; | ||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
@@ -73,6 +72,15 @@ public class PageDataset { | |||||
return mapFilterId.get(id); | return mapFilterId.get(id); | ||||
} | } | ||||
public ModelTable getModelTable() { | |||||
return ModelTableCache.getInstance().get(masterTable); | |||||
} | |||||
public boolean isCurTable(String table_name) { | |||||
return table_name.equals(getModelTable().getName()); | |||||
} | |||||
/** | /** | ||||
* 重置丰富字段信息 | * 重置丰富字段信息 | ||||
*/ | */ | ||||
@@ -119,7 +127,7 @@ public class PageDataset { | |||||
filter.sqlName = filter.field; | filter.sqlName = filter.field; | ||||
} | } | ||||
} else { | } else { | ||||
calcField = calcField || ((PageDatasetField)field).fieldIsCalc(); | |||||
calcField = calcField || ((PageDatasetField) field).fieldIsCalc(); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -25,7 +25,7 @@ public class DynPageListHandler extends AbstractListHandler { | |||||
private SwMap filter; | private SwMap filter; | ||||
//对应的数据集定义 | //对应的数据集定义 | ||||
private PageDataset pageDataSet; | |||||
protected PageDataset pageDataSet; | |||||
public DynPageListHandler(long pageId, SwMap filter, PageDataset pageDataSet) { | public DynPageListHandler(long pageId, SwMap filter, PageDataset pageDataSet) { | ||||
this.pageId = pageId; | this.pageId = pageId; | ||||
@@ -4,8 +4,6 @@ import cc.smtweb.framework.core.cache.AbstractCache; | |||||
import cc.smtweb.framework.core.cache.CacheManager; | import cc.smtweb.framework.core.cache.CacheManager; | ||||
import cc.smtweb.framework.core.common.R; | import cc.smtweb.framework.core.common.R; | ||||
import cc.smtweb.framework.core.common.SwEnum; | import cc.smtweb.framework.core.common.SwEnum; | ||||
import cc.smtweb.framework.core.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.db.EntityDao; | import cc.smtweb.framework.core.db.EntityDao; | ||||
@@ -15,6 +13,7 @@ import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; | |||||
import cc.smtweb.framework.core.db.vo.ModelField; | import cc.smtweb.framework.core.db.vo.ModelField; | ||||
import cc.smtweb.framework.core.db.vo.ModelIndex; | import cc.smtweb.framework.core.db.vo.ModelIndex; | ||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import cc.smtweb.framework.core.exception.BizException; | |||||
import cc.smtweb.framework.core.mvc.service.TreeHelper; | import cc.smtweb.framework.core.mvc.service.TreeHelper; | ||||
import cc.smtweb.framework.core.util.CommUtil; | import cc.smtweb.framework.core.util.CommUtil; | ||||
import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | ||||
@@ -113,27 +112,27 @@ public class DynPageSaveHandler extends AbstractDynPageHandler { | |||||
DbEngine.getInstance().doTrans(new AbsDbWorker() { | DbEngine.getInstance().doTrans(new AbsDbWorker() { | ||||
@Override | @Override | ||||
public void work() { | public void work() { | ||||
for (DefaultEntity bean: map.values()) { | |||||
for (DefaultEntity bean : map.values()) { | |||||
saveBean(bean); | saveBean(bean); | ||||
} | } | ||||
} | } | ||||
@Override | @Override | ||||
public void doAfterDbCommit() { | public void doAfterDbCommit() { | ||||
for (DefaultEntity bean: map.values()) { | |||||
for (DefaultEntity bean : map.values()) { | |||||
afterCommit(bean); | afterCommit(bean); | ||||
} | } | ||||
} | } | ||||
@Override | @Override | ||||
public void doAfterDbRollback() { | public void doAfterDbRollback() { | ||||
for (DefaultEntity bean: map.values()) { | |||||
for (DefaultEntity bean : map.values()) { | |||||
afterRollback(bean); | afterRollback(bean); | ||||
} | } | ||||
} | } | ||||
}); | }); | ||||
Map<String, DynRetBean> mapRet = new HashMap<>(map.size()); | Map<String, DynRetBean> mapRet = new HashMap<>(map.size()); | ||||
for (Map.Entry<String, DefaultEntity> entry: map.entrySet()) { | |||||
for (Map.Entry<String, DefaultEntity> entry : map.entrySet()) { | |||||
mapRet.put(entry.getKey(), DynRetBean.createBean(entry.getValue().getData())); | mapRet.put(entry.getKey(), DynRetBean.createBean(entry.getValue().getData())); | ||||
} | } | ||||
return R.success(mapRet); | return R.success(mapRet); | ||||
@@ -1,7 +1,6 @@ | |||||
package cc.smtweb.system.bpm.web.engine.dynPage; | package cc.smtweb.system.bpm.web.engine.dynPage; | ||||
import cc.smtweb.framework.core.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | |||||
import cc.smtweb.framework.core.mvc.service.SwListData; | import cc.smtweb.framework.core.mvc.service.SwListData; | ||||
import lombok.Data; | import lombok.Data; | ||||
@@ -16,7 +15,8 @@ public class DynRetBean { | |||||
//列表返回 | //列表返回 | ||||
private SwListData list = null; | private SwListData list = null; | ||||
public static DynRetBean createBean(SwMap form) { | |||||
public static DynRetBean createBean(SwMap swMap) { | |||||
SwMap form = (SwMap) swMap.clone(); | |||||
DynRetBean bean = new DynRetBean(); | DynRetBean bean = new DynRetBean(); | ||||
bean.form = form; | bean.form = form; | ||||
bean.form.remove("_def_table_name"); | bean.form.remove("_def_table_name"); | ||||
@@ -3,10 +3,9 @@ package cc.smtweb.system.bpm.web.sys.user.role; | |||||
import cc.smtweb.framework.core.annotation.SwCache; | import cc.smtweb.framework.core.annotation.SwCache; | ||||
import cc.smtweb.framework.core.cache.AbstractEntityCache; | import cc.smtweb.framework.core.cache.AbstractEntityCache; | ||||
import cc.smtweb.framework.core.cache.CacheManager; | import cc.smtweb.framework.core.cache.CacheManager; | ||||
import cc.smtweb.framework.core.util.PubUtil; | |||||
import java.util.ArrayList; | |||||
import java.util.Comparator; | |||||
import java.util.List; | |||||
import java.util.HashSet; | |||||
import java.util.Set; | import java.util.Set; | ||||
/** | /** | ||||
@@ -31,4 +30,12 @@ public class RoleCache extends AbstractEntityCache<Role> { | |||||
public final Role getByCode(String key) { | public final Role getByCode(String key) { | ||||
return getByKey(mk_code, key); | return getByKey(mk_code, key); | ||||
} | } | ||||
public final String getNamesByIds(Set<Long> key) { | |||||
Set<String> names = new HashSet<>(); | |||||
key.forEach(k -> { | |||||
names.add(get(k).getName()); | |||||
}); | |||||
return PubUtil.getSqlInIds(names); | |||||
} | |||||
} | } |
@@ -1,91 +0,0 @@ | |||||
package cc.smtweb.system.bpm.web.sys.user.user; | |||||
import cc.smtweb.framework.core.annotation.SwTable; | |||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | |||||
/** | |||||
* Created by 1 at 2022-07-28 20:05:08 | |||||
* 实体【[角色表](SYS_ROLE)】的Entity类 | |||||
*/ | |||||
@SwTable("SYS_ROLE") | |||||
public class Role extends DefaultEntity { | |||||
public static final String ENTITY_NAME = "SYS_ROLE"; | |||||
public Role() { | |||||
super(ENTITY_NAME); | |||||
} | |||||
/** 主键 */ | |||||
public long getId() { | |||||
return getLong("srl_id"); | |||||
} | |||||
/** 主键 */ | |||||
public void setId(long srl_id) { | |||||
put("srl_id", srl_id); | |||||
} | |||||
/** 类别 */ | |||||
public long getType() { | |||||
return getLong("srl_type"); | |||||
} | |||||
/** 类别 */ | |||||
public void setType(long srl_type) { | |||||
put("srl_type", srl_type); | |||||
} | |||||
/** 编码 */ | |||||
public String getCode() { | |||||
return getStr("srl_code"); | |||||
} | |||||
/** 编码 */ | |||||
public void setCode(String srl_code) { | |||||
put("srl_code", srl_code); | |||||
} | |||||
/** 名称 */ | |||||
public String getName() { | |||||
return getStr("srl_name"); | |||||
} | |||||
/** 名称 */ | |||||
public void setName(String srl_name) { | |||||
put("srl_name", srl_name); | |||||
} | |||||
/** 备注 */ | |||||
public String getRemark() { | |||||
return getStr("srl_remark"); | |||||
} | |||||
/** 备注 */ | |||||
public void setRemark(String srl_remark) { | |||||
put("srl_remark", srl_remark); | |||||
} | |||||
/** 等级 */ | |||||
public long getLevel() { | |||||
return getLong("srl_level"); | |||||
} | |||||
/** 等级 */ | |||||
public void setLevel(long srl_level) { | |||||
put("srl_level", srl_level); | |||||
} | |||||
/** 菜单方案 */ | |||||
public long getSmpId() { | |||||
return getLong("srl_smp_id"); | |||||
} | |||||
/** 菜单方案 */ | |||||
public void setSmpId(long srl_smp_id) { | |||||
put("srl_smp_id", srl_smp_id); | |||||
} | |||||
/** 权限详细 */ | |||||
public String getPrivilege() { | |||||
return getStr("srl_privilege"); | |||||
} | |||||
/** 权限详细 */ | |||||
public void setPrivilege(String srl_privilege) { | |||||
put("srl_privilege", srl_privilege); | |||||
} | |||||
} |
@@ -1,34 +0,0 @@ | |||||
package cc.smtweb.system.bpm.web.sys.user.user; | |||||
import cc.smtweb.framework.core.annotation.SwCache; | |||||
import cc.smtweb.framework.core.cache.AbstractEntityCache; | |||||
import cc.smtweb.framework.core.cache.CacheManager; | |||||
import java.util.ArrayList; | |||||
import java.util.Comparator; | |||||
import java.util.List; | |||||
import java.util.Set; | |||||
/** | |||||
* Created by 1 at 2022-07-28 20:05:08 | |||||
* 实体【[角色表](SYS_ROLE)】的缓存类 | |||||
*/ | |||||
@SwCache(ident = "SYS_ROLE", title = "角色表") | |||||
public class RoleCache extends AbstractEntityCache<Role> { | |||||
//缓存key:按编码 | |||||
public final static String mk_code = "code"; | |||||
public static RoleCache getInstance() { | |||||
return CacheManager.getIntance().getCache(RoleCache.class); | |||||
} | |||||
public RoleCache() { | |||||
//缓存key:按编码 | |||||
regMap(mk_code, "srl_code"); | |||||
} | |||||
//缓存key:按编码 | |||||
public final Role getByCode(String key) { | |||||
return getByKey(mk_code, key); | |||||
} | |||||
} |
@@ -1,15 +1,21 @@ | |||||
package cc.smtweb.system.bpm.web.sys.user.user; | package cc.smtweb.system.bpm.web.sys.user.user; | ||||
import cc.smtweb.framework.core.common.R; | |||||
import cc.smtweb.framework.core.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.db.EntityDao; | |||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; | ||||
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; | |||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import cc.smtweb.framework.core.mvc.service.AbstractHandler; | |||||
import cc.smtweb.framework.core.util.CommUtil; | |||||
import cc.smtweb.framework.core.util.PubUtil; | import cc.smtweb.framework.core.util.PubUtil; | ||||
import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | ||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageDelHandler; | import cc.smtweb.system.bpm.web.engine.dynPage.DynPageDelHandler; | ||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageListHandler; | import cc.smtweb.system.bpm.web.engine.dynPage.DynPageListHandler; | ||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageLoadHandler; | import cc.smtweb.system.bpm.web.engine.dynPage.DynPageLoadHandler; | ||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageSaveHandler; | import cc.smtweb.system.bpm.web.engine.dynPage.DynPageSaveHandler; | ||||
import cc.smtweb.system.bpm.web.sys.user.role.RoleCache; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
@@ -21,13 +27,29 @@ import java.util.Set; | |||||
*/ | */ | ||||
public class UserHandler { | public class UserHandler { | ||||
public static EntityDao<User> getUserDao() { | |||||
return DbEngine.getInstance().findDao(User.ENTITY_NAME); | |||||
} | |||||
public static EntityDao<UserStatu> getUserStatuDao() { | |||||
return DbEngine.getInstance().findDao(UserStatu.ENTITY_NAME); | |||||
} | |||||
public static EntityDao<UserParty> getUserPartyDao() { | |||||
return DbEngine.getInstance().findDao(UserParty.ENTITY_NAME); | |||||
} | |||||
public static EntityDao<UserRole> getUserRoleDao() { | |||||
return DbEngine.getInstance().findDao(UserRole.ENTITY_NAME); | |||||
} | |||||
static class UserSaveHandler extends DynPageSaveHandler { | static class UserSaveHandler extends DynPageSaveHandler { | ||||
private UserStatu userStatu; | private UserStatu userStatu; | ||||
private List<UserRole> roleList; | private List<UserRole> roleList; | ||||
@Override | @Override | ||||
protected DefaultEntity readBeanFromPage(PageDataset pageDataSet, SwMap data) { | protected DefaultEntity readBeanFromPage(PageDataset pageDataSet, SwMap data) { | ||||
if (pageDataSet.name.equals("userPartyCard")) { | |||||
if (pageDataSet.isCurTable(UserParty.ENTITY_NAME)) { | |||||
roleList = new ArrayList<>(); | roleList = new ArrayList<>(); | ||||
Set<Long> userRoles = data.readLongSet("sup_roles"); | Set<Long> userRoles = data.readLongSet("sup_roles"); | ||||
DefaultEntity bean = super.readBeanFromPage(pageDataSet, data); | DefaultEntity bean = super.readBeanFromPage(pageDataSet, data); | ||||
@@ -42,6 +64,7 @@ public class UserHandler { | |||||
userRole.setRoleId(k); | userRole.setRoleId(k); | ||||
roleList.add(userRole); | roleList.add(userRole); | ||||
}); | }); | ||||
return bean; | |||||
} | } | ||||
return super.readBeanFromPage(pageDataSet, data); | return super.readBeanFromPage(pageDataSet, data); | ||||
} | } | ||||
@@ -55,14 +78,14 @@ public class UserHandler { | |||||
userStatu = new UserStatu(); | userStatu = new UserStatu(); | ||||
userStatu.init(); | userStatu.init(); | ||||
userStatu.setEntityId(bean.getEntityId()); | userStatu.setEntityId(bean.getEntityId()); | ||||
DbEngine.getInstance().findDao(UserStatu.ENTITY_NAME).insertEntity(userStatu); | |||||
getUserStatuDao().insertEntity(userStatu); | |||||
UserStatuCache.getInstance().put(userStatu); | UserStatuCache.getInstance().put(userStatu); | ||||
} | } | ||||
} | } | ||||
if (bean instanceof UserParty) { | if (bean instanceof UserParty) { | ||||
Set<Long> ur = UserRoleCache.getInstance().getIdByUser(((UserParty) bean).getUserId()); | |||||
DbEngine.getInstance().findDao(UserRole.ENTITY_NAME).deleteEntity(ur); | |||||
DbEngine.getInstance().findDao(UserRole.ENTITY_NAME).batchInsertEntity(roleList); | |||||
Set<Long> ur = UserRoleCache.getInstance().getByParty(bean.getEntityId()); | |||||
getUserRoleDao().deleteEntity(ur); | |||||
getUserRoleDao().batchInsertEntity(roleList); | |||||
UserRoleCache.getInstance().removeList(ur); | UserRoleCache.getInstance().removeList(ur); | ||||
UserRoleCache.getInstance().putList(roleList); | UserRoleCache.getInstance().putList(roleList); | ||||
} | } | ||||
@@ -75,13 +98,13 @@ public class UserHandler { | |||||
protected void localDel(long id, ModelTable table) { | protected void localDel(long id, ModelTable table) { | ||||
super.localDel(id, table); | super.localDel(id, table); | ||||
if (table.getName().equals(User.ENTITY_NAME)) { | if (table.getName().equals(User.ENTITY_NAME)) { | ||||
DbEngine.getInstance().findDao(UserStatu.ENTITY_NAME).deleteEntity(id); | |||||
DbEngine.getInstance().findDao(UserParty.ENTITY_NAME).deleteEntity(UserPartyCache.getInstance().getIdByUser(id)); | |||||
DbEngine.getInstance().findDao(UserRole.ENTITY_NAME).deleteEntity(UserRoleCache.getInstance().getIdByUser(id)); | |||||
getUserStatuDao().deleteEntity(id); | |||||
getUserPartyDao().deleteEntity(UserPartyCache.getInstance().getIdByUser(id)); | |||||
getUserRoleDao().deleteEntity(UserRoleCache.getInstance().getIdByUser(id)); | |||||
} | } | ||||
if (table.getName().equals(UserParty.ENTITY_NAME)) { | if (table.getName().equals(UserParty.ENTITY_NAME)) { | ||||
DbEngine.getInstance().findDao(UserParty.ENTITY_NAME).deleteEntity(id); | |||||
DbEngine.getInstance().findDao(UserRole.ENTITY_NAME).deleteEntity(UserRoleCache.getInstance().getByS(id)); | |||||
getUserPartyDao().deleteEntity(id); | |||||
getUserRoleDao().deleteEntity(UserRoleCache.getInstance().getByParty(id)); | |||||
} | } | ||||
} | } | ||||
@@ -94,7 +117,7 @@ public class UserHandler { | |||||
} | } | ||||
if (table.getName().equals(UserParty.ENTITY_NAME)) { | if (table.getName().equals(UserParty.ENTITY_NAME)) { | ||||
UserPartyCache.getInstance().remove(id); | UserPartyCache.getInstance().remove(id); | ||||
UserRoleCache.getInstance().removeList(UserRoleCache.getInstance().getByS(id)); | |||||
UserRoleCache.getInstance().removeList(UserRoleCache.getInstance().getByParty(id)); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -104,6 +127,17 @@ public class UserHandler { | |||||
public UserListHandler(long pageId, SwMap filter, PageDataset pageDataSet) { | public UserListHandler(long pageId, SwMap filter, PageDataset pageDataSet) { | ||||
super(pageId, filter, pageDataSet); | super(pageId, filter, pageDataSet); | ||||
} | } | ||||
@Override | |||||
protected void afterQuery(List<SwMap> listData) { | |||||
if (pageDataSet.isCurTable(UserParty.ENTITY_NAME)) { | |||||
listData.forEach(sw -> { | |||||
sw.put("sup_roles", RoleCache.getInstance().getNamesByIds(UserRoleCache.getInstance().getRoleByParty(sw.readLong("sup_id")))); | |||||
}); | |||||
return; | |||||
} | |||||
super.afterQuery(listData); | |||||
} | |||||
} | } | ||||
static class UserLoadHandler extends DynPageLoadHandler { | static class UserLoadHandler extends DynPageLoadHandler { | ||||
@@ -114,5 +148,60 @@ public class UserHandler { | |||||
listHandler.init(params, us); | listHandler.init(params, us); | ||||
return listHandler; | return listHandler; | ||||
} | } | ||||
@Override | |||||
protected void afterLoadBean(PageDataset dataset, SwMap bean) { | |||||
super.afterLoadBean(dataset, bean); | |||||
if (dataset.isCurTable(UserParty.ENTITY_NAME)) { | |||||
bean.put("sup_roles", CommUtil.getSqlInIds(UserRoleCache.getInstance().getRoleByParty(bean.readLong("sup_id")))); | |||||
} | |||||
} | |||||
} | |||||
static class UserCustHandler extends AbstractHandler { | |||||
public R batchDelParty() { | |||||
Set<Long> idList = params.readLongSet("ids"); | |||||
Set<Long> roleIdList = UserRoleCache.getInstance().getByParty(idList); | |||||
DbEngine.getInstance().doTrans(new AbsDbWorker() { | |||||
@Override | |||||
public void work() { | |||||
getUserPartyDao().deleteEntity(idList); | |||||
getUserRoleDao().deleteEntity(roleIdList); | |||||
} | |||||
@Override | |||||
public void doAfterDbCommit() { | |||||
UserPartyCache.getInstance().removeList(idList); | |||||
UserRoleCache.getInstance().removeList(roleIdList); | |||||
} | |||||
}); | |||||
return R.success(); | |||||
} | |||||
public R delAll() { | |||||
long id = params.readLong("id"); | |||||
Set<Long> partyIds = UserPartyCache.getInstance().getIdByUser(id); | |||||
Set<Long> roleIds = UserRoleCache.getInstance().getByParty(partyIds); | |||||
DbEngine.getInstance().doTrans(new AbsDbWorker() { | |||||
@Override | |||||
public void work() { | |||||
getUserDao().deleteEntity(id); | |||||
getUserStatuDao().deleteEntity(id); | |||||
getUserRoleDao().deleteEntity(roleIds); | |||||
getUserPartyDao().deleteEntity(partyIds); | |||||
} | |||||
@Override | |||||
public void doAfterDbCommit() { | |||||
UserCache.getInstance().remove(id); | |||||
UserStatuCache.getInstance().remove(id); | |||||
UserRoleCache.getInstance().removeList(roleIds); | |||||
UserPartyCache.getInstance().removeList(partyIds); | |||||
} | |||||
}); | |||||
return R.success(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -27,13 +27,13 @@ public class UserRoleCache extends AbstractEntityCache<UserRole> { | |||||
} | } | ||||
//缓存key:按机构关系缓存 | //缓存key:按机构关系缓存 | ||||
public final Set<UserRole> getByS(String key) { | |||||
public final Set<UserRole> getByParty(String key) { | |||||
return getListByKey(mk_s, key); | return getListByKey(mk_s, key); | ||||
} | } | ||||
public final Set<Long> getByS(Long key) { | |||||
public final Set<Long> getByParty(Long key) { | |||||
Set<Long> ids = new HashSet<>(); | Set<Long> ids = new HashSet<>(); | ||||
Set<UserRole> set = getByS(String.valueOf(key)); | |||||
Set<UserRole> set = getByParty(String.valueOf(key)); | |||||
if (PubUtil.isEmpty(set)) return ids; | if (PubUtil.isEmpty(set)) return ids; | ||||
set.forEach(bean -> { | set.forEach(bean -> { | ||||
ids.add(bean.getEntityId()); | ids.add(bean.getEntityId()); | ||||
@@ -41,20 +41,53 @@ public class UserRoleCache extends AbstractEntityCache<UserRole> { | |||||
return ids; | return ids; | ||||
} | } | ||||
public final Set<Long> getByParty(Set<Long> key) { | |||||
Set<Long> ids = new HashSet<>(); | |||||
for (Long k : key) ids.addAll(getByParty(k)); | |||||
return ids; | |||||
} | |||||
public final Set<Long> getRoleByParty(Long key) { | |||||
Set<Long> ids = new HashSet<>(); | |||||
Set<UserRole> set = getByParty(String.valueOf(key)); | |||||
if (PubUtil.isEmpty(set)) return ids; | |||||
set.forEach(bean -> { | |||||
ids.add(bean.getRoleId()); | |||||
}); | |||||
return ids; | |||||
} | |||||
public final Set<Long> getRoleByParty(Set<Long> key) { | |||||
Set<Long> ids = new HashSet<>(); | |||||
for (Long k : key) ids.addAll(getRoleByParty(k)); | |||||
return ids; | |||||
} | |||||
public final Set<Long> getRoleIdByUser(Long key) { | |||||
Set<Long> roleSet = new HashSet<>(); | |||||
Set<UserRole> userRoles = getSetByUser(String.valueOf(key)); | |||||
for (UserRole userRole : userRoles) { | |||||
roleSet.add(userRole.getRoleId()); | |||||
} | |||||
return roleSet; | |||||
} | |||||
public final Set<Long> getIdByUser(Long key) { | public final Set<Long> getIdByUser(Long key) { | ||||
return getIdByUser(String.valueOf(key)); | return getIdByUser(String.valueOf(key)); | ||||
} | } | ||||
public final Set<Long> getIdByUser(String key) { | public final Set<Long> getIdByUser(String key) { | ||||
Set<Long> roleSet = new HashSet<>(); | |||||
Set<Long> ids = new HashSet<>(); | |||||
Set<Long> upSet = UserPartyCache.getInstance().getListIdByKey(UserPartyCache.mk_u, key); | Set<Long> upSet = UserPartyCache.getInstance().getListIdByKey(UserPartyCache.mk_u, key); | ||||
if (PubUtil.isEmpty(upSet)) return roleSet; | |||||
if (PubUtil.isEmpty(upSet)) return ids; | |||||
upSet.forEach(k -> { | upSet.forEach(k -> { | ||||
Set<Long> urSet = getListIdByKey(mk_s, String.valueOf(k)); | |||||
Set<UserRole> urSet = getListByKey(mk_s, String.valueOf(k)); | |||||
if (PubUtil.isEmpty(urSet)) return; | if (PubUtil.isEmpty(urSet)) return; | ||||
roleSet.addAll(upSet); | |||||
for (UserRole userRole : urSet) { | |||||
ids.add(userRole.getEntityId()); | |||||
} | |||||
}); | }); | ||||
return roleSet; | |||||
return ids; | |||||
} | } | ||||
public final Set<UserRole> getSetByUser(String key) { | public final Set<UserRole> getSetByUser(String key) { | ||||
@@ -4,10 +4,9 @@ import cc.smtweb.framework.core.annotation.SwBody; | |||||
import cc.smtweb.framework.core.annotation.SwService; | import cc.smtweb.framework.core.annotation.SwService; | ||||
import cc.smtweb.framework.core.common.R; | import cc.smtweb.framework.core.common.R; | ||||
import cc.smtweb.framework.core.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService; | |||||
import cc.smtweb.framework.core.mvc.service.AbstractHandler; | import cc.smtweb.framework.core.mvc.service.AbstractHandler; | ||||
import cc.smtweb.framework.core.session.UserSession; | import cc.smtweb.framework.core.session.UserSession; | ||||
import cc.smtweb.system.bpm.web.sys.base.dict.DictHandler; | |||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService; | |||||
/** | /** | ||||
* Created by 1 at 2022-07-28 15:24:49 | * Created by 1 at 2022-07-28 15:24:49 | ||||
@@ -15,6 +14,7 @@ import cc.smtweb.system.bpm.web.sys.base.dict.DictHandler; | |||||
*/ | */ | ||||
@SwService | @SwService | ||||
public class UserService extends DynPageService { | public class UserService extends DynPageService { | ||||
public final static String TYPE_CUST = "cust"; | |||||
@Override | @Override | ||||
protected AbstractHandler createHandler(String type) { | protected AbstractHandler createHandler(String type) { | ||||
@@ -25,8 +25,33 @@ public class UserService extends DynPageService { | |||||
return new UserHandler.UserDelHandler(); | return new UserHandler.UserDelHandler(); | ||||
case TYPE_LOAD: | case TYPE_LOAD: | ||||
return new UserHandler.UserLoadHandler(); | return new UserHandler.UserLoadHandler(); | ||||
case TYPE_CUST: | |||||
return new UserHandler.UserCustHandler(); | |||||
} | } | ||||
return super.createHandler(type); | return super.createHandler(type); | ||||
} | } | ||||
/** | |||||
* @Author yaoq | |||||
* @Date 2022/7/21 15:50 | |||||
* @Params | |||||
* @Return cc.smtweb.framework.core.common.R | |||||
* @Description 明细批量新增 | |||||
*/ | |||||
public R batchDelParty(@SwBody SwMap params, UserSession us) { | |||||
return pageHandler(params, us, TYPE_CUST, handler -> ((UserHandler.UserCustHandler) handler).batchDelParty()); | |||||
} | |||||
/** | |||||
* @Author yaoq | |||||
* @Date 2022/7/21 15:50 | |||||
* @Params | |||||
* @Return cc.smtweb.framework.core.common.R | |||||
* @Description 删除全部 | |||||
*/ | |||||
public R delAll(@SwBody SwMap params, UserSession us) { | |||||
return pageHandler(params, us, TYPE_CUST, handler -> ((UserHandler.UserCustHandler) handler).delAll()); | |||||
} | |||||
} | } |
@@ -1,18 +1,28 @@ | |||||
/** | /** | ||||
* Created by 1 at 2022-07-28 15:24:52 | * Created by 1 at 2022-07-28 15:24:52 | ||||
* 注册事件类【用户列表】,参看event.defaultEvent.js | * 注册事件类【用户列表】,参看event.defaultEvent.js | ||||
*/ | |||||
*/ | |||||
window.$swEvent.setup("bpm.sys.user.user.userList", { | window.$swEvent.setup("bpm.sys.user.user.userList", { | ||||
setup(page){ | |||||
const { $params,$refs, $widgets, $model, $utils, $tabRouter, $api } = page || {}; | |||||
const { $$message, $$http } = $utils || {}; | |||||
setup(page) { | |||||
const {$params, $refs, $widgets, $model, $utils, $tabRouter, $api} = page || {}; | |||||
const {$$message, $$http} = $utils || {}; | |||||
// 示例 | |||||
const demoFunc = () => { | |||||
// | |||||
const batchDelParty = () => { | |||||
const data = $refs.tbparty.getSelectIds(); | |||||
if (data.length == 0) { | |||||
$$message.notify.warning("请选择要删除的记录!"); | |||||
return; | |||||
} | |||||
$$http.post("bpm/user/batchDelParty", {ids: data.join(",")}).then((rt) => { | |||||
// 8.弹出成功消息 | |||||
$$message.notify.success("操作成功"); | |||||
page.$api.loadOne("userPartyList"); | |||||
}); | |||||
}; | |||||
}; | |||||
return { | |||||
demoFunc, | |||||
return { | |||||
batchDelParty, | |||||
} | |||||
} | } | ||||
} | |||||
}); | }); |
@@ -6,10 +6,12 @@ | |||||
"colNum": 3, | "colNum": 3, | ||||
"name": "query", | "name": "query", | ||||
"label": "按钮区", | "label": "按钮区", | ||||
"size": "80", | |||||
"size": "50", | |||||
"shadow": "", | "shadow": "", | ||||
"alignY": "center", | "alignY": "center", | ||||
"paddingRight": 10 | |||||
"paddingRight": 20, | |||||
"gridTemplateColumns": "400px 400px 1fr", | |||||
"paddingLeft": 20 | |||||
}, | }, | ||||
"children": [ | "children": [ | ||||
<#assign fields = group.cfilters> | <#assign fields = group.cfilters> | ||||
@@ -23,7 +25,8 @@ | |||||
<#if filter.maxlength gt 0> | <#if filter.maxlength gt 0> | ||||
"maxlength": ${filter.maxlength}, | "maxlength": ${filter.maxlength}, | ||||
</#if> | </#if> | ||||
"placeholder": "请输入查询内容", | |||||
"placeholder": "请输入${filter.label}", | |||||
"hideLabel": true, | |||||
"labelWidth": 100, | "labelWidth": 100, | ||||
"affixError": false, | "affixError": false, | ||||
"dataset": "${filter.dataset}", | "dataset": "${filter.dataset}", | ||||
@@ -88,12 +91,21 @@ | |||||
}] | }] | ||||
}, | }, | ||||
{ | { | ||||
"id": "${newId()}", | |||||
"type": "fx-form-panel", | |||||
"shape": "panel", | |||||
"props": { | |||||
"size": "20", | |||||
"backgroundColor": "transparent" | |||||
}, | |||||
"children": [] | |||||
}, | |||||
"id": "id${newId()}", | |||||
"type": "fx-form-panel", | |||||
"shape": "panel", | |||||
"props": { | |||||
"size": "0" | |||||
}, | |||||
"children": [ | |||||
{ | |||||
"id": "id${newId()}", | |||||
"type": "fx-divider", | |||||
"props": { | |||||
"label": "", | |||||
"contentPosition": "center", | |||||
"direction": "horizontal" | |||||
} | |||||
} | |||||
] | |||||
}, |
@@ -7,8 +7,8 @@ | |||||
"size": "", | "size": "", | ||||
"label": "列表", | "label": "列表", | ||||
"colNum": 0, | "colNum": 0, | ||||
"paddingLeft": 32, | |||||
"paddingRight": 32, | |||||
"paddingLeft": 20, | |||||
"paddingRight": 20, | |||||
"shadow": "" | "shadow": "" | ||||
}, | }, | ||||
"children": [{ | "children": [{ | ||||
@@ -22,7 +22,7 @@ | |||||
"showHeader": true, | "showHeader": true, | ||||
"fit": true, | "fit": true, | ||||
"dataset": "${param.queryDs}", | "dataset": "${param.queryDs}", | ||||
"actionWidth": 150 | |||||
"actionWidth": 120 | |||||
}, | }, | ||||
"slots": { | "slots": { | ||||
<#if (group.fields?size>0)> | <#if (group.fields?size>0)> | ||||
@@ -95,4 +95,4 @@ | |||||
"events": {} | "events": {} | ||||
} | } | ||||
] | ] | ||||
}, | |||||
}, |
@@ -28,14 +28,13 @@ | |||||
"type": "fx-form-panel", | "type": "fx-form-panel", | ||||
"shape": "panel", | "shape": "panel", | ||||
"props": { | "props": { | ||||
"size": "68", | |||||
"size": "50", | |||||
"label": "查询条件", | "label": "查询条件", | ||||
"colNum": 2, | "colNum": 2, | ||||
"alignY": "center", | "alignY": "center", | ||||
"paddingLeft": 32, | |||||
"paddingRight": 32, | |||||
"shadow": "", | |||||
"backgroundImage":"bgImg-region-title" | |||||
"paddingLeft": 20, | |||||
"paddingRight": 20, | |||||
"shadow": "" | |||||
}, | }, | ||||
"children": [ | "children": [ | ||||
{ | { | ||||
@@ -43,12 +42,12 @@ | |||||
"type": "fx-title", | "type": "fx-title", | ||||
"props": { | "props": { | ||||
"label": "${title}", | "label": "${title}", | ||||
"fontSize": 16, | |||||
"color": "#01070D", | |||||
"fontSize": 15, | |||||
"color": "#313131", | |||||
"fontWeight": "bold", | "fontWeight": "bold", | ||||
"showPrefix": false, | |||||
"showPrefix": true, | |||||
"prefixWidth": 5, | "prefixWidth": 5, | ||||
"prefixHeight": 24, | |||||
"prefixHeight": 15, | |||||
"prefixColor": "#1E90FF" | "prefixColor": "#1E90FF" | ||||
} | } | ||||
}, | }, | ||||
@@ -28,14 +28,13 @@ | |||||
"type": "fx-form-panel", | "type": "fx-form-panel", | ||||
"shape": "panel", | "shape": "panel", | ||||
"props": { | "props": { | ||||
"size": "68", | |||||
"size": "50", | |||||
"label": "查询条件", | "label": "查询条件", | ||||
"colNum": 2, | "colNum": 2, | ||||
"alignY": "center", | "alignY": "center", | ||||
"paddingLeft": 32, | |||||
"paddingRight": 32, | |||||
"shadow": "", | |||||
"backgroundImage":"bgImg-region-title" | |||||
"paddingLeft": 20, | |||||
"paddingRight": 20, | |||||
"shadow": "" | |||||
}, | }, | ||||
"children": [ | "children": [ | ||||
{ | { | ||||
@@ -43,12 +42,12 @@ | |||||
"type": "fx-title", | "type": "fx-title", | ||||
"props": { | "props": { | ||||
"label": "${title}", | "label": "${title}", | ||||
"fontSize": 16, | |||||
"color": "#01070D", | |||||
"fontSize": 15, | |||||
"color": "#313131", | |||||
"fontWeight": "bold", | "fontWeight": "bold", | ||||
"showPrefix": false, | |||||
"showPrefix": true, | |||||
"prefixWidth": 5, | "prefixWidth": 5, | ||||
"prefixHeight": 24, | |||||
"prefixHeight": 15, | |||||
"prefixColor": "#1E90FF" | "prefixColor": "#1E90FF" | ||||
} | } | ||||
}, | }, | ||||
@@ -115,7 +114,14 @@ | |||||
<#else> | <#else> | ||||
"title": "${param.editTitle}", | "title": "${param.editTitle}", | ||||
</#if> | </#if> | ||||
"key": "editDialog" | |||||
"key": "editDialog", | |||||
"fontSize": 16, | |||||
"color": "#313131", | |||||
"fontWeight": "bold", | |||||
"showPrefix": true, | |||||
"prefixWidth": 5, | |||||
"prefixHeight": 16, | |||||
"prefixColor": "#1E90FF" | |||||
}, | }, | ||||
"events": {} | "events": {} | ||||
}, | }, | ||||
@@ -143,7 +149,7 @@ | |||||
"shape": "panel", | "shape": "panel", | ||||
"props": { | "props": { | ||||
"size": "0", | "size": "0", | ||||
"paddingTop": 32, | |||||
"paddingTop": 15, | |||||
"colNum": 2 | "colNum": 2 | ||||
}, | }, | ||||
<#assign dfields = dialog.fields> | <#assign dfields = dialog.fields> | ||||
@@ -243,9 +249,9 @@ | |||||
"type": "fx-form-panel", | "type": "fx-form-panel", | ||||
"shape": "panel", | "shape": "panel", | ||||
"props": { | "props": { | ||||
"size": "56", | |||||
"size": "50", | |||||
"alignY": "center", | "alignY": "center", | ||||
"paddingRight": 10 | |||||
"paddingRight": 20 | |||||
}, | }, | ||||
"children": [ | "children": [ | ||||
{ | { | ||||