From 7f900d71eec6c6276de22a6b579e5736f2b5193a Mon Sep 17 00:00:00 2001 From: xy <1607447753@qq.com> Date: Fri, 28 Jun 2024 22:50:14 +0800 Subject: [PATCH] xy --- .../java/com/config/MyMetaObjectHandler.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/main/java/com/config/MyMetaObjectHandler.java diff --git a/src/main/java/com/config/MyMetaObjectHandler.java b/src/main/java/com/config/MyMetaObjectHandler.java new file mode 100644 index 0000000..2f9e793 --- /dev/null +++ b/src/main/java/com/config/MyMetaObjectHandler.java @@ -0,0 +1,28 @@ +package com.config; + +import java.util.Date; + +import org.apache.ibatis.reflection.MetaObject; + +import com.baomidou.mybatisplus.mapper.MetaObjectHandler; + +/** + * 自定义填充处理器 + */ +public class MyMetaObjectHandler extends MetaObjectHandler { + + @Override + public void insertFill(MetaObject metaObject) { + this.setFieldValByName("ctime", new Date(), metaObject); + } + + @Override + public boolean openUpdateFill() { + return false; + } + + @Override + public void updateFill(MetaObject metaObject) { + // 关闭更新填充、这里不执行 + } +}