[代码完善](dev): 修复非String类型,但是基本类型时,不触发字段转换的问题

This commit is contained in:
song_jx 2023-06-06 20:25:39 +08:00
parent 6cb15da062
commit dfe5154b06

View File

@ -96,8 +96,8 @@ public class TranslatorHandle {
final Field[] declaredFields = ReflectUtil.getFields(beanClass);
// 循环处理需要转换的字段字段上的注解链上需要有@Transform且字段类型必须为String
Arrays.stream(declaredFields)
// 只转换String类型的属性其他类型的属性代表是嵌套情况需要过滤掉后面处理
.filter(field -> field.getType() == String.class && AnnotationUtil.hasAnnotation(field, Translate.class))
// 只转换简单值类型的属性会把值转为String类型处理其他类型的属性代表是嵌套情况需要过滤掉后面处理
.filter(field -> ClassUtil.isSimpleValueType(field.getType()) && AnnotationUtil.hasAnnotation(field, Translate.class))
.forEach(field -> transformField(bean, fieldFormatType, field));
// 转换嵌套字段字段上需要标注@Transform且字段类型不为String递归转换
Arrays.stream(declaredFields)