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.VCApiLogDto;
import com.sptg.video.cloud.api.entity.VCApiLog;
import com.sptg.video.cloud.api.feigns.VCApiLogFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author zwx
 * @create 2020/10/17 16:14
 */
@Component
@Slf4j
public class VCApiLogFeignFallbackFactory implements FallbackFactory<VCApiLogFeign> {
    @Override
    public VCApiLogFeign create(Throwable cause) {
        return new VCApiLogFeign() {
            @Override
            public ResultBean<Page<VCApiLog>> pagingQuery(PageBean<VCApiLog, VCApiLogDto> pageBean) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR,pageBean);
            }

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