package com.sptg.device.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.common.core.constant.OperationConstant;
import com.sptg.device.api.dto.DevicePathDto;
import com.sptg.device.api.dto.DeviceRemoteInfoDto;
import com.sptg.device.api.entity.DevicePath;
import com.sptg.device.api.entity.DeviceRemoteInfo;
import com.sptg.device.api.feigns.DevicePathFeign;
import com.sptg.device.api.feigns.DeviceRemoteInfoFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * title: DevicePathFeignFallbackFactory
 * package: com.sptg.device.api.feigns.fallback
 * description:设备位置对外服务接口容错处理
 */
@Component
@Slf4j
public class DeviceRemoteInfoFeignFallbackFactory implements FallbackFactory<DeviceRemoteInfoFeign> {

    @Override
    public DeviceRemoteInfoFeign create(Throwable cause) {
        return new DeviceRemoteInfoFeign() {
            @Override
            public ResultBean<Page> pagingQuery(DeviceRemoteInfoDto dto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> add(DeviceRemoteInfoDto dto) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public DeviceRemoteInfo findDeviceRemoteInfo(DeviceRemoteInfoDto dto) {
                log.error(cause.getMessage());
                return null;
            }

            @Override
            public DeviceRemoteInfo getBySerialNumber(String serialNumber) {
                log.error(cause.getMessage());
                return null;
            }

            @Override
            public DeviceRemoteInfo getById(Long id) {
                log.error(cause.getMessage());
                return null;
            }

            @Override
            public ResultBean<Boolean> edit(DeviceRemoteInfo deviceRemoteInfo) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> delete(DeviceRemoteInfoDto dto) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
