package com.sptg.estate.api.feigns.fallback;

import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.estate.api.entity.InstallationReview;
import com.sptg.estate.api.feigns.InstallationReviewFeign;
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 InstallationReviewFeignFallbackFactory implements FallbackFactory<InstallationReviewFeign> {

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

            @Override
            public ResultBean<InstallationReview> findByPositionRecordId(Long positionRecordId) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<InstallationReview> findByEnvironmentalReviewId(Long environmentalReviewId) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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