liusuyi
2024-06-06 f37c91a84345f925e41cd26bf5d22ed1a2594bdf
ard-work/src/main/java/com/ruoyi/utils/tools/ArdTool.java
@@ -186,4 +186,29 @@
        }
    }
    /**
     *  通过反射对象填充
     * 刘苏义
     * 2024/4/2 11:50:57
     */
    public static void fillNullFields(Object source, Object target) {
        if (source == null || target == null) {
            return;
        }
        Field[] fields = source.getClass().getDeclaredFields();
        for (Field field : fields) {
            field.setAccessible(true);
            try {
                Object sourceValue = field.get(source);
                Object targetValue = field.get(target);
                if (targetValue == null && sourceValue != null) {
                    field.set(target, sourceValue);
                }
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }
}