package cn.iocoder.yudao.framework.common.base;

import cn.iocoder.yudao.framework.common.validation.group.ModGroup;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * 功能描述: 表主键ID的公共实体类
 * <p>
 * 作者: July
 * 日期: 2020-09-15 11:58
 * @author Admin
 */
@Data
@MappedSuperclass
public abstract class BaseEntity implements Comparable<BaseEntity>, Serializable {

    private static final long serialVersionUID = -5822264443656081290L;

    /** 表主键Id */
    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @NotNull(message="主键不存在无法更新", groups = {ModGroup.class})
    private Long id;

    @Override
    public int compareTo(BaseEntity o) {
        return this.getId().compareTo(o.getId());
    }
}
