package com.its.api.its.model.dto.code;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.api.its.model.entity.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("FcltTypeDto(시설물 유형 정보)")
public class FcltTypeDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("시설물유형 코드")
    @JsonProperty("fclt_type")
    private String fcltType;

    @ApiModelProperty("시설물명")
    @JsonProperty("fclt_nm")
    private String fcltNm;

    @ApiModelProperty("시설물코드설명")
    @JsonProperty("fclt_desc")
    private String fcltDesc;

    public static FcltTypeDto makeDto(TbCmmnCd entity) {
        FcltTypeDto dto = FcltTypeDto.builder()
                .fcltType(entity.getCmmnCd())
                .fcltNm(entity.getCmmnCdKorNm())
                .build();

        dto.setFcltDesc( "[" + dto.getFcltType() + "] " + dto.getFcltNm());

        return dto;
    }
}
