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

/**
 * @author zwx
 * @create 2020/10/18 17:01
 */
@Slf4j
@Component
public class CruiseInfoFeignFallbackFactory implements FallbackFactory<CruiseInfoFeign> {
    @Override
    public CruiseInfoFeign create(Throwable cause) {
        return new CruiseInfoFeign() {
            @Override
            public ResultBean<Page<CruiseInfo>> showCruiseInfoList(CruiseInfoDto cruiseInfoDto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<Boolean> syncCruiseInfoList(CruiseInfoDto cruiseInfoDto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
