package com.sptg.video.cloud.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.video.cloud.api.dto.FileInfoDto;
import com.sptg.video.cloud.api.entity.FileInfo;
import com.sptg.video.cloud.api.feigns.FileInfoFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author zwx
 * @create 2020/10/18 20:47
 */
@Slf4j
@Component
public class FileInfoFeignFallbackFactory implements FallbackFactory<FileInfoFeign> {
    @Override
    public FileInfoFeign create(Throwable cause) {
        return new FileInfoFeign() {
            @Override
            public ResultBean<Page<FileInfo>> showFileInfoList(FileInfoDto fileInfoDto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<Boolean> syncFileInfoList(FileInfoDto fileInfoDto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
