From 8553552bbb03ffa297696f67eb4d22adb528eb28 Mon Sep 17 00:00:00 2001 From: RB <42044143+getrebuild@users.noreply.github.com> Date: Thu, 24 Apr 2025 20:11:57 +0800 Subject: [PATCH] hotfix: isItemHide --- .../general/ClassificationManager.java | 30 +++++++++---------- .../service/general/RecentlyUsedHelper.java | 11 +++++-- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/rebuild/core/configuration/general/ClassificationManager.java b/src/main/java/com/rebuild/core/configuration/general/ClassificationManager.java index a57a0c22e..9bc02fea2 100644 --- a/src/main/java/com/rebuild/core/configuration/general/ClassificationManager.java +++ b/src/main/java/com/rebuild/core/configuration/general/ClassificationManager.java @@ -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; } } diff --git a/src/main/java/com/rebuild/core/service/general/RecentlyUsedHelper.java b/src/main/java/com/rebuild/core/service/general/RecentlyUsedHelper.java index e33e54a25..2b1ab3632 100644 --- a/src/main/java/com/rebuild/core/service/general/RecentlyUsedHelper.java +++ b/src/main/java/com/rebuild/core/service/general/RecentlyUsedHelper.java @@ -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; + } }