【7.2.5】【wrapper】基础字段类型判断工具迁移到rule

pull/37/head
fengshuonan 2022-09-07 11:44:36 +08:00
parent 3cbea40d4a
commit 08b4afe1ac
2 changed files with 8 additions and 10 deletions

View File

@ -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.hutool.core.util.ArrayUtil;
import cn.stylefeng.roses.kernel.rule.util.ObjectConvertUtil;
import java.util.Collection; import java.util.Collection;
@ -19,10 +18,10 @@ public class MixFieldTypeUtil {
* @author fengshuonan * @author fengshuonan
* @date 2022/9/7 10:24 * @date 2022/9/7 10:24
*/ */
public static boolean getLongFlag(Object fieldValue) { public static boolean whetherAssignClass(Object fieldValue, Class<?> clazz) {
// 直接判断是否是Long // 判断value是否是指定类型
if (fieldValue instanceof Long) { if (clazz.isAssignableFrom(fieldValue.getClass())) {
return true; return true;
} }
@ -30,7 +29,7 @@ public class MixFieldTypeUtil {
else if (fieldValue instanceof Collection) { else if (fieldValue instanceof Collection) {
Collection<?> collectionList = (Collection<?>) fieldValue; Collection<?> collectionList = (Collection<?>) fieldValue;
for (Object item : collectionList) { for (Object item : collectionList) {
if (item instanceof Long) { if (clazz.isAssignableFrom(item.getClass())) {
return true; return true;
} }
} }
@ -40,7 +39,7 @@ public class MixFieldTypeUtil {
else if (ArrayUtil.isArray(fieldValue)) { else if (ArrayUtil.isArray(fieldValue)) {
Object[] objects = ObjectConvertUtil.objToArray(fieldValue); Object[] objects = ObjectConvertUtil.objToArray(fieldValue);
for (Object item : objects) { for (Object item : objects) {
if (item instanceof Long) { if (clazz.isAssignableFrom(item.getClass())) {
return true; return true;
} }
} }
@ -49,5 +48,4 @@ public class MixFieldTypeUtil {
return false; return false;
} }
} }

View File

@ -3,12 +3,12 @@ package cn.stylefeng.roses.kernel.system.modular.user.format;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import cn.stylefeng.roses.kernel.rule.base.SimpleFieldFormatProcess; 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.rule.util.ObjectConvertUtil;
import cn.stylefeng.roses.kernel.scanner.api.enums.FieldTypeEnum; import cn.stylefeng.roses.kernel.scanner.api.enums.FieldTypeEnum;
import cn.stylefeng.roses.kernel.scanner.api.util.ClassTypeUtil; import cn.stylefeng.roses.kernel.scanner.api.util.ClassTypeUtil;
import cn.stylefeng.roses.kernel.system.api.UserServiceApi; import cn.stylefeng.roses.kernel.system.api.UserServiceApi;
import cn.stylefeng.roses.kernel.system.api.pojo.user.SysUserDTO; 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.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -24,7 +24,7 @@ public class UserFormatProcess implements SimpleFieldFormatProcess {
@Override @Override
public boolean canFormat(Object originValue) { public boolean canFormat(Object originValue) {
return MixFieldTypeUtil.getLongFlag(originValue); return MixFieldTypeUtil.whetherAssignClass(originValue, Long.class);
} }
@Override @Override