package com.oqpo.api.web.dto.response.code;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.oqpo.api.entity.CodeEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

@Getter
@Setter
@Builder
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@JsonInclude(JsonInclude.Include.ALWAYS)
public class CodeInfoResponse {
    @ApiModelProperty(value = "코드")
    private String codeCd;

    @ApiModelProperty(value = "코드타입")
    private String codeTpCd;

    @ApiModelProperty(value = "코드명")
    private String codeNm;

    @ApiModelProperty(value = "사용여부")
    private String useYn;

    public static CodeInfoResponse toDTO(CodeEntity entity) {
        if (entity == null) return null;
        return CodeInfoResponse.builder()
                .codeCd(entity.getCodeCd())
                .codeTpCd(entity.getCodeTpCd())
                .codeNm(entity.getCodeNm())
                .useYn(entity.getUseYn())
                .build();
    }
}
