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.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_LOIN_L")
@org.hibernate.annotations.Table(appliesTo = "TB_APIMS_LOIN_L", comment = "사용자 로그인 로그")
public class UserLoginHistory extends AbstractEntity<String> implements Serializable{
	
	private static final long serialVersionUID = 1L;

	@Id
//	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@GenericGenerator(
            name = "TB_APIMS_LOIN_L_GEN",
            strategy = "com.eactive.eai.rms.data.jpa.SchemaPrefixedSequenceGenerator",
            parameters = {
                    @org.hibernate.annotations.Parameter(name = "sequence_name", value = "TB_APIMS_LOIN_L_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_LOIN_L_GEN"
    )
	@Column(name="LOIN_LOG_ID", unique = true, nullable = false)
	@Comment("로그인 로그 식별자")
	private int loginLogId;
	
	@Column(name="USER_ID", length = 20, nullable = false)
	@Comment("사용자 식별자(사번)")
	private String userId;
	
	@Column(name="LOIN_DTTM", length = 14, nullable = false)
	@Comment("로그인 일시")
	@CreatedDate
	private LocalDateTime loginDttm;
	
	@Column(name="LOIN_IP", length = 32, nullable = false)
	@Comment("로그인 IP")
	private String loginIp;
	
	@Override
	public @NonNull String getId() {
		return Integer.toString(loginLogId);
	}
}
