package com.sptg.pay.api.feigns.fallback;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.pay.api.dto.PayCertificateDto;
import com.sptg.pay.api.entity.PayCertificate;
import com.sptg.pay.api.feigns.PayCertificateFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author zwx
 * @create 2020/5/25 10:06
 */
@Component
@Slf4j
public class PayCertificateFallbackFactory implements FallbackFactory<PayCertificateFeign> {

    @Override
    public PayCertificateFeign create(Throwable throwable) {
        return new PayCertificateFeign(){
            @Override
            public ResultBean<Page<PayCertificate>> showPayCertificatePage(PayCertificateDto payCertificateDto) {
                log.error(ResultEnum.ERROR.getCode(),throwable);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> addPayCertificate(PayCertificateDto payCertificateDto) {
                log.error(ResultEnum.ERROR.getCode(),throwable);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public PayCertificate addPayCertificateByImport(PayCertificateDto payCertificateDto) {
                log.error(ResultEnum.ERROR.getCode(),throwable);
                return null;
            }

            @Override
            public ResultBean<Boolean> updatePayCertificate(PayCertificate payCertificate) {
                log.error(ResultEnum.ERROR.getCode(),throwable);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public PayCertificate findPayCertificateById(Long id) {
                log.error(ResultEnum.ERROR.getCode(),throwable);
                return null;
            }

            @Override
            public PayCertificate findPayCertificateByCondition(PayCertificateDto payCertificateDto) {
                log.error(ResultEnum.ERROR.getCode(),throwable);
                return null;
            }

            @Override
            public List<PayCertificate> findPayCertificateListByCondition(PayCertificateDto payCertificateDto) {
                log.error(ResultEnum.ERROR.getCode(),throwable);
                return null;
            }
        };
    }
}
