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.RoomDto;
import com.sptg.estate.api.entity.Room;
import com.sptg.estate.api.entity.Unit;
import com.sptg.estate.api.feigns.RoomFeign;
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: RoomFallbackFactory
 * package: com.sptg.estate.api.feigns.fallback
 * description: 房间 服务容错处理类
 *
 *
 *
 */
@Component
@Slf4j
public class RoomFeignFallbackFactory implements FallbackFactory<RoomFeign> {

    @Override
    public RoomFeign create(Throwable cause) {
        return new RoomFeign() {
            @Override
            public ResultBean<Page<Room>> showRoomList(RoomDto roomDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Room> addRoom(RoomDto roomDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<Boolean> updateRoom(RoomDto roomDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> deleteRoom(RoomDto roomDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<Boolean> deleteRoomList(RoomDto roomDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Room> findListByPosition(RoomDto roomDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> importRoomList(RoomDto roomDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ExcelResultEnum.ERROR);
            }

            @Override
            public ResultBean<Room> getByUnitId(Long unitId) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ExcelResultEnum.ERROR);
            }
            @Override
            public ResultBean<Map<String, Integer>> getRoomAccount(RoomDto roomDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public List<Room> getListByRoomId(List<Long> roomIds) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public Page<Room> pagingByIds(RoomDto roomDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public int findRoomByCondition(RoomDto roomDto) {
                log.error(cause.getMessage(),cause);
                return 0;
            }

            @Override
            public Room findRoomByNameAndNumber(RoomDto roomDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public Room addRoomByImport(Room room) {
                log.error(cause.getMessage(),cause);
                return null;
            }

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

            @Override
            public boolean updateRoomList(List<Room> roomList) {
                log.error(cause.getMessage(),cause);
                return false;
            }

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

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

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

            @Override
            public List<Room> getListByCondition(RoomDto roomDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

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

            @Override
            public int addRoomSync(Room room) {
                log.error(cause.getMessage(),cause);
                return 0;
            }
        };
    }
}
