package com.its.op.entity.its.oper;

import com.its.op.dto.its.oper.TbUserCnncHsDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.*;
import java.io.Serializable;

/**
 * 사용자접속이력 Entity Class
 */
@Getter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("사용자접속이력")
@Entity
@Table(name = "TB_USER_CNNC_HS")
@IdClass(TbUserCnncHsKey.class)
public class TbUserCnncHs implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("운영시스템ID(WEB:웹관리자로그인)")  // N VARCHAR2(7)
    @Id
    @Column(name = "OPER_SYST_ID", nullable = false, length = 7)
    private String operSystId;

    @ApiModelProperty("로그인시각")  // N VARCHAR2(14)
    @Id
    @Column(name = "LOGIN_HMS", nullable = false, length = 14)
    private String loginHms;

    @ApiModelProperty("사용자ID(웹사용자 email)")  // N VARCHAR2(50)
    @Id
    @Column(name = "USER_ID", nullable = false, length = 50)
    private String userId;

    @ApiModelProperty("로그아웃시각")  // Y VARCHAR2(14)
    @Column(name = "LOGOUT_HMS", length = 14)
    private String logoutHms;

    public TbUserCnncHsDto toDto() {
        return TbUserCnncHsDto.builder()
                .operSystId(this.operSystId)
                .loginHms(this.loginHms)
                .userId(this.userId)
                .logoutHms(this.logoutHms)
                .build();
    }

}
