|
|
@ -7,49 +7,39 @@ import org.apache.ibatis.reflection.MetaObject;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @author woo
|
|
|
|
* MP注入处理器
|
|
|
|
* @date 2021/3/11
|
|
|
|
* @author Lion Li
|
|
|
|
|
|
|
|
* @date 2021/4/25
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
|
|
|
|
public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void insertFill(MetaObject metaObject) {
|
|
|
|
public void insertFill(MetaObject metaObject) {
|
|
|
|
//region 处理创建人信息
|
|
|
|
//根据属性名字设置要填充的值
|
|
|
|
Object createBy = this.getFieldValByName("createBy", metaObject);
|
|
|
|
if (metaObject.hasGetter("createTime")) {
|
|
|
|
Object createTime = this.getFieldValByName("createTime", metaObject);
|
|
|
|
if (metaObject.getValue("createTime") == null) {
|
|
|
|
if (createBy == null) {
|
|
|
|
this.setFieldValByName("createTime", new Date(), metaObject);
|
|
|
|
createBy = SecurityUtils.getUsername();
|
|
|
|
}
|
|
|
|
this.setFieldValByName("createBy", createBy, metaObject);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (createTime == null) {
|
|
|
|
if (metaObject.hasGetter("createBy")) {
|
|
|
|
createTime = new Date();
|
|
|
|
if (metaObject.getValue("createBy") == null) {
|
|
|
|
this.setFieldValByName("createTime", createTime, metaObject);
|
|
|
|
this.setFieldValByName("createBy", SecurityUtils.getUsername(), metaObject);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//endregion
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void updateFill(MetaObject metaObject) {
|
|
|
|
public void updateFill(MetaObject metaObject) {
|
|
|
|
//region 处理修改人信息
|
|
|
|
if (metaObject.hasGetter("updateBy")) {
|
|
|
|
Object updateBy = this.getFieldValByName("updateBy", metaObject);
|
|
|
|
if (metaObject.getValue("updateBy") == null) {
|
|
|
|
Object updateTime = this.getFieldValByName("updateTime", metaObject);
|
|
|
|
this.setFieldValByName("updateBy", SecurityUtils.getUsername(), metaObject);
|
|
|
|
if (updateBy == null) {
|
|
|
|
}
|
|
|
|
updateBy = SecurityUtils.getUsername();
|
|
|
|
|
|
|
|
this.setFieldValByName("updateBy", updateBy, metaObject);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (updateTime == null) {
|
|
|
|
if (metaObject.hasGetter("updateTime")) {
|
|
|
|
updateTime = new Date();
|
|
|
|
if (metaObject.getValue("updateTime") == null) {
|
|
|
|
this.setFieldValByName("updateTime", updateTime, metaObject);
|
|
|
|
this.setFieldValByName("updateTime", new Date(), metaObject);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//endregion
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public boolean openInsertFill() {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public boolean openUpdateFill() {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|