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

import com.its.op.dto.its.facility.TbFcltFailOcrrTypeDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

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_FAIL_OCRR_TYPE")
public class TbFcltFailOcrrType implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("장애 발생 구분코드")  // N VARCHAR2(7)
    @Id
    @Column(name = "FAIL_OCRR_CD", nullable = false, length = 7)
    private String failOcrrCd;

    @ApiModelProperty("장애 발생 구분코드명")  // Y VARCHAR2(30)
    @Column(name = "FAIL_OCRR_CD_NM", length = 30)
    private String failOcrrCdNm;

    @ApiModelProperty("사용여부")  // Y CHAR(1)
    @Column(name = "USE_YN", columnDefinition = "CHAR", length = 1)
    private String useYn;

    public TbFcltFailOcrrTypeDto toDto() {
        return TbFcltFailOcrrTypeDto.builder()
                .failOcrrCd(this.failOcrrCd)
                .failOcrrCdNm(this.failOcrrCdNm)
                .useYn(this.useYn)
                .build();
    }

    public TbFcltFailOcrrType(String failOcrrCd) {
        this.failOcrrCd = failOcrrCd;
    }

    public void updateInfo(TbFcltFailOcrrTypeDto.TbFcltFailOcrrTypeUpdReq req) {
        this.failOcrrCdNm = req.getFailOcrrCdNm();
        this.useYn = req.getUseYn();
    }

}
