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

/**
 * @author zwx
 * @create 2020/10/18 16:09
 */
@Slf4j
@Component
public class PresetInfoFeignFallbackFactory implements FallbackFactory<PresetInfoFeign> {

    @Override
    public PresetInfoFeign create(Throwable cause) {
        return new PresetInfoFeign() {
            @Override
            public ResultBean<Page<PresetInfo>> showPresetInfoList(PresetInfoDto presetInfoDto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<Boolean> syncPresetInfoList(PresetInfoDto presetInfoDto) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
