package com.gree.mall.miniapp.helper;


import com.gree.mall.miniapp.exception.FeignServiceException;
import com.gree.mall.miniapp.exception.RemoteServiceException;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.List;


@Data
@Slf4j
public class FeignResponseObject<T> {

    public static int ResponseCode_Success=200;

    private int code;
    private T data;
    private String msg;
    private String serviceName;
    private String requestUrl;
    private List<String> stackTrace;

    public T checkOutData()throws RemoteServiceException {
        if (this.code == ResponseCode_Success) {
            return this.data;
        }
        FeignServiceException feignServiceException=new FeignServiceException(this.code, this.msg);
        feignServiceException.setServiceName(this.serviceName);
        feignServiceException.setRequestUrl(this.requestUrl);
        feignServiceException.setServiceStackTrace(this.stackTrace);
        throw feignServiceException;
    }




}
