!9 修复自动填充创建人、最后修改人自动填充失效

Merge pull request !9 from 贺小五/feature/creator_updater
pull/2/head
芋道源码 2021-03-09 11:04:55 +08:00 committed by Gitee
commit 61c7687473
2 changed files with 13 additions and 0 deletions

View File

@ -1,5 +1,7 @@
package cn.iocoder.dashboard.framework.mybatis.config; package cn.iocoder.dashboard.framework.mybatis.config;
import cn.iocoder.dashboard.framework.mybatis.core.handle.DefaultDBFieldHandler;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -24,4 +26,9 @@ public class MybatisConfiguration {
return mybatisPlusInterceptor; return mybatisPlusInterceptor;
} }
@Bean
public MetaObjectHandler defaultMetaObjectHandler(){
return new DefaultDBFieldHandler(); // 自动填充参数类
}
} }

View File

@ -1,5 +1,7 @@
package cn.iocoder.dashboard.framework.mybatis.core.dataobject; package cn.iocoder.dashboard.framework.mybatis.core.dataobject;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data; import lombok.Data;
@ -15,18 +17,22 @@ public class BaseDO implements Serializable {
/** /**
* *
*/ */
@TableField(fill = FieldFill.INSERT)
private Date createTime; private Date createTime;
/** /**
* *
*/ */
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime; private Date updateTime;
/** /**
* *
*/ */
@TableField(fill = FieldFill.INSERT)
private String creator; private String creator;
/** /**
* *
*/ */
@TableField(fill = FieldFill.INSERT_UPDATE)
private String updater; private String updater;
/** /**
* *