Browse Source

单位缓存

master
yaoq 2 years ago
parent
commit
caef46b597
1 changed files with 22 additions and 4 deletions
  1. +22
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/party/PartyCache.java

+ 22
- 4
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/party/PartyCache.java View File

@@ -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.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.Set; import java.util.Set;


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


public PartyCache() { public PartyCache() {
//缓存key:按父ID //缓存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);
} }
} }

Loading…
Cancel
Save