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.PayChannelConfigDto;
import com.sptg.pay.api.entity.PayChannelConfig;
import com.sptg.pay.api.feigns.PayChannelConfigFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

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

    @Override
    public PayChannelConfigFeign create(Throwable throwable) {
        return new PayChannelConfigFeign(){
            @Override
            public ResultBean<Page<PayChannelConfig>> showPayChannelConfigPage(PayChannelConfigDto payChannelConfigDto) {
                log.error(ResultEnum.ERROR.getCode(),throwable);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> addPayChannelConfig(PayChannelConfigDto payChannelConfigDto) {
                log.error(ResultEnum.ERROR.getCode(),throwable);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

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

            @Override
            public PayChannelConfig findUnitByCondition(PayChannelConfigDto payChannelConfigDto) {
                log.error(ResultEnum.ERROR.getCode(),throwable);
                return null;
            }
        };
    }
}
