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

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.code.TbCmmnCd;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("FcltFailTypeDto(시설물 장애 유형 코드 정보)")
public class FcltFailTypeDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("장애 유형")  // Y VARCHAR(7)
    @JsonProperty("fail_type")
    private String failType;

    @ApiModelProperty("장애 유형명")
    @JsonProperty("fail_nm")
    private String failNm;

    @ApiModelProperty("코드설명")
    @JsonProperty("fail_desc")
    private String failDesc;

    public static FcltFailTypeDto makeDto(TbCmmnCd entity) {
        FcltFailTypeDto dto = FcltFailTypeDto.builder()
                .failType(entity.getCmmnCd())
                .failNm(entity.getCmmnCdKorNm())
                .build();

        dto.setFailDesc( "[" + dto.getFailType() + "] " + dto.getFailNm());

        return dto;
    }
}
