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

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.ExcelResultEnum;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.common.core.constant.OperationConstant;
import com.sptg.estate.api.dto.BuildingBatchAdd;
import com.sptg.estate.api.dto.BuildingDto;
import com.sptg.estate.api.entity.Building;
import com.sptg.estate.api.feigns.BuildingFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * title: BuildingFallbackFactory
 * package: com.sptg.estate.api.feigns.fallback
 * description: 楼栋 服务容错处理类
 *
 *
 *
 */
@Component
@Slf4j
public class BuildingFeignFallbackFactory implements FallbackFactory<BuildingFeign> {

    @Override
    public BuildingFeign create(Throwable cause) {
        return new BuildingFeign() {
            @Override
            public ResultBean<Page<Building>> showBuildingList(BuildingDto buildingDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Building> addBuilding(BuildingDto buildingDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public Building findBuildingById(Long id) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public ResultBean<Boolean> updateBuilding(BuildingDto buildingDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> deleteBuilding(BuildingDto buildingDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> trashOrRecover(BuildingDto buildingDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> deleteBuildingList(BuildingDto buildingDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Building> findListByPosition(BuildingDto buildingDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> importBuildingList(BuildingDto buildingDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ExcelResultEnum.ERROR);
            }

            @Override
            public ResultBean<Building> getByUnitId(Long unitId) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ExcelResultEnum.ERROR);
            }
            @Override
            public ResultBean<Map<String, Integer>> getBuildingAccount(BuildingDto buildingDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public List<Building> getListByBuildingId(List<Long> buildingIds) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public Page<Building> pagingByIds(BuildingDto buildingDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public int findBuildingByCondition(BuildingDto buildingDto) {
                log.error(cause.getMessage(),cause);
                return 0;
            }

            @Override
            public Building findBuildingByNameAndNumber(BuildingDto buildingDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public Building addBuildingByImport(Building building) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public boolean updateEntity(Building building) {
                log.error(cause.getMessage(),cause);
                return false;
            }

            @Override
            public boolean updateBuildingList(List<Building> buildingList) {
                log.error(cause.getMessage(),cause);
                return false;
            }

            @Override
            public List<Building> getListByLikeName(BuildingDto dto) {
                log.error(cause.getMessage(),cause);
                return new ArrayList<>(OperationConstant.ZERO);
            }

            @Override
            public Building getByOldId(String oldId) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public Building getByBuildingNumber(String houseNumber) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public List<Building> getListByCondition(BuildingDto buildingDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public boolean addBuildingBatch(BuildingBatchAdd batchAdd) {
                log.error(cause.getMessage(),cause);
                return false;
            }
        };
    }
}
