From 56b5f12b8642d8a9349ca06dc72e63189bac84be Mon Sep 17 00:00:00 2001 From: hexiaowu Date: Tue, 9 Mar 2021 00:51:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8D=95=E5=85=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=97=A0=E6=B3=95=E8=8E=B7=E5=8F=96=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=A1=AB=E5=85=85=E5=8F=82=E6=95=B0=20DefaultDBFieldHandler=20?= =?UTF-8?q?=E7=B1=BB=20BaseDO=E6=96=B0=E5=A2=9ETableField=E6=B3=A8?= =?UTF-8?q?=E8=A7=A3=EF=BC=8C=E7=94=A8=E4=BA=8E=E8=87=AA=E5=8A=A8=E5=A1=AB?= =?UTF-8?q?=E5=85=85=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/mybatis/config/MybatisConfiguration.java | 7 +++++++ .../framework/mybatis/core/dataobject/BaseDO.java | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/main/java/cn/iocoder/dashboard/framework/mybatis/config/MybatisConfiguration.java b/src/main/java/cn/iocoder/dashboard/framework/mybatis/config/MybatisConfiguration.java index a955c402e..4d4f0d681 100644 --- a/src/main/java/cn/iocoder/dashboard/framework/mybatis/config/MybatisConfiguration.java +++ b/src/main/java/cn/iocoder/dashboard/framework/mybatis/config/MybatisConfiguration.java @@ -1,5 +1,7 @@ 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.inner.PaginationInnerInterceptor; import org.apache.ibatis.annotations.Mapper; @@ -23,4 +25,9 @@ public class MybatisConfiguration { return mybatisPlusInterceptor; } + @Bean + public MetaObjectHandler defaultMetaObjectHandler(){ + return new DefaultDBFieldHandler(); // 自动填充参数类 + } + } diff --git a/src/main/java/cn/iocoder/dashboard/framework/mybatis/core/dataobject/BaseDO.java b/src/main/java/cn/iocoder/dashboard/framework/mybatis/core/dataobject/BaseDO.java index df9ddb22e..ca359dc83 100644 --- a/src/main/java/cn/iocoder/dashboard/framework/mybatis/core/dataobject/BaseDO.java +++ b/src/main/java/cn/iocoder/dashboard/framework/mybatis/core/dataobject/BaseDO.java @@ -1,5 +1,7 @@ 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 lombok.Data; @@ -15,18 +17,22 @@ public class BaseDO implements Serializable { /** * 创建时间 */ + @TableField(fill = FieldFill.INSERT) private Date createTime; /** * 最后更新时间 */ + @TableField(fill = FieldFill.INSERT_UPDATE) private Date updateTime; /** * 创建者 */ + @TableField(fill = FieldFill.INSERT) private String creator; /** * 更新者 */ + @TableField(fill = FieldFill.INSERT_UPDATE) private String updater; /** * 是否删除