package com.eactive.httpmockserver.common.entity;

import org.hibernate.annotations.Type;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import java.time.LocalDateTime;

@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class Auditable {

    /**
     * 최초등록시점
     */
    @Column(name = "REGISTERED_ON")
    @Type(type = "org.hibernate.type.LocalDateTimeType")
    @CreatedDate
    private LocalDateTime createdAt;

    /**
     * 최초등록자ID
     */
    @Column(name = "REGISTERED_BY")
    @CreatedBy
    private String createdBy;

    /**
     * 최종수정시점
     */
    @Column(name = "LAST_MODIFIED_ON")
    @Type(type = "org.hibernate.type.LocalDateTimeType")
    @LastModifiedDate
    private LocalDateTime updatedAt;

    /**
     * 최종수정자ID
     */
    @Column(name = "LAST_MODIFIED_BY")
    @LastModifiedBy
    private String updatedBy;

    public LocalDateTime getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public LocalDateTime getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(LocalDateTime updatedAt) {
        this.updatedAt = updatedAt;
    }

    public String getUpdatedBy() {
        return updatedBy;
    }

    public void setUpdatedBy(String updatedBy) {
        this.updatedBy = updatedBy;
    }
}



