使用oracle做的数据上传系统后台
kongdeqiang
2026-03-23 bdeb03a42dace46b1211bf12f3ad66837814035d
src/main/java/com/example/config/MyBatisPlusConfig.java
@@ -5,6 +5,7 @@
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.example.security.UserContext;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -27,15 +28,20 @@
        return new MetaObjectHandler() {
            @Override
            public void insertFill(MetaObject metaObject) {
                String username = UserContext.getCurrentUsername();
                this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());
                this.strictInsertFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());
                this.strictInsertFill(metaObject, "deleted", Integer.class, 0);
                this.strictInsertFill(metaObject, "version", Integer.class, 1);
                this.strictInsertFill(metaObject, "createBy", String.class, username != null ? username : "系统");
                this.strictInsertFill(metaObject, "updateBy", String.class, username != null ? username : "系统");
            }
            @Override
            public void updateFill(MetaObject metaObject) {
                String username = UserContext.getCurrentUsername();
                this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());
                this.strictUpdateFill(metaObject, "updateBy", String.class, username != null ? username : "系统");
            }
        };
    }