package com.its.op.dto.its.code;

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("DtctTypeDto(검지기유형-방향 코드정보)")
public class VdsDtctTypeDto implements Serializable {
    private static final long serialVersionUID = 1L;

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

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

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

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

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

        return dto;
    }
}
