【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.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;
}
}

View File

@ -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