package com.its.op.dto.its.rse;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.rse.TbRseCtlrCnncHs;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.validation.constraints.PositiveOrZero;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * RSE 접속로그 이력 DTO Class
 */
@Data
@Builder
@ApiModel("TbRseCtlrCnncHsDto(RSE 접속로그 이력)")
public class TbRseCtlrCnncHsDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("RSE 제어기 번호")  // N NUMBER(10)
    @JsonProperty("rse_ctlr_nmbr")
    private Long rseCtlrNmbr;

    @ApiModelProperty("수집 일시")  // N VARCHAR2(14)
    @JsonProperty("clct_dt")
    private String clctDt;

    @ApiModelProperty("로그 유형")  // Y VARCHAR2(7)
    @JsonProperty("log_type")
    private String logType;

    @ApiModelProperty("로그 ID")  // Y VARCHAR2(64)
    @JsonProperty("log_id")
    private String logId;

    @ApiModelProperty("로그 ADDRESS")  // Y VARCHAR2(20)
    @JsonProperty("log_address")
    private String logAddress;

    // Code Description Field
    @ApiModel("TbRseCtlrCnncHsUpdReq(RSE 접속로그 이력 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbRseCtlrCnncHsUpdReq {

        @ApiModelProperty("RSE 제어기 번호, Nullable = N, NUMBER(10)")  // N NUMBER(10)
        @JsonProperty("rse_ctlr_nmbr")
        @PositiveOrZero
        private Long rseCtlrNmbr;

        @ApiModelProperty("수집 일시, Nullable = N, VARCHAR2(14)")  // N VARCHAR2(14)
        @JsonProperty("clct_dt")
        @Size(min=1, max=14)
        private String clctDt;

        @ApiModelProperty("로그 유형, Nullable = Y, VARCHAR2(7)")  // Y VARCHAR2(7)
        @JsonProperty("log_type")
        @Size(min=1, max=7)
        private String logType;

        @ApiModelProperty("로그 ID, Nullable = Y, VARCHAR2(64)")  // Y VARCHAR2(64)
        @JsonProperty("log_id")
        @Size(min=1, max=64)
        private String logId;

        @ApiModelProperty("로그 ADDRESS, Nullable = Y, VARCHAR2(20)")  // Y VARCHAR2(20)
        @JsonProperty("log_address")
        @Size(min=1, max=20)
        private String logAddress;

        @Builder
        public TbRseCtlrCnncHsUpdReq(Long rse_ctlr_nmbr, String clct_dt, String log_type, String log_id, String log_address) {
            this.rseCtlrNmbr = rse_ctlr_nmbr;
            this.clctDt = clct_dt;
            this.logType = log_type;
            this.logId = log_id;
            this.logAddress = log_address;
        }

        public TbRseCtlrCnncHs toEntity() {
            return TbRseCtlrCnncHs.builder()
                    .rseCtlrNmbr(this.rseCtlrNmbr)
                    .clctDt(this.clctDt)
                    .logType(this.logType)
                    .logId(this.logId)
                    .logAddress(this.logAddress)
                    .build();
        }

    }

}
