package com.sptg.third.api.feigns.grid.fallback;

import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.device.api.dto.DeviceDto;
import com.sptg.device.api.entity.Device;
import com.sptg.estate.api.entity.AccessRecords;
import com.sptg.third.api.feigns.grid.GridDoorDeviceFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * Created By lidexi in 2021/1/13
 **/
@Slf4j
@Component
public class GridDoorDeviceFeignFallbackFactory implements FallbackFactory<GridDoorDeviceFeign> {
    @Override
    public GridDoorDeviceFeign create(Throwable throwable) {
        return new GridDoorDeviceFeign() {
            @Override
            public ResultBean<String> gridDevicePush(Device device) {
                log.error(throwable.getMessage(),throwable);
                return new ResultBean<>(ResultEnum.ERROR,"操作失败");
            }

            @Override
            public ResultBean<String> gridAccessrecordPush(AccessRecords accessRecords) {
                log.error(throwable.getMessage(),throwable);
                return new ResultBean<>(ResultEnum.ERROR,"操作失败");
            }
        };
    }
}
