package com.zfire.mall.manager.helper;


import com.zfire.mall.manager.exception.FeignServiceException;
import com.zfire.mall.manager.exception.RemoteServiceException;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;
import java.util.List;


@Data
@Slf4j
public class FeignResponseObject<T> {

    public List<Integer> responseSuccessCodes = Arrays.asList(1,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 (responseSuccessCodes.contains(code)) {
            return this.data;
        }
        throw new RemoteServiceException(this.code,this.msg);
    }


}
