package com.yuchen.saas.device.api.feign;

import com.yuchen.saas.device.api.dto.*;
import com.yuchen.saas.device.api.entity.NetAlarmRecord;
import com.yuchen.saas.device.api.utils.SaasDeviceFeignFallbackUtils;
import com.yuchen.saas.device.api.vo.NetAlarmLevelStatisticsVO;
import com.yuchen.saas.device.api.vo.NetAlarmTrendVo;
import com.yuchen.saas.park.api.dto.park.IoTEvent;
import com.yuchen.saas.park.api.entity.fault.ConnectEvent;
import com.yuchen.saas.park.api.vo.fault.DeviceProperty;
import feign.hystrix.FallbackFactory;
import org.nest.springwrap.core.mp.support.NestPage;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author yuanzhelin
 * @Date 2024/9/26 18:42
 * @Description TODO
 */
@Component
public class NetAlarmFeignFallback implements FallbackFactory<NetAlarmFeign> {


    @Override
    public NetAlarmFeign create(Throwable throwable) {
        return new NetAlarmFeign() {
            @Override
            public R<Boolean> propertyAlarm(DeviceProperty deviceProperty) {
                return SaasDeviceFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<Boolean> connectAlarm(ConnectEvent connectEvent) {
                return SaasDeviceFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<Boolean> eventAlarm(IoTEvent event) {
                return SaasDeviceFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<Boolean> postServiceAlarmData(ServiceAlarmEvent serviceAlarmEvent) {
                return SaasDeviceFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<Boolean> postThirdPartyAlarmData(ThirdPartyAlarmEvent thirdPartyAlarmEvent) {
                return SaasDeviceFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<NestPage<NetAlarmRecord>> alarmRecordPage(NetAlarmRecordPageDto qryDto) {
                return SaasDeviceFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<NetAlarmLevelStatisticsVO> statistics(NetAlarmLevelStatisticsDto qryDto) {
                return SaasDeviceFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<List<NetAlarmTrendVo>> trend(NetAlarmTrendDto qryDto) {
                return SaasDeviceFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R close(NetAlarmCloseDto dto) {
                return SaasDeviceFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R dispatched(NetAlarmDeployDto dto) {
                return SaasDeviceFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<NetAlarmRecord> detail(Long id) {
                return SaasDeviceFeignFallbackUtils.printLogAndReturn(throwable);
            }
        };
    }
}
