diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/party/PartyCache.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/party/PartyCache.java index 6829b3c..8895a35 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/party/PartyCache.java +++ b/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 { public PartyCache() { //缓存key:按父ID - regList(mk_pr, "pt_parent_id"); + regList(mk_pr, "pt_parent_id"); } - //缓存key:按父ID - public final Set getByPr(String key) { - return getListByKey(mk_pr, key); + //获取儿子 + public final Set getChildren(Long key) { + return getListByKey(mk_pr, String.valueOf(key)); + } + + //获取顶级集合 + public final Set 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 children = getChildren(key); + return PubUtil.isEmpty(children); } }