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

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

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

/**
 * 시설물업체 DTO Class
 */
@Data
@Builder
@ApiModel("TbFcltCmpyDto(시설물업체)")
public class TbFcltCmpyDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("업체 ID")  // N VARCHAR(30)
    @JsonProperty("cmpy_id")
    private String cmpyId;

    @ApiModelProperty("업체 명")  // Y VARCHAR(50)
    @JsonProperty("cmpy_nm")
    private String cmpyNm;

    @ApiModelProperty("사업자 등록 번호")  // Y VARCHAR(30)
    @JsonProperty("cmpy_rgst_nmbr")
    private String cmpyRgstNmbr;

    @ApiModelProperty("주소")  // Y VARCHAR(200)
    @JsonProperty("addr")
    private String addr;

    @ApiModelProperty("전화번호")  // Y VARCHAR(30)
    @JsonProperty("tel")
    private String tel;

    @ApiModelProperty("팩스 번호")  // Y VARCHAR(30)
    @JsonProperty("fax_nmbr")
    private String faxNmbr;

    @ApiModelProperty("대표자 명")  // Y VARCHAR(30)
    @JsonProperty("rprv_nm")
    private String rprvNm;

    @ApiModelProperty("담당자 명")  // Y VARCHAR(30)
    @JsonProperty("chgr_nm")
    private String chgrNm;

    @ApiModelProperty("담당자 연락처")  // Y VARCHAR(30)
    @JsonProperty("chgr_hp_nmbr")
    private String chgrHpNmbr;

    @ApiModelProperty("담당자 이메일")  // Y VARCHAR(128)
    @JsonProperty("chgr_email")
    private String chgrEmail;

    @ApiModelProperty("삭제 여부")  // Y CHAR(1)
    @JsonProperty("del_yn")
    private String delYn;

    // Code Description Field

    @ApiModel("TbFcltCmpyUpdReq(시설물업체 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbFcltCmpyUpdReq {

        @ApiModelProperty("업체 ID, Nullable = N, VARCHAR(30)")  // N VARCHAR(30)
        @JsonProperty("cmpy_id")
        @Size(min=1, max=30)
        private String cmpyId;

        @ApiModelProperty("업체 명, Nullable = Y, VARCHAR(50)")  // Y VARCHAR(50)
        @JsonProperty("cmpy_nm")
        @Size(min=1, max=50)
        private String cmpyNm;

        @ApiModelProperty("사업자 등록 번호, Nullable = Y, VARCHAR(30)")  // Y VARCHAR(30)
        @JsonProperty("cmpy_rgst_nmbr")
        //@Size(min=1, max=30)
        @Size(max=30)
        private String cmpyRgstNmbr;

        @ApiModelProperty("주소, Nullable = Y, VARCHAR(200)")  // Y VARCHAR(200)
        @JsonProperty("addr")
        @Size(min=1, max=200)
        private String addr;

        @ApiModelProperty("전화번호, Nullable = Y, VARCHAR(30)")  // Y VARCHAR(30)
        @JsonProperty("tel")
        @Size(max=30)
        private String tel;

        @ApiModelProperty("팩스 번호, Nullable = Y, VARCHAR(30)")  // Y VARCHAR(30)
        @JsonProperty("fax_nmbr")
        @Size(max=30)
        private String faxNmbr;

        @ApiModelProperty("대표자 명, Nullable = Y, VARCHAR(30)")  // Y VARCHAR(30)
        @JsonProperty("rprv_nm")
        @Size(max=30)
        private String rprvNm;

        @ApiModelProperty("담당자 명, Nullable = Y, VARCHAR(30)")  // Y VARCHAR(30)
        @JsonProperty("chgr_nm")
        @Size(max=30)
        private String chgrNm;

        @ApiModelProperty("담당자 연락처, Nullable = Y, VARCHAR(30)")  // Y VARCHAR(30)
        @JsonProperty("chgr_hp_nmbr")
        @Size(max=30)
        private String chgrHpNmbr;

        @ApiModelProperty("담당자 이메일, Nullable = Y, VARCHAR(128)")  // Y VARCHAR(128)
        @JsonProperty("chgr_email")
        @Size(max=128)
        private String chgrEmail;

        @ApiModelProperty("삭제 여부, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("del_yn")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String delYn;

        @Builder
        public TbFcltCmpyUpdReq(String cmpy_id, String cmpy_nm, String cmpy_rgst_nmbr, String addr, String tel, String fax_nmbr, String rprv_nm, String chgr_nm, String chgr_hp_nmbr, String chgr_email, String del_yn) {
            this.cmpyId = cmpy_id;
            this.cmpyNm = cmpy_nm;
            this.cmpyRgstNmbr = cmpy_rgst_nmbr;
            this.addr = addr;
            this.tel = tel;
            this.faxNmbr = fax_nmbr;
            this.rprvNm = rprv_nm;
            this.chgrNm = chgr_nm;
            this.chgrHpNmbr = chgr_hp_nmbr;
            this.chgrEmail = chgr_email;
            this.delYn = del_yn;
        }

        public TbFcltCmpy toEntity() {
            return TbFcltCmpy.builder()
                    .cmpyId(this.cmpyId)
                    .cmpyNm(this.cmpyNm)
                    .cmpyRgstNmbr(this.cmpyRgstNmbr)
                    .addr(this.addr)
                    .tel(this.tel)
                    .faxNmbr(this.faxNmbr)
                    .rprvNm(this.rprvNm)
                    .chgrNm(this.chgrNm)
                    .chgrHpNmbr(this.chgrHpNmbr)
                    .chgrEmail(this.chgrEmail)
                    .delYn(this.delYn)
                    .build();
        }

    }

}
