package cokr.xit.ens.core.aop;

import cokr.xit.ens.core.exception.code.EnsErrCd;
import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Getter
@ToString
@Schema(name = "EnsResponseVO")
@NoArgsConstructor
public class EnsResponseVO<T> {

	@Schema(required = true, title = "에러 코드", example = " ")
	@JsonProperty("errCode")
	@JsonAlias({"err_code"})
	@SerializedName(value = "errCode", alternate = {"err_code"})
	private EnsErrCd errCode = null;

	@Schema(required = true, title = "에러 메시지", example = " ")
	@JsonProperty("errMsg")
	@JsonAlias({"err_msg"})
	@SerializedName(value = "errMsg", alternate = {"err_msg"})
	private String errMsg  = null;

	@Schema(required = false, title = "결과 데이터", example = " ")
	@JsonProperty("resultInfo")
	@JsonAlias({"result_info"})
	@SerializedName(value = "resultInfo", alternate = {"result_info"})
	private T resultInfo;
	
	@Builder(builderClassName = "okBuilder" ,builderMethodName = "okBuilder")
	EnsResponseVO(T resultInfo) {
		this.errCode = EnsErrCd.OK;
		this.errMsg = EnsErrCd.OK.getCodeNm();
		this.resultInfo = resultInfo;
	}

	@Builder(builderClassName = "errBuilder" ,builderMethodName = "errBuilder")
	EnsResponseVO(EnsErrCd errCode, String errMsg) {
		this.errCode = errCode;
		this.errMsg = errMsg;
	}

	@Builder(builderClassName = "errRsltBuilder" ,builderMethodName = "errRsltBuilder")
	EnsResponseVO(EnsErrCd errCode, String errMsg, T resultInfo) {
		this.errCode = errCode;
		this.errMsg = errMsg;
		this.resultInfo = resultInfo;
	}
}
