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

import java.util.List;

/**
 * title: PositionFeignFallbackFactory
 * package: com.sptg.estate.api.feigns.fallback
 * description:设备检测-服务容错处理类
 *
 *               
 *                
 */
@Component
@Slf4j
public class DeviceTestFeignFallbackFactory implements FallbackFactory<DeviceTestFeign> {

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

            @Override
            public ResultBean<Page<DeviceTest>> showList(DeviceTestDto dto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<Boolean> checkState(DeviceTestDto 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<DeviceTest> findListByPosition(DeviceTestDto dto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<DeviceTest> findBySerialNumber(String serialNumber) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> insertEntity(DeviceTest deviceTest) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<DeviceTest> findByDeviceInstallationIds(List<Long> deviceInstallationIds) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
