修复一些bug

This commit is contained in:
aiShuiJiaoDeXioShou 2024-09-12 04:00:40 +08:00
parent bbf781accf
commit a169712e48
2 changed files with 17 additions and 1 deletions

View File

@ -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());
}
}
}

View File

@ -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;
}