package com.sptg.statistics.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.statistics.api.dto.SysDeviceLogDto;
import com.sptg.statistics.api.entity.SysDeviceLog;
import com.sptg.statistics.api.feigns.SysDeviceLogFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

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

/**
 * title: SysAdviceLogFeignFallbackFactory
 * package: com.sptg.statistics.api.feigns.fallback
 * description: 机器事件日志服务容错处理
 *
 *                
 *                
 */
@Component
@Slf4j
public class SysDeviceLogFeignFallbackFactory implements FallbackFactory<SysDeviceLogFeign> {


    @Override
    public SysDeviceLogFeign create(Throwable cause) {
        return new SysDeviceLogFeign(){
            @Override
            public ResultBean<Page<SysDeviceLog>> showSysDeviceLogList(SysDeviceLogDto sdlDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<Boolean> addSysDeviceLog(SysDeviceLog sysDeviceLog) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<Boolean> info(List<SysDeviceLog> sysDeviceLogs) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<Boolean> info(SysDeviceLog sysDeviceLog) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<List<Map<String, Object>>> statisticsDeviceMalfunction(SysDeviceLogDto sysDeviceLogDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<List<Map<String, Object>>> getDeviceFaultCountList(SysDeviceLogDto sysDeviceLogDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<List<Map<String, Object>>> deviceRankForArea(SysDeviceLogDto sysDeviceLogDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };

    }
}
