package com.oqpo.api.web.dto.response.oper.iflink;

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

@Getter
@Setter
@Builder
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@JsonInclude(JsonInclude.Include.ALWAYS)
public class InterfaceResponse {

    @ApiModelProperty(value = "CRUD")
    private String viewCd;

    @ApiModelProperty(value = "IF번호")
    private String ifNo;
    @ApiModelProperty(value = "IF ID")
    private String ifId;
    @ApiModelProperty(value = "IF명")
    private String ifNm;
    @ApiModelProperty(value = "사용여부")
    private String useYn;
    @ApiModelProperty(value = "사용여부명")
    private String useYnNm;
    @ApiModelProperty(value = "연동정보")
    private String linkInfo;
    @ApiModelProperty(value = "통신방식코드")
    private String comMethCd;
    @ApiModelProperty(value = "통신방식명")
    private String comMethNm;
    @ApiModelProperty(value = "송수신구분코드")
    private String srTpCd;
    @ApiModelProperty(value = "송수신구분명")
    private String srTpNm;
    @ApiModelProperty(value = "송수신URL")
    private String ifUrl;
    @ApiModelProperty(value = "API 설명")
    private String apiInfo;
    @ApiModelProperty(value = "전송파라메타설명")
    private String requestInfo;
    @ApiModelProperty(value = "수신파라메타설명")
    private String responseInfo;
    @ApiModelProperty(value = "등록일")
    private String addDt;
    @ApiModelProperty(value = "등록자아이디")
    private String addId;
    @ApiModelProperty(value = "등록자명")
    private String addNm;
    @ApiModelProperty(value = "수정일")
    private String chgDt;
    @ApiModelProperty(value = "수정자아이디")
    private String chgId;
    @ApiModelProperty(value = "수정자명")
    private String chgNm;

    public static InterfaceResponse toDTO(InterfaceEntity entity) {
        if (entity == null) return null;
        return InterfaceResponse.builder()
                .ifNo(entity.getIfNo())
                .ifId(entity.getIfId())
                .ifNm(entity.getIfNm())
                .useYn(entity.getUseYn())
                .useYnNm(entity.getUseYnNm())
                .linkInfo(entity.getLinkInfo())
                .comMethCd(entity.getComMethCd())
                .comMethNm(entity.getComMethNm())
                .srTpCd(entity.getSrTpCd())
                .srTpNm(entity.getSrTpNm())
                .ifUrl(entity.getIfUrl())
                .apiInfo(entity.getApiInfo())
                .requestInfo(entity.getRequestInfo())
                .responseInfo(entity.getResponseInfo())
                .addDt(entity.getAddDt())
                .addId(entity.getAddId())
                .addNm(entity.getAddNm())
                .chgDt(entity.getChgDt())
                .chgId(entity.getChgId())
                .chgNm(entity.getChgNm())
                .build();
    }
}
