package com.microservices.system.api.utils;

import com.microservices.common.core.domain.R;
import com.microservices.common.core.exception.ServiceException;
import com.microservices.common.core.utils.StringUtils;

/**
 * @author otto
 */
public class FeignUtils {
    public static <T> T getReturnData(R<T> result){
        if (StringUtils.isNull(result)) {
            return null;
        }

        if (R.FAIL == result.getCode())
        {
            throw new ServiceException(result.getMsg());
        }
        return result.getData();
    }
}
