diff --git a/policeSecurityServer/src/main/java/com/changhu/common/cache/GlobalCacheManager.java b/policeSecurityServer/src/main/java/com/changhu/common/cache/GlobalCacheManager.java index 6738b5a..7ea767c 100644 --- a/policeSecurityServer/src/main/java/com/changhu/common/cache/GlobalCacheManager.java +++ b/policeSecurityServer/src/main/java/com/changhu/common/cache/GlobalCacheManager.java @@ -36,18 +36,19 @@ public class GlobalCacheManager { static void initEnum() { log.info("初始化枚举字典数据----"); + //在包下扫描出BaseEnum的子类 Set> classes = ClassUtil.scanPackageBySuper("com.changhu.common.db.enums", BaseEnum.class); + //序列化方法 Method superSerializer = ClassUtil.getDeclaredMethod(BaseEnum.class, "serializer"); for (Class aClass : classes) { - Method childrenSerializer = ClassUtil.getDeclaredMethod(aClass, "serializer"); BaseEnum[] enumConstants = (BaseEnum[]) aClass.getEnumConstants(); if (enumConstants == null) { continue; } - // 获取所有字段 - Field[] fields = aClass.getDeclaredFields(); - // 过滤出非静态字段并带有 IsExtData 注解的字段 - List extDataFields = Arrays.stream(fields) + //子类是否重写了父类的serializer方法 + boolean isRewriteSerializer = !superSerializer.equals(ClassUtil.getDeclaredMethod(aClass, "serializer")); + // 获取所有字段并过滤出非静态字段并带有 IsExtData 注解的字段 + List extDataFields = Arrays.stream(aClass.getDeclaredFields()) .filter(field -> !Modifier.isStatic(field.getModifiers())) .filter(field -> field.getAnnotation(IsExtData.class) != null) .collect(Collectors.toList()); @@ -56,7 +57,7 @@ public class GlobalCacheManager { Stream.of(enumConstants).forEach(v -> { //如果子类重写父类的方法 则直接使用子类的结果 - if (!superSerializer.equals(childrenSerializer)) { + if (isRewriteSerializer) { map.put(v, v.serializer()); } else { SelectNodeVo vo = new SelectNodeVo<>(); diff --git a/superManagement/src/stores/modules/userStore.ts b/superManagement/src/stores/modules/userStore.ts index f52f0f5..63cb48e 100644 --- a/superManagement/src/stores/modules/userStore.ts +++ b/superManagement/src/stores/modules/userStore.ts @@ -20,7 +20,7 @@ export const useUserStore = defineStore({ getTokenInfo: (state): TokenInfo => state.tokenInfo as TokenInfo, }, persist: { - key: "useUserStore", + key: "spUserStore", storage: window.localStorage, paths: ["tokenInfo"], }