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("IncdCodeDto(돌발관리 코드정보)")
public class IncdCodeDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("코드")
    @JsonProperty("code")
    private String code;

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

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

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

        dto.setDesc( "[" + dto.getCode() + "] " + dto.getName());

        return dto;
    }
}
