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.PositionDto;
import com.sptg.estate.api.entity.EnvironmentalReview;
import com.sptg.estate.api.entity.InstallationReview;
import com.sptg.estate.api.entity.Position;
import com.sptg.estate.api.entity.PositionRecord;
import com.sptg.estate.api.feigns.PositionFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * title: PositionFeignFallbackFactory
 * package: com.sptg.estate.api.feigns.fallback
 * description:设备定位-服务容错处理类
 *
 *                
 *                
 */
@Component
@Slf4j
public class PositionFeignFallbackFactory implements FallbackFactory<PositionFeign> {

    @Override
    public PositionFeign create(Throwable cause) {
        return new PositionFeign(){
            @Override
            public ResultBean<Page<Position>> showList(PositionDto dto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<Position> findByProjectId(Long projectId) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public List<PositionRecord> getPositionRecordListById(Long id) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public List<EnvironmentalReview> getEnvironmentalReviewListById(Long id) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public List<InstallationReview> getInstallationReviewListById(Long id) {
                log.error(cause.getMessage(),cause);
                return null;
            }

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

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

            @Override
            public ResultBean<Position> findListByPosition(PositionDto dto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> countByProjectId(Long projectId) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

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