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("FcltFailRegDto(장애등록구분 코드 정보)")
public class FcltFailRegDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("장애등록구분코드")
    @JsonProperty("fail_reg_cd")
    private String failRedCd;

    @ApiModelProperty("코드명")
    @JsonProperty("name")
    private String name;

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

    public static FcltFailRegDto makeDto(TbCmmnCd entity) {
        FcltFailRegDto dto = FcltFailRegDto.builder()
                .failRedCd(entity.getCmmnCd())
                .name(entity.getCmmnCdKorNm())
                .build();

        dto.setDesc( "[" + entity.getCmmnCd() + "] " + entity.getCmmnCdKorNm());

        return dto;
    }
}
