package com.usky.transfer.factory;

import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.exception.BusinessException;
import com.usky.transfer.RemoteTransferService;
import com.usky.transfer.domain.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;


/**
 * 用户服务降级处理
 *
 * @author ruoyi
 */
@Component
public class RemoteTransferFallbackFactory implements FallbackFactory<RemoteTransferService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteTransferFallbackFactory.class);

    @Override
    public RemoteTransferService create(Throwable throwable)
    {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteTransferService() {
            @Override
            public ApiResult<Void> sendDeviceData(DeviceDataWriteVO writeVO) {
                throw new BusinessException(throwable.getMessage());
            }
            @Override
            public ApiResult<Void> deleteProductCache() {
                throw new BusinessException(throwable.getMessage());
            }
            @Override
            public ApiResult<Void> deleteDeviceCache(String productCode) {
                throw new BusinessException(throwable.getMessage());
            }
            @Override
            public Map<String,Object> deviceControl(String productCode, String deviceUuid, String commandStr,Integer tenantId, Long userId, String userName) {
                throw new BusinessException(throwable.getMessage());
            }
        };
    }
}
