package com.its.op.entity.its.facility;

import com.its.op.dto.its.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(50)
    @Column(name = "CMPY_NM", length = 50)
    private String cmpyNm;

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

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

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

    @ApiModelProperty("팩스 번호")  // Y VARCHAR(30)
    @Column(name = "FAX_NMBR", length = 30)
    private String faxNmbr;

    @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(30)
    @Column(name = "CHGR_HP_NMBR", length = 30)
    private String chgrHpNmbr;

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

    @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)
                .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();
    }

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

    public void updateInfo(TbFcltCmpyDto.TbFcltCmpyUpdReq req) {
        this.cmpyNm = req.getCmpyNm();
        this.cmpyRgstNmbr = req.getCmpyRgstNmbr();
        this.addr = req.getAddr();
        this.tel = req.getTel();
        this.faxNmbr = req.getFaxNmbr();
        this.rprvNm = req.getRprvNm();
        this.chgrNm = req.getChgrNm();
        this.chgrHpNmbr = req.getChgrHpNmbr();
        this.chgrEmail = req.getChgrEmail();
        this.delYn = req.getDelYn();
    }

}
