You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.6 KiB
55 lines
1.6 KiB
|
4 weeks ago
|
package com.project.base.domain.entity;
|
||
|
|
|
||
|
|
import cn.hutool.core.bean.BeanUtil;
|
||
|
|
import com.baomidou.mybatisplus.annotation.*;
|
||
|
|
import com.project.base.domain.enums.StatusEnum;
|
||
|
|
import jakarta.persistence.Column;
|
||
|
|
import jakarta.persistence.MappedSuperclass;
|
||
|
|
import lombok.Data;
|
||
|
|
import org.hibernate.annotations.Comment;
|
||
|
|
|
||
|
|
import java.io.Serializable;
|
||
|
|
import java.util.Date;
|
||
|
|
import java.util.function.Supplier;
|
||
|
|
|
||
|
|
@MappedSuperclass
|
||
|
|
@Data
|
||
|
|
|
||
|
|
public class BaseEntity implements Serializable {
|
||
|
|
|
||
|
|
|
||
|
|
@TableField(value = "creator_id" , fill = FieldFill.INSERT)
|
||
|
|
@Column(name = "creator_id" , columnDefinition="varchar(50) comment '创建用户id'")
|
||
|
|
private String creatorId;
|
||
|
|
|
||
|
|
@TableField(value = "create_time" , fill = FieldFill.INSERT)
|
||
|
|
@Comment("创建时间")
|
||
|
|
@Column(name = "create_time")
|
||
|
|
private Date createTime;
|
||
|
|
|
||
|
|
@TableField(value = "updater_id" , fill = FieldFill.INSERT_UPDATE)
|
||
|
|
@Column(name = "updater_id", columnDefinition="bigint(20) comment '更新用户id'")
|
||
|
|
private Long updaterId;
|
||
|
|
|
||
|
|
@TableField(value = "update_time" , fill = FieldFill.INSERT_UPDATE)
|
||
|
|
@Comment("更新时间")
|
||
|
|
@Column(name = "update_time")
|
||
|
|
private Date updateTime;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* deleted字段请在数据库中 设置为tinyInt 并且非null 默认值为0
|
||
|
|
*/
|
||
|
|
@TableField("deleted")
|
||
|
|
@TableLogic
|
||
|
|
@Comment("逻辑删除位")
|
||
|
|
@Column(name = "deleted")
|
||
|
|
private Boolean deleted = StatusEnum.Normal.getValue();
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
public <T> T toDTO(Supplier<T> supplier) {
|
||
|
|
T dto = supplier.get();
|
||
|
|
BeanUtil.copyProperties(this, dto);
|
||
|
|
return dto;
|
||
|
|
}
|
||
|
|
}
|