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

import com.its.op.dto.its.facility.TbFcltFailTypeActDto;
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_TYPE_ACT")
public class TbFcltFailTypeAct implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("장애조치유형")  // N VARCHAR2(7)
    @Id
    @Column(name = "FAIL_ACT_CD", nullable = false, length = 7)
    private String failActCd;

    @ApiModelProperty("장애조치 명")  // Y VARCHAR2(30)
    @Column(name = "FAIL_ACT_CD_NM", length = 30)
    private String failActCdNm;

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

    public TbFcltFailTypeActDto toDto() {
        return TbFcltFailTypeActDto.builder()
                .failActCd(this.failActCd)
                .failActCdNm(this.failActCdNm)
                .useYn(this.useYn)
                .build();
    }

    public TbFcltFailTypeAct(String failActCd) {
        this.failActCd = failActCd;
    }

    public void updateInfo(TbFcltFailTypeActDto.TbFcltFailTypeActUpdReq req) {
        this.failActCdNm = req.getFailActCdNm();
        this.useYn = req.getUseYn();
    }

}
