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

import java.util.List;

/**
 * @author zwx
 * @create 2020/5/16 9:41
 */
@Component
@Slf4j
public class UserOrderFeignFallbackFactory implements FallbackFactory<UserOrderFeign> {
    @Override
    public UserOrderFeign create(Throwable throwable) {
        return new UserOrderFeign() {
            @Override
            public ResultBean<Page<UserOrder>> showUserOrderPage(UserOrderDto userOrderDto) {
                log.error(ResultEnum.ERROR.getCode(),throwable);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public List<UserOrder> getUserOrderList(UserOrderDto userOrderDto) {
                log.error(ResultEnum.ERROR.getCode(),throwable);
                return null;
            }

            @Override
            public ResultBean<UserOrder> addUserOrder(UserOrderDto userOrder) {
                log.error(ResultEnum.ERROR.getCode(),throwable);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> updateUserOrder(UserOrder userOrder) {
                log.error(ResultEnum.ERROR.getCode(),throwable);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public UserOrder findUserOrderByCondition(UserOrderDto userOrderDto) {
                log.error(ResultEnum.ERROR.getCode(),throwable);
                return null;
            }

            @Override
            public boolean payFinish(UserOrder userOrder) {
                log.error(ResultEnum.ERROR.getCode(),throwable);
                return false;
            }

            @Override
            public ResultBean<Boolean> orderQuery(UserOrderDto userOrderDto) {
                log.error(ResultEnum.ERROR.getCode(),throwable);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public UserOrder addUserOrderByImport(UserOrderDto userOrderDto) {
                log.error(ResultEnum.ERROR.getCode(),throwable);
                return null;
            }

            @Override
            public UserOrder getByOldId(String oldId) {
                log.error(ResultEnum.ERROR.getCode(),throwable);
                return null;
            }
        };
    }
}
