package com.jty.wsxt.domain.shared;

import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.time.LocalDateTime;

/**
 * 实体生成主键的父类
 *
 * @author Jason
 * @since 2019/4/17 14:26
 */
@MappedSuperclass
@Data
public abstract class IdentifiedEntityObject<T> implements EntityObject<T> {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    /***
     * 数据创建时间
     */
    @CreationTimestamp
    private LocalDateTime createdTime;

    /***
     * 数据修改时间
     */
    @UpdateTimestamp
    private LocalDateTime modifiedTime;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }
}