构造函数设置默认值

   public SalaryAccountingStatementImportVO() {
        // 使用反射获取所有 BigDecimal 字段并设置为 ZERO
        for (Field field : this.getClass().getDeclaredFields()) {
            if (field.getType().equals(BigDecimal.class)) {
                try {
                    field.setAccessible(true);
                    field.set(this, BigDecimal.ZERO);
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }
    }

 

posted @ 2025-04-28 16:16  八英里  阅读(9)  评论(0)    收藏  举报