package com.yuchen.saas.payment.api.feign;

import com.yuchen.saas.payment.api.dto.invoice.SaasInvoiceFaqQueryDTO;
import com.yuchen.saas.payment.api.dto.invoice.SaasInvoiceHeaderDTO;
import com.yuchen.saas.payment.api.dto.invoice.SaasInvoiceHeaderQueryDTO;
import com.yuchen.saas.payment.api.dto.invoice.SaasInvoiceInstructionQueryDTO;
import com.yuchen.saas.payment.api.util.PayFeignFallbackUtils;
import com.yuchen.saas.payment.api.vo.invoice.SaasInvoiceFaqVO;
import com.yuchen.saas.payment.api.vo.invoice.SaasInvoiceHeaderListVO;
import com.yuchen.saas.payment.api.vo.invoice.SaasInvoiceHeaderVO;
import com.yuchen.saas.payment.api.vo.invoice.SaasInvoiceInstructionVO;
import feign.hystrix.FallbackFactory;
import org.nest.springwrap.core.mp.support.NestPage;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestHeader;

import java.util.Map;

@Component
public class SaasInvoiceManageFeignFallback implements FallbackFactory<SaasInvoiceManageFeign> {
    @Override
    public SaasInvoiceManageFeign create(Throwable throwable) {
        return new SaasInvoiceManageFeign() {

            @Override
            public R<Boolean> saveOrUpdateHeader(SaasInvoiceHeaderDTO headerDTO) {
                return PayFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<Boolean> deleteHeader(Long id) {
                return PayFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<SaasInvoiceHeaderVO> getHeaderById(Long id) {
                return PayFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<NestPage<SaasInvoiceHeaderListVO>> getHeaderPageList(SaasInvoiceHeaderQueryDTO queryDTO) {
                return PayFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<NestPage<SaasInvoiceInstructionVO>> getInstructionPageList(SaasInvoiceInstructionQueryDTO queryDTO, @RequestHeader Map header) {
                return PayFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<NestPage<SaasInvoiceFaqVO>> getFaqPageList(SaasInvoiceFaqQueryDTO queryDTO) {
                return PayFeignFallbackUtils.printLogAndReturn(throwable);
            }
        };
    }
}
