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.EnvironmentalReviewDto;
import com.sptg.estate.api.entity.EnvironmentalReview;
import com.sptg.estate.api.feigns.DeviceTestFeign;
import com.sptg.estate.api.feigns.EnvironmentalReviewFeign;
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 EnvironmentalReviewFeignFallbackFactory implements FallbackFactory<EnvironmentalReviewFeign> {

    @Override
    public EnvironmentalReviewFeign create(Throwable cause) {
        return new EnvironmentalReviewFeign(){
            @Override
            public ResultBean<Boolean> countByPositionId(Long positionId) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<EnvironmentalReview> findByPositionId(Long positionId) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> insertOrUpdate(EnvironmentalReview environmentalReview) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Page<EnvironmentalReview>> showList(EnvironmentalReviewDto dto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Integer> countByOrgPosition(String orgPosition) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> checkState(EnvironmentalReviewDto dto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<EnvironmentalReview> findById(Long id) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
