package com.sptg.estate.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.estate.api.dto.BillsDto;
import com.sptg.estate.api.entity.Bills;
import com.sptg.estate.api.feigns.BillsFeign;
import com.sptg.estate.api.vo.BillsVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * title: PositionFeignFallbackFactory
 * package: com.sptg.estate.api.feigns.fallback
 * description:竣工验收-服务容错处理类
 */
@Component
@Slf4j
public class BillsFeignFallbackFactory implements FallbackFactory<BillsFeign> {


    @Override
    public BillsFeign create(Throwable throwable) {
        return new BillsFeign() {

            @Override
            public Page<Bills> list(Integer current, Integer size, Bills bills) {
                log.error("BillsFeign-list 调用错误");
                log.error("错误信息："+throwable.getMessage());
                return new Page<>();
            }

            @Override
            public ResultBean<Page<Bills>> page(BillsDto dto) {
                log.error(throwable.getMessage(),throwable);
                return new ResultBean<Page<Bills>>(ResultEnum.ERROR);
            }

            @Override
            public BillsVO detail(Long id) {
                log.error("BillsFeign-detail 调用错误");
                log.error("错误信息："+throwable.getMessage());
                return null;
            }

            @Override
            public ResultBean<Boolean> delete(BillsDto billsDto) {
                log.error("BillsFeign-delete 调用错误");
                log.error("错误信息："+throwable.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> edit(BillsDto billsDto) {
                log.error(throwable.getMessage(),throwable);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> add(BillsDto billsDto) {
                log.error(throwable.getMessage(),throwable);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
