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.
43 lines
1.2 KiB
43 lines
1.2 KiB
package com.campus.common;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
import lombok.Data;
|
|
import org.hibernate.annotations.Where;
|
|
import org.hibernate.annotations.CreationTimestamp;
|
|
import org.hibernate.annotations.UpdateTimestamp;
|
|
|
|
import javax.persistence.*;
|
|
import java.io.Serializable;
|
|
import java.util.Date;
|
|
import java.util.UUID;
|
|
|
|
@Data
|
|
@MappedSuperclass
|
|
@Where(clause = "deleted = false")
|
|
public abstract class BaseEntity implements Serializable {
|
|
|
|
@Id
|
|
@Column(name = "id", nullable = false, updatable = false, length = 36)
|
|
private String id;
|
|
|
|
/** 逻辑删除标记:true-已删除,false-未删除 */
|
|
@Column(name = "deleted", nullable = false)
|
|
private Boolean deleted = false;
|
|
|
|
@CreationTimestamp
|
|
@Column(name = "created_at", nullable = false, updatable = false)
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
|
private Date createdAt;
|
|
|
|
@UpdateTimestamp
|
|
@Column(name = "updated_at", nullable = false)
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
|
private Date updatedAt;
|
|
|
|
@PrePersist
|
|
public void prePersist() {
|
|
if (this.id == null) {
|
|
this.id = UUID.randomUUID().toString();
|
|
}
|
|
}
|
|
}
|
|
|