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.estate.api.dto.FloorDto;
import com.sptg.estate.api.entity.Floor;
import com.sptg.estate.api.feigns.FloorFeign;
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: FloorFallbcakFactory
 * package: com.sptg.estate.api.feigns.fallback
 * description: 楼层 服务容错处理类
 *
 *
 *
 */
@Component
@Slf4j
public class FloorFeignFallbackFactory implements FallbackFactory<FloorFeign> {

    @Override
    public FloorFeign create(Throwable cause) {
        return new FloorFeign() {
            @Override
            public ResultBean<Page<Floor>> showFloorList(FloorDto floorDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<FloorDto> addFloor(FloorDto floorDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

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

            @Override
            public ResultBean<Boolean> updateFloor(FloorDto floorDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> deleteFloor(FloorDto floorDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<Boolean> deleteFloorList(FloorDto floorDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Floor> findListByPosition(FloorDto floorDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public  ResultBean<Floor> findListByPid(FloorDto floorDto) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public List<Floor> getListByXqId(Long xqId) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ArrayList<>(0);
            }

            @Override
            public List<Floor> getListByIdList(List<Long> dyIdList) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return null;
            }

            @Override
            public ResultBean<Boolean> importFloorList(FloorDto floorDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ExcelResultEnum.ERROR);
            }

            @Override
            public ResultBean<Map<String, Integer>> getFloorAccount(FloorDto floorDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public int getFloorCount(FloorDto floorDto) {
                log.error(cause.getMessage(),cause);
                return 0;
            }

            @Override
            public int findFloorByCondition(FloorDto floorDto) {
                log.error(cause.getMessage(),cause);
                return 0;
            }

            @Override
            public Floor findFloorByNameAndNumber(FloorDto floorDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public Floor getByFloorNumberAndXqId(Long xqId, String floorNumber) {
                log.error(cause.getMessage(),cause);
                return null;
            }

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

            @Override
            public boolean updateFloorList(List<Floor> floorList) {
                log.error(cause.getMessage(),cause);
                return false;
            }

            @Override
            public List<Floor> getListByLikeName(FloorDto dto) {
                log.error(ResultEnum.ERROR.getCode(),cause);
                return new ArrayList<>(0);
            }

            @Override
            public Floor addFloorByImport(Floor floor) {
                log.error(cause.getMessage(),cause);
                return null;
            }

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

            @Override
            public Floor getByFloorNumber(String floorNumber) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public List<Floor> getFloorByUnitId(Long unitId) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public List<Floor> getListByCondition(FloorDto floorDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public int addFloorSync(Floor floor) {
                log.error(cause.getMessage(),cause);
                return 0;
            }
        };
    }
}
