diff --git a/kernel-d-wrapper/wrapper-api/src/main/java/cn/stylefeng/roses/kernel/wrapper/api/util/MixFieldTypeUtil.java b/kernel-a-rule/src/main/java/cn/stylefeng/roses/kernel/rule/util/MixFieldTypeUtil.java similarity index 73% rename from kernel-d-wrapper/wrapper-api/src/main/java/cn/stylefeng/roses/kernel/wrapper/api/util/MixFieldTypeUtil.java rename to kernel-a-rule/src/main/java/cn/stylefeng/roses/kernel/rule/util/MixFieldTypeUtil.java index e289b0a38..39d1f3142 100644 --- a/kernel-d-wrapper/wrapper-api/src/main/java/cn/stylefeng/roses/kernel/wrapper/api/util/MixFieldTypeUtil.java +++ b/kernel-a-rule/src/main/java/cn/stylefeng/roses/kernel/rule/util/MixFieldTypeUtil.java @@ -1,7 +1,6 @@ -package cn.stylefeng.roses.kernel.wrapper.api.util; +package cn.stylefeng.roses.kernel.rule.util; import cn.hutool.core.util.ArrayUtil; -import cn.stylefeng.roses.kernel.rule.util.ObjectConvertUtil; import java.util.Collection; @@ -19,10 +18,10 @@ public class MixFieldTypeUtil { * @author fengshuonan * @date 2022/9/7 10:24 */ - public static boolean getLongFlag(Object fieldValue) { + public static boolean whetherAssignClass(Object fieldValue, Class clazz) { - // 直接判断是否是Long - if (fieldValue instanceof Long) { + // 判断value是否是指定类型 + if (clazz.isAssignableFrom(fieldValue.getClass())) { return true; } @@ -30,7 +29,7 @@ public class MixFieldTypeUtil { else if (fieldValue instanceof Collection) { Collection collectionList = (Collection) fieldValue; for (Object item : collectionList) { - if (item instanceof Long) { + if (clazz.isAssignableFrom(item.getClass())) { return true; } } @@ -40,7 +39,7 @@ public class MixFieldTypeUtil { else if (ArrayUtil.isArray(fieldValue)) { Object[] objects = ObjectConvertUtil.objToArray(fieldValue); for (Object item : objects) { - if (item instanceof Long) { + if (clazz.isAssignableFrom(item.getClass())) { return true; } } @@ -49,5 +48,4 @@ public class MixFieldTypeUtil { return false; } - } diff --git a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/format/UserFormatProcess.java b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/format/UserFormatProcess.java index 6999d1365..f8aa7dd20 100644 --- a/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/format/UserFormatProcess.java +++ b/kernel-s-system/system-business-user/src/main/java/cn/stylefeng/roses/kernel/system/modular/user/format/UserFormatProcess.java @@ -3,12 +3,12 @@ package cn.stylefeng.roses.kernel.system.modular.user.format; import cn.hutool.core.convert.Convert; import cn.hutool.extra.spring.SpringUtil; import cn.stylefeng.roses.kernel.rule.base.SimpleFieldFormatProcess; +import cn.stylefeng.roses.kernel.rule.util.MixFieldTypeUtil; import cn.stylefeng.roses.kernel.rule.util.ObjectConvertUtil; import cn.stylefeng.roses.kernel.scanner.api.enums.FieldTypeEnum; import cn.stylefeng.roses.kernel.scanner.api.util.ClassTypeUtil; import cn.stylefeng.roses.kernel.system.api.UserServiceApi; import cn.stylefeng.roses.kernel.system.api.pojo.user.SysUserDTO; -import cn.stylefeng.roses.kernel.wrapper.api.util.MixFieldTypeUtil; import java.util.ArrayList; import java.util.Collection; @@ -24,7 +24,7 @@ public class UserFormatProcess implements SimpleFieldFormatProcess { @Override public boolean canFormat(Object originValue) { - return MixFieldTypeUtil.getLongFlag(originValue); + return MixFieldTypeUtil.whetherAssignClass(originValue, Long.class); } @Override