package com.eactive.eai.rms.data.entity.man.user;

import java.io.Serializable;
import java.time.LocalDateTime;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.Comment;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;

import com.eactive.eai.data.entity.AbstractEntity;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;

@Data
@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true)

@Entity
@Table(name = "TB_APIMS_USER_ATHR_ROLE_CHG_H")
@org.hibernate.annotations.Table(appliesTo = "TB_APIMS_USER_ATHR_ROLE_CHG_H", comment = "사용자 권한 ROLE 변경 이력")
public class UserAthrRoleChgHistory extends AbstractEntity<Integer> implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
//	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@GenericGenerator(
            name = "TB_APIMS_USER_ATHR_ROLE_CHG_H_GEN",
            strategy = "com.eactive.eai.rms.data.jpa.SchemaPrefixedSequenceGenerator",
            parameters = {
                    @org.hibernate.annotations.Parameter(name = "sequence_name", value = "TB_APIMS_USER_ATHR_ROLE_CHG_H_SEQ"),
                    @org.hibernate.annotations.Parameter(name = "initial_value", value = "1"),
                    @org.hibernate.annotations.Parameter(name = "increment_size", value = "1")
            }
    )
    @GeneratedValue(
            strategy = GenerationType.SEQUENCE,
            generator = "TB_APIMS_USER_ATHR_ROLE_CHG_H_GEN"
    )
	@Column(name = "CHG_LOG_ID", unique = true, nullable = false)
	@Comment("사용자 정보 변경 로그 식별 ID")
	private int chgLogId;

	@Column(name = "USER_ID", length = 20, nullable = false)
	@Comment("사용자 식별자(사번)")
	private String userId;

	@Column(name = "CHG_GB", length = 4, nullable = false)
	@Comment("사용자 변경 구분")
	private String chgGb;

	@Column(name = "CHG_DTL", length = 4000, nullable = false)
	@Comment("변경 상세 내역")
	private String chgDtl;

	@Column(name = "AMDR_ID", length = 20, nullable = false)
	@Comment("수정자 식별자(사번)")
	@CreatedBy
	private String amdrId;

	@Column(name = "CCTN_IP", length = 32)
	@Comment("수정자 접속IP 주소")
	private String cctnIp;

	@Column(name = "CRTN_DTTM", length = 20)
	@Comment("레코드 생성일시")
	@CreatedDate
	private LocalDateTime crtnDttm;

	@Override
	public @NonNull Integer getId() {
		return chgLogId;
	}

}
