basic-server/src/main/java/com/ruoyi/basic/entity/Customer.java
@@ -1,6 +1,7 @@ package com.ruoyi.basic.entity; import com.baomidou.mybatisplus.annotation.*; import com.ruoyi.common.core.domain.MyBaseEntity; import lombok.Data; import com.ruoyi.common.core.domain.BaseEntity; @@ -12,7 +13,7 @@ */ @Data @TableName("customer") public class Customer extends BaseEntity { public class Customer extends MyBaseEntity { private static final long serialVersionUID = 1L; basic-server/src/main/resources/db/migration/postgresql/V20250530152701__create_table_supply.sql
@@ -13,7 +13,11 @@ province_id BIGINT NOT NULL DEFAULT 0, city_id BIGINT NOT NULL DEFAULT 0, district_id BIGINT NOT NULL DEFAULT 0, create_time TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP -- 自动填充创建时间 deleted int4 NOT NULL DEFAULT 0, -- 是否删除(软删除标志) create_by VARCHAR(255), -- 创建人 create_time TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, -- 创建时间,默认当前时间 update_by VARCHAR(255), -- 最后更新人 update_time TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP -- 最后更新时间,默认当前时间 ); -- 表注释:供应商信息表,存储供应商基本信息(含地址层级关联) @@ -52,6 +56,9 @@ -- 区县ID(默认0,非空,关联地址字典) COMMENT ON COLUMN supply.district_id IS '供应商所在区县的ID(关联地址字典表),默认0,用于地址层级划分'; -- 创建时间(带时区,自动填充) COMMENT ON COLUMN supply.create_time IS '记录数据创建的时间戳(带时区),系统自动填充当前时间'; COMMENT ON COLUMN supply.deleted IS '软删除标志,true表示已删除'; COMMENT ON COLUMN supply.create_by IS '创建人用户名'; COMMENT ON COLUMN supply.create_time IS '记录创建时间'; COMMENT ON COLUMN supply.update_by IS '最后更新人用户名'; COMMENT ON COLUMN supply.update_time IS '记录最后更新时间'; ruoyi-common/src/main/java/com/ruoyi/common/handler/MyMetaObjectHandler.java
@@ -5,7 +5,7 @@ import org.apache.ibatis.reflection.MetaObject; import org.springframework.stereotype.Component; import java.time.LocalDateTime; import java.time.OffsetDateTime; @Component public class MyMetaObjectHandler implements MetaObjectHandler { @@ -14,22 +14,22 @@ public void insertFill(MetaObject metaObject) { // 判断字段是否存在,存在才填充 if (metaObject.hasSetter("createBy")) { Long userId = 0L; Long userId; try { if (SecurityUtils.getLoginUser() != null) { userId = SecurityUtils.getLoginUser().getUserId(); this.strictInsertFill(metaObject, "createBy", Long.class, userId); this.strictInsertFill(metaObject, "createBy", String.class, userId.toString()); } } catch (Exception ignored) { } } if (metaObject.hasSetter("createTime")) { this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now()); this.strictInsertFill(metaObject, "createTime", OffsetDateTime.class, OffsetDateTime.now()); } if (metaObject.hasSetter("updateTime")) { this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now()); this.strictUpdateFill(metaObject, "updateTime", OffsetDateTime.class, OffsetDateTime.now()); } } @@ -38,11 +38,11 @@ // 判断字段是否存在,存在才填充 if (metaObject.hasSetter("updateBy")) { Long userId = SecurityUtils.getLoginUser().getUserId(); this.strictUpdateFill(metaObject, "updateBy", Long.class, userId); this.strictUpdateFill(metaObject, "updateBy", String.class, userId.toString()); } if (metaObject.hasSetter("updateTime")) { this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now()); this.strictUpdateFill(metaObject, "updateTime", OffsetDateTime.class, OffsetDateTime.now()); } } }