package com.its.op.dto.its.facility;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.facility.TbFcltSubjPartOut;
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;

/**
 * FMS 시설물 부품 출고 정보 DTO Class
 */
@Data
@Builder
@ApiModel("TbFcltSubjPartOutDto(FMS 시설물 부품 출고 정보)")
public class TbFcltSubjPartOutDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("")  // N NUMBER(10)
    @JsonProperty("part_nmbr")
    private Long partNmbr;

    @ApiModelProperty("출고 대상 시설물 ID")  // N VARCHAR2(30)
    @JsonProperty("fclt_id")
    private String fcltId;

    @ApiModelProperty("출고 일자")  // N VARCHAR2(8)
    @JsonProperty("out_dt")
    private String outDt;

    @ApiModelProperty("출고 갯수")  // N NUMBER(5)
    @JsonProperty("out_cnt")
    private Integer outCnt;

    @ApiModelProperty("출고 내용")  // Y VARCHAR2(200)
    @JsonProperty("out_desc")
    private String outDesc;

    @ApiModelProperty("출고 담장자 사원 ID")  // Y VARCHAR2(10)
    @JsonProperty("user_id")
    private String userId;

    @ApiModelProperty("재고 수량")  // Y NUMBER(5)
    @JsonProperty("valid_cnt")
    private Integer validCnt;

    // Code Description Field
    @ApiModel("TbFcltSubjPartOutUpdReq(FMS 시설물 부품 출고 정보 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbFcltSubjPartOutUpdReq {

        @ApiModelProperty(", Nullable = N, NUMBER(10)")  // N NUMBER(10)
        @JsonProperty("part_nmbr")
        @PositiveOrZero
        private Long partNmbr;

        @ApiModelProperty("출고 대상 시설물 ID, Nullable = N, VARCHAR2(30)")  // N VARCHAR2(30)
        @JsonProperty("fclt_id")
        @Size(min=1, max=30)
        private String fcltId;

        @ApiModelProperty("출고 일자, Nullable = N, VARCHAR2(8)")  // N VARCHAR2(8)
        @JsonProperty("out_dt")
        @Size(min=1, max=8)
        private String outDt;

        @ApiModelProperty("출고 갯수, Nullable = N, NUMBER(5)")  // N NUMBER(5)
        @JsonProperty("out_cnt")
        @PositiveOrZero
        private Integer outCnt;

        @ApiModelProperty("출고 내용, Nullable = Y, VARCHAR2(200)")  // Y VARCHAR2(200)
        @JsonProperty("out_desc")
        @Size(min=1, max=200)
        private String outDesc;

        @ApiModelProperty("출고 담장자 사원 ID, Nullable = Y, VARCHAR2(10)")  // Y VARCHAR2(10)
        @JsonProperty("user_id")
        @Size(min=1, max=10)
        private String userId;

        @ApiModelProperty("재고 수량, Nullable = Y, NUMBER(5)")  // Y NUMBER(5)
        @JsonProperty("valid_cnt")
        @PositiveOrZero
        private Integer validCnt;

        @Builder
        public TbFcltSubjPartOutUpdReq(Long part_nmbr, String fclt_id, String out_dt, Integer out_cnt, String out_desc, String user_id, Integer valid_cnt) {
            this.partNmbr = part_nmbr;
            this.fcltId = fclt_id;
            this.outDt = out_dt;
            this.outCnt = out_cnt;
            this.outDesc = out_desc;
            this.userId = user_id;
            this.validCnt = valid_cnt;
        }

        public TbFcltSubjPartOut toEntity() {
            return TbFcltSubjPartOut.builder()
                    .partNmbr(this.partNmbr)
                    .fcltId(this.fcltId)
                    .outDt(this.outDt)
                    .outCnt(this.outCnt)
                    .outDesc(this.outDesc)
                    .userId(this.userId)
                    .validCnt(this.validCnt)
                    .build();
        }

    }

}
