package com.its.api.its.model.entity.facility;

import com.its.api.its.model.dto.facility.TbFcltCmpyDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;

/**
 * 시설물업체 Entity Class
 */
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("시설물업체")
@Entity
@Table(name = "TB_FCLT_CMPY")
public class TbFcltCmpy implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("업체 ID")  // N VARCHAR(30)
    @Id
    @Column(name = "CMPY_ID", nullable = false, length = 30)
    private String cmpyId;

    @ApiModelProperty("업체 명")  // Y VARCHAR(30)
    @Column(name = "CMPY_NM", length = 30)
    private String cmpyNm;

    @ApiModelProperty("사업자 등록 번호")  // Y VARCHAR(30)
    @Column(name = "BRNO", length = 30)
    private String brno;

    @ApiModelProperty("주소")  // Y VARCHAR(200)
    @Column(name = "ADDR", length = 200)
    private String addr;

    @ApiModelProperty("전화번호")  // Y VARCHAR(128)
    @Column(name = "TEL", length = 128)
    private String tel;

    @ApiModelProperty("팩스 번호")  // Y VARCHAR(128)
    @Column(name = "FCSM_NMBR", length = 128)
    private String fcsmNmbr;

    @ApiModelProperty("대표자 명")  // Y VARCHAR(30)
    @Column(name = "RPRV_NM", length = 30)
    private String rprvNm;

    @ApiModelProperty("담당자 명")  // Y VARCHAR(30)
    @Column(name = "CHGR_NM", length = 30)
    private String chgrNm;

    @ApiModelProperty("담당자 연락처")  // Y VARCHAR(128)
    @Column(name = "CHGR_HP_NMBR", length = 128)
    private String chgrHpNmbr;

    @ApiModelProperty("담당자 이메일")  // Y VARCHAR(128)
    @Column(name = "CHGR_EMAL", length = 128)
    private String chgrEmal;

    @ApiModelProperty("추가자 명")  // Y VARCHAR(30)
    @Column(name = "ADTN_NM", length = 30)
    private String adtnNm;

    @ApiModelProperty("추가 일시")  // Y VARCHAR(14)
    @Column(name = "ADTN_DT", length = 14)
    private String adtnDt;

    @ApiModelProperty("변경자 명")  // Y VARCHAR(30)
    @Column(name = "CHNG_NM", length = 30)
    private String chngNm;

    @ApiModelProperty("변경 일시")  // Y VARCHAR(14)
    @Column(name = "CHNG_DT", length = 14)
    private String chngDt;

    @ApiModelProperty("삭제 여부")  // Y CHAR(1)
    @Column(name = "DEL_YN", columnDefinition = "CHAR", length = 1)
    private String delYn;

    public TbFcltCmpyDto toDto() {
        return TbFcltCmpyDto.builder()
                .cmpyId(this.cmpyId)
                .cmpyNm(this.cmpyNm)
                .brno(this.brno)
                .addr(this.addr)
                .tel(this.tel)
                .fcsmNmbr(this.fcsmNmbr)
                .rprvNm(this.rprvNm)
                .chgrNm(this.chgrNm)
                .chgrHpNmbr(this.chgrHpNmbr)
                .chgrEmal(this.chgrEmal)
                .adtnNm(this.adtnNm)
                .adtnDt(this.adtnDt)
                .chngNm(this.chngNm)
                .chngDt(this.chngDt)
                .delYn(this.delYn)
                .build();
    }

    public TbFcltCmpy(String cmpyId) {
        this.cmpyId = cmpyId;
    }

    public void updateInfo(TbFcltCmpyDto.TbFcltCmpyUpdReq req) {
        this.cmpyNm = req.getCmpyNm();
        this.brno = req.getBrno();
        this.addr = req.getAddr();
        this.tel = req.getTel();
        this.fcsmNmbr = req.getFcsmNmbr();
        this.rprvNm = req.getRprvNm();
        this.chgrNm = req.getChgrNm();
        this.chgrHpNmbr = req.getChgrHpNmbr();
        this.chgrEmal = req.getChgrEmal();
        this.adtnNm = req.getAdtnNm();
        this.adtnDt = req.getAdtnDt();
        this.chngNm = req.getChngNm();
        this.chngDt = req.getChngDt();
        this.delYn = req.getDelYn();
    }

}
