From caef46b597cebac06f8ba99e402b8653da0e8ae7 Mon Sep 17 00:00:00 2001 From: yaoq Date: Tue, 9 Aug 2022 15:54:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E4=BD=8D=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/bpm/web/sys/user/party/PartyCache.java | 26 ++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) 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); } }