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.AlarmNoticeDto;
import com.sptg.iot.api.dto.IotAlarmDto;
import com.sptg.iot.api.dto.IotSmsSendDto;
import com.sptg.iot.api.entity.IotAlarm;
import com.sptg.iot.api.feigns.IotAlarmFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author zwx
 * @create 2020/10/19 23:33
 */
@Component
@Slf4j
public class IotAlarmFeignFallbackFactory implements FallbackFactory<IotAlarmFeign> {
    @Override
    public IotAlarmFeign create(Throwable cause) {
        return new IotAlarmFeign() {
            @Override
            public ResultBean<Page<IotAlarm>> showIotAlarmList(IotAlarmDto iotAlarmDto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<String> syncIotAlarmList(IotAlarmDto iotDeviceAlarmDto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> syncIotAlarmDetailOne(IotAlarmDto iotAlarmDto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> syncIotAlarmDetailBatch(List<IotAlarmDto> iotAlarmDtoList) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> syncIotAlarmDetailAll(IotAlarmDto iotAlarmDto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public IotAlarm getIotAlarmByAlarmId(String alarmId) {
                log.error(cause.getMessage(), cause);
                return null;
            }

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

            @Override
            public ResultBean<String> alarmNotice(List<AlarmNoticeDto> alarmNoticeDtoList) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> addAlarm(IotAlarmDto iotAlarmDto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> alarmSendSms(IotSmsSendDto iotSmsSendDto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
