package cn.novalon.gym.manage.member.entity;

import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.domain.Persistable;
import org.springframework.data.relational.core.mapping.Column;

import lombok.Data;

import java.time.LocalDateTime;

/**
 * 会员模块实体基类
 * 
 * @author 付嘉
 * @date 2026-05-08
 */
@Data
public abstract class BaseEntity implements Persistable<Long> {

    // ID
    @Id
    private Long id;

    // 创建时间
    @CreatedDate
    @Column("created_at")
    private LocalDateTime createdAt;

    // 更新时间
    @LastModifiedDate
    @Column("updated_at")
    private LocalDateTime updatedAt;

    @Column("deleted_at")
    private LocalDateTime deletedAt;

    // 判断当前实体是否是新建的
    @Override
    public boolean isNew() {
        return createdAt == null;
    }
}
