|
@@ -1,6 +1,7 @@
|
|
|
package com.platform.common.util;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.bean.copier.CopyOptions;
|
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
@@ -29,7 +30,7 @@ public final class BeanConverterUtil {
|
|
|
public static <T> T copyObjectProperties(Object source, Class<? extends T> clazz) {
|
|
|
try {
|
|
|
T t = clazz.newInstance();
|
|
|
- BeanUtil.copyProperties(source,t);
|
|
|
+ BeanUtil.copyProperties(source,t, CopyOptions.create().setIgnoreNullValue(true));
|
|
|
return t;
|
|
|
} catch (InstantiationException | IllegalAccessException e) {
|
|
|
e.printStackTrace();
|
|
@@ -46,7 +47,7 @@ public final class BeanConverterUtil {
|
|
|
*/
|
|
|
@SneakyThrows
|
|
|
public static <T> T copyObjectProperties(Object source, T t) {
|
|
|
- BeanUtil.copyProperties(source, t);
|
|
|
+ BeanUtil.copyProperties(source, t, CopyOptions.create().setIgnoreNullValue(true));
|
|
|
return t;
|
|
|
}
|
|
|
|