package com.sptg.video.cloud.api.feigns.fallback;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.PageBean;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.video.cloud.api.dto.VCDeviceDto;
import com.sptg.video.cloud.api.entity.VCDevice;
import com.sptg.video.cloud.api.feigns.VCDeviceFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

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

/**
 * @author zwx
 * @create 2020/10/16 11:57
 */
@Slf4j
@Component
public class VCDeviceFeignFallbackFactory implements FallbackFactory<VCDeviceFeign> {
    @Override
    public VCDeviceFeign create(Throwable cause) {
        return new VCDeviceFeign() {

            @Override
            public ResultBean<Page<VCDevice>> pagingQuery(PageBean<VCDevice, VCDeviceDto> pageBean) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR,pageBean);
            }

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

            @Override
            public VCDevice findDeviceByNum(String deviceNum) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public ResultBean<String> syncDeviceList(VCDeviceDto deviceDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> deviceGetDevUrl(VCDeviceDto deviceDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> devicePusher(VCDeviceDto deviceDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> mediaServerStreamOnline(VCDeviceDto vcDeviceDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> msAddFFmpegSource(VCDeviceDto vcDeviceDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> msDelFFmpegSource(VCDeviceDto vcDeviceDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> devicePusherStatus(VCDeviceDto deviceDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> devicePusherDelete(VCDeviceDto deviceDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> deviceGetHttpFlvUrl(VCDeviceDto deviceDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> syncDeviceDevUrlList(VCDeviceDto vcDeviceDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<List<VCDevice>> getList() {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> updateBatch(List<VCDevice> vcDeviceList) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> update(VCDevice vcDevice) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
