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.EstateRepairDto;
import com.sptg.estate.api.entity.EstateRepair;
import com.sptg.estate.api.feigns.EstateRepairFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * title: EstateRepairFallbackFactory
 * package: com.sptg.estate.api.feigns.fallback
 * description:物业报修-服务容错处理类
 *
 *                
 *                
 */
@Component
@Slf4j
public class EstateRepairFeignFallbackFactory implements FallbackFactory<EstateRepairFeign> {
    @Override
    public EstateRepairFeign create(Throwable cause) {
        return new EstateRepairFeign(){
            @Override
            public ResultBean<Page<EstateRepair>> showEstateRepairList(EstateRepairDto estateRepairDto) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<List<EstateRepair>> getList(@RequestBody EstateRepairDto estateRepairDto) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<EstateRepair> addOrEditEstateRepair(EstateRepair estateRepair) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<EstateRepair> findEstateRepairById(long id) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<Boolean> deleteEstateRepairById(long id) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<Boolean> deleteEstateRepairList(EstateRepairDto estateRepairDto) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
