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.AcceptanceDto;
import com.sptg.estate.api.entity.Acceptance;
import com.sptg.estate.api.feigns.AcceptanceFeign;
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 AcceptanceFeignFallbackFactory implements FallbackFactory<AcceptanceFeign> {

    @Override
    public AcceptanceFeign create(Throwable cause) {
        return new AcceptanceFeign() {

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

            @Override
            public ResultBean<Boolean> insert(AcceptanceDto 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<Page<Acceptance>> showList(AcceptanceDto acceptanceDto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> edit(Acceptance acceptance) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

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