mirror of
https://github.com/getrebuild/rebuild.git
synced 2025-09-07 15:15:47 +08:00
hotfix: isItemHide
This commit is contained in:
parent
f49dc27c89
commit
8553552bbb
2 changed files with 24 additions and 17 deletions
|
@ -63,19 +63,20 @@ public class ClassificationManager implements ConfigManager {
|
|||
* @return
|
||||
*/
|
||||
public Item getItem(ID itemId) {
|
||||
final String ckey = "ClassificationITEM40-" + itemId;
|
||||
final String ckey = "ClassificationITEM403-" + itemId;
|
||||
Item ditem = (Item) Application.getCommonsCache().getx(ckey);
|
||||
if (ditem != null) {
|
||||
return DELETED_ITEM.equals(ditem.Name) ? null : ditem;
|
||||
}
|
||||
if (ditem != null) return DELETED_ITEM.equals(ditem.Name) ? null : ditem;
|
||||
|
||||
Object[] o = Application.createQueryNoFilter(
|
||||
"select name,fullName,code,color,isHide from ClassificationData where itemId = ?")
|
||||
"select name,fullName,code,color,isHide,parent from ClassificationData where itemId = ?")
|
||||
.setParameter(1, itemId)
|
||||
.unique();
|
||||
if (o != null) ditem = new Item((String) o[0], (String) o[1], (String) o[2], (String) o[3], ObjectUtils.toBool(o[4]));
|
||||
if (o != null) {
|
||||
ditem = new Item((String) o[0], (String) o[1], (String) o[2], (String) o[3],
|
||||
ObjectUtils.toBool(o[4]), (ID) o[5]);
|
||||
}
|
||||
// 可能已删除
|
||||
if (ditem == null) ditem = new Item(DELETED_ITEM, null, null, null, true);
|
||||
if (ditem == null) ditem = new Item(DELETED_ITEM, null, null, null, true, null);
|
||||
|
||||
Application.getCommonsCache().putx(ckey, ditem);
|
||||
return DELETED_ITEM.equals(ditem.Name) ? null : ditem;
|
||||
|
@ -102,12 +103,9 @@ public class ClassificationManager implements ConfigManager {
|
|||
.setParameter(2, openLevel)
|
||||
.array();
|
||||
|
||||
if (found.length == 0) {
|
||||
return null;
|
||||
} else {
|
||||
// TODO 找到多个匹配的优选
|
||||
return (ID) found[0][0];
|
||||
}
|
||||
if (found.length == 0) return null;
|
||||
// 找到多个匹配的优选
|
||||
return (ID) found[0][0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -163,7 +161,7 @@ public class ClassificationManager implements ConfigManager {
|
|||
public void clean(Object cid) {
|
||||
ID id2 = (ID) cid;
|
||||
if (id2.getEntityCode() == EntityHelper.ClassificationData) {
|
||||
Application.getCommonsCache().evict("ClassificationITEM38-" + cid);
|
||||
Application.getCommonsCache().evict("ClassificationITEM403-" + cid);
|
||||
} else if (id2.getEntityCode() == EntityHelper.Classification) {
|
||||
Application.getCommonsCache().evict("ClassificationLEVEL-" + cid);
|
||||
}
|
||||
|
@ -173,12 +171,13 @@ public class ClassificationManager implements ConfigManager {
|
|||
@Getter
|
||||
public static class Item implements Serializable {
|
||||
private static final long serialVersionUID = -1903227875771376652L;
|
||||
Item(String name, String fullName, String code, String color, boolean isHide) {
|
||||
Item(String name, String fullName, String code, String color, boolean isHide, ID parent) {
|
||||
this.Name = name;
|
||||
this.FullName = fullName;
|
||||
this.Code = code;
|
||||
this.Color = color;
|
||||
this.Hide = isHide;
|
||||
this.Parent = parent;
|
||||
}
|
||||
|
||||
final String Name;
|
||||
|
@ -186,5 +185,6 @@ public class ClassificationManager implements ConfigManager {
|
|||
final String Code;
|
||||
final String Color;
|
||||
final boolean Hide;
|
||||
final ID Parent;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,10 +93,10 @@ public class RecentlyUsedHelper {
|
|||
if (checkFilter != null) {
|
||||
if (!QueryHelper.isMatchFilter(raw, checkFilter)) continue;
|
||||
}
|
||||
// fix:4.0.2
|
||||
// fix:4.0.3
|
||||
if (entityCode == EntityHelper.ClassificationData) {
|
||||
ClassificationManager.Item item = ClassificationManager.instance.getItem(raw);
|
||||
if (item == null || item.isHide()) continue;
|
||||
if (item == null || isItemHide(item)) continue;
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -165,4 +165,11 @@ public class RecentlyUsedHelper {
|
|||
private static String formatKey(ID user, String entity, String type) {
|
||||
return String.format("RS31.%s-%s-%s", user, entity, StringUtils.defaultIfBlank(type, StringUtils.EMPTY));
|
||||
}
|
||||
|
||||
// 分类项是否已禁用(含父级)
|
||||
private static boolean isItemHide(ClassificationManager.Item item) {
|
||||
if (item == null || item.isHide()) return true;
|
||||
if (item.getParent() != null) return isItemHide(ClassificationManager.instance.getItem(item.getParent()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue