Kaynağa Gözat

修改属性值填充处理器

tags/24080901
WendyYang 8 ay önce
ebeveyn
işleme
62e0ed647d
1 değiştirilmiş dosya ile 19 ekleme ve 7 silme
  1. +19
    -7
      hz-pm-api/src/main/java/com/hz/pm/api/common/handler/BaseFieldFillHandler.java

+ 19
- 7
hz-pm-api/src/main/java/com/hz/pm/api/common/handler/BaseFieldFillHandler.java Dosyayı Görüntüle

@@ -31,18 +31,30 @@ public class BaseFieldFillHandler implements MetaObjectHandler {

@Override
public void insertFill(MetaObject metaObject) {
long userId = getUserId();
fillVal(CREATE_BY, metaObject, getUserId());
fillVal(UPDATE_BY, metaObject, getUserId());
LocalDateTime now = LocalDateTime.now();
this.fillStrategy(metaObject, CREATE_BY, userId);
this.fillStrategy(metaObject, CREATE_ON, now);
this.fillStrategy(metaObject, UPDATE_BY, userId);
this.fillStrategy(metaObject, UPDATE_ON, now);
fillVal(CREATE_ON, metaObject, now);
fillVal(UPDATE_ON, metaObject, now);
}

@Override
public void updateFill(MetaObject metaObject) {
this.fillStrategy(metaObject, UPDATE_BY, getUserId());
this.fillStrategy(metaObject, UPDATE_ON, LocalDateTime.now());
fillVal(UPDATE_BY, metaObject, getUserId());
fillVal(UPDATE_ON, metaObject, LocalDateTime.now());
}

private void fillVal(String fieldName, MetaObject metaObject, Object val) {
if (metaObject.hasSetter(fieldName)) {
Class<?> setterType = metaObject.getSetterType(fieldName);
if (setterType != null) {
if (setterType.equals(String.class)) {
this.fillStrategy(metaObject, fieldName, val.toString());
} else {
this.fillStrategy(metaObject, fieldName, val);
}
}
}
}

}

Yükleniyor…
İptal
Kaydet