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.SysOperationLogDto;
import com.sptg.statistics.api.entity.SysOperationLog;
import com.sptg.statistics.api.feigns.SysOperationLogFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * title: SysOpeartionLogFeignFallbackFactory
 * package: com.sptg.statistics.api.feigns.fallback
 * description: 系统操作日志服务容错处理
 *
 *                
 *                
 */
@Component
@Slf4j
public class SysOpeartionLogFeignFallbackFactory implements FallbackFactory<SysOperationLogFeign> {


    @Override
    public SysOperationLogFeign create(Throwable cause) {
        return new SysOperationLogFeign(){
            @Override
            public ResultBean<Page<SysOperationLog>> showSysOperationLogList(SysOperationLogDto solDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<Boolean> addSysOperationLog(SysOperationLog sysOperationLog) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public  ResultBean<Boolean> info(List<SysOperationLog> sysOperationLogs) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public  ResultBean<Boolean> info(SysOperationLog sysOperationLog) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };

    }
}
