package com.sptg.iot.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.iot.api.dto.IotAlarmWorkOrderDto;
import com.sptg.iot.api.entity.IotAlarm;
import com.sptg.iot.api.entity.IotAlarmWorkOrder;
import com.sptg.iot.api.feigns.IotAlarmWorkOrderFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author zwx
 * @create 2020/10/19 23:33
 */
@Component
@Slf4j
public class IotDeviceWorkOrderFeignFallbackFactory implements FallbackFactory<IotAlarmWorkOrderFeign> {
    @Override
    public IotAlarmWorkOrderFeign create(Throwable cause) {
        return new IotAlarmWorkOrderFeign() {
            @Override
            public ResultBean<Page<IotAlarmWorkOrder>> showIotAlarmWorkOrderList(IotAlarmWorkOrderDto iotAlarmWorkOrderDto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> syncIotAlarmWorkOrderList(IotAlarmWorkOrderDto iotAlarmWorkOrderDto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> updateIotAlarmWorkOrder(IotAlarmWorkOrderDto iotAlarmWorkOrderDto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Page<IotAlarmWorkOrder>> pagingQuery(IotAlarmWorkOrderDto iotAlarmWorkOrderDto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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