From a169712e48860237c8ded59cc6e9213e75dda929 Mon Sep 17 00:00:00 2001 From: aiShuiJiaoDeXioShou <2832294398@qq.com> Date: Thu, 12 Sep 2024 04:00:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9Bbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../acdr/common/handler/GlobalFieldFillHandler.java | 6 ++++++ .../java/com/yskj/acdr/master/user/entity/Users.java | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/acdr/src/main/java/com/yskj/acdr/common/handler/GlobalFieldFillHandler.java b/acdr/src/main/java/com/yskj/acdr/common/handler/GlobalFieldFillHandler.java index 9b59e0f9..ec532c74 100644 --- a/acdr/src/main/java/com/yskj/acdr/common/handler/GlobalFieldFillHandler.java +++ b/acdr/src/main/java/com/yskj/acdr/common/handler/GlobalFieldFillHandler.java @@ -27,6 +27,8 @@ public class GlobalFieldFillHandler implements MetaObjectHandler { // 仅在用户已登录且 metaObject 中存在但未设置 userId 时填充 userId if (StpUtil.isLogin()) { + this.strictInsertFill(metaObject, "creator", String.class, StpUtil.getLoginIdAsString()); + this.strictInsertFill(metaObject, "updater", String.class, StpUtil.getLoginIdAsString()); if (metaObject.hasSetter("userId")) { // 检查是否存在 userId 字段 Object userId = metaObject.getValue("userId"); // 仅当 userId 为 null 时设置新值,防止覆盖已存在的值 @@ -49,6 +51,10 @@ public class GlobalFieldFillHandler implements MetaObjectHandler { @Override public void updateFill(MetaObject metaObject) { this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now()); + if (StpUtil.isLogin()) { + this.strictInsertFill(metaObject, "creator", String.class, StpUtil.getLoginIdAsString()); + this.strictInsertFill(metaObject, "updater", String.class, StpUtil.getLoginIdAsString()); + } } } diff --git a/acdr/src/main/java/com/yskj/acdr/master/user/entity/Users.java b/acdr/src/main/java/com/yskj/acdr/master/user/entity/Users.java index a959361e..70ddf156 100644 --- a/acdr/src/main/java/com/yskj/acdr/master/user/entity/Users.java +++ b/acdr/src/main/java/com/yskj/acdr/master/user/entity/Users.java @@ -28,7 +28,7 @@ import java.time.LocalDateTime; @Accessors(chain = true) @TableName("acdr_users") @ApiModel(value = "UserBase对象", description = "") -public class Users extends ExtendEntity implements Serializable { +public class Users implements Serializable { private static final long serialVersionUID = 1L; @@ -81,4 +81,14 @@ public class Users extends ExtendEntity implements Serializable { @ApiModelProperty("是否拥有宠托师证书") @TableField(value = "is_pet_nursery") private Boolean isPetNursery = false; + + // 逻辑删除 + @TableLogic + private Boolean deleted; + + @TableField(value = "create_time", fill = FieldFill.INSERT) + private LocalDateTime createTime; + + @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) + private LocalDateTime updateTime; }