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("로그인시각")  // N VARCHAR(14)
    @Id
    @Column(name = "LOGIN_HMS", nullable = false, length = 14)
    private String loginHms;

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

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

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

}
