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.ProjectDto;
import com.sptg.estate.api.entity.Project;
import com.sptg.estate.api.feigns.ProjectFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * title: ProjectFeignFallbackFactory
 * package: com.sptg.estate.biz.security
 * description: 实施项目-服务容错处理类
 *
 *               
 *                     
 */
@Component
@Slf4j
public class ProjectFeignFallbackFactory implements FallbackFactory<ProjectFeign> {
    @Override
    public ProjectFeign create(Throwable cause) {
        return new ProjectFeign() {
            @Override
            public ResultBean<Page<Project>> showList(ProjectDto projectDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Page<Project>> showListInstallation(ProjectDto projectDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Page<Project>> showListTest(ProjectDto projectDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Project> findByResidentialId(Long residentialId) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<Boolean> updateById(Project project) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

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

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

            @Override
            public ResultBean<Project> findListByPosition(ProjectDto projectDto) {
                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> insertProjectAndContract(ProjectDto dto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public List<Project> findListByXqIds(List<Long> idList) {
                log.error(cause.getMessage(),cause);
                return null;
            }
        };
    }
}
