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

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.facility.TbFcltSubjPartIn;
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("TbFcltSubjPartInDto(FMS 시설물 부품 입고 정보)")
public class TbFcltSubjPartInDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("부품 품목 번호")  // N NUMBER(10)
    @JsonProperty("part_nmbr")
    private Long partNmbr;

    @ApiModelProperty("입고 일자")  // N VARCHAR2(8)
    @JsonProperty("in_dt")
    private String inDt;

    @ApiModelProperty("단위(EA, ...)")  // Y VARCHAR2(10)
    @JsonProperty("in_unit")
    private String inUnit;

    @ApiModelProperty("단위 수량당 단가")  // N NUMBER(5)
    @JsonProperty("per_amt")
    private Integer perAmt;

    @ApiModelProperty("입고 갯수")  // N NUMBER(5)
    @JsonProperty("in_cnt")
    private Integer inCnt;

    @ApiModelProperty("매입 업체 ID")  // Y VARCHAR2(30)
    @JsonProperty("cmpy_id")
    private String cmpyId;

    @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("TbFcltSubjPartInUpdReq(FMS 시설물 부품 입고 정보 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbFcltSubjPartInUpdReq {

        @ApiModelProperty("부품 품목 번호, Nullable = N, NUMBER(10)")  // N NUMBER(10)
        @JsonProperty("part_nmbr")
        @PositiveOrZero
        private Long partNmbr;

        @ApiModelProperty("입고 일자, Nullable = N, VARCHAR2(8)")  // N VARCHAR2(8)
        @JsonProperty("in_dt")
        @Size(min=1, max=8)
        private String inDt;

        @ApiModelProperty("단위(EA, ...), Nullable = Y, VARCHAR2(10)")  // Y VARCHAR2(10)
        @JsonProperty("in_unit")
        @Size(min=1, max=10)
        private String inUnit;

        @ApiModelProperty("단위 수량당 단가, Nullable = N, NUMBER(5)")  // N NUMBER(5)
        @JsonProperty("per_amt")
        @PositiveOrZero
        private Integer perAmt;

        @ApiModelProperty("입고 갯수, Nullable = N, NUMBER(5)")  // N NUMBER(5)
        @JsonProperty("in_cnt")
        @PositiveOrZero
        private Integer inCnt;

        @ApiModelProperty("매입 업체 ID, Nullable = Y, VARCHAR2(30)")  // Y VARCHAR2(30)
        @JsonProperty("cmpy_id")
        @Size(min=1, max=30)
        private String cmpyId;

        @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 TbFcltSubjPartInUpdReq(Long part_nmbr, String in_dt, String in_unit, Integer per_amt, Integer in_cnt, String cmpy_id, String user_id, Integer valid_cnt) {
            this.partNmbr = part_nmbr;
            this.inDt = in_dt;
            this.inUnit = in_unit;
            this.perAmt = per_amt;
            this.inCnt = in_cnt;
            this.cmpyId = cmpy_id;
            this.userId = user_id;
            this.validCnt = valid_cnt;
        }

        public TbFcltSubjPartIn toEntity() {
            return TbFcltSubjPartIn.builder()
                    .partNmbr(this.partNmbr)
                    .inDt(this.inDt)
                    .inUnit(this.inUnit)
                    .perAmt(this.perAmt)
                    .inCnt(this.inCnt)
                    .cmpyId(this.cmpyId)
                    .userId(this.userId)
                    .validCnt(this.validCnt)
                    .build();
        }

    }

}
