package com.yida.data.user.fallback;

import com.yida.data.common.core.annotation.Fallback;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.user.EduCourse;
import com.yida.data.user.feign.RemoteCourseService;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

/**
 * RemoteCourseService fallback处理类
 *
 * @author ZYJ
 * @date 2022/8/26
 */
@Slf4j
@Fallback
public class RemoteCourseServiceFallback implements FallbackFactory<RemoteCourseService> {

    @Override
    public RemoteCourseService create(Throwable throwable) {
        log.error("RemoteCourseService fallback reason:{}", throwable.getMessage());

        return new RemoteCourseService() {
            /**
             * 调用通知接口
             *
             * @param schoolId
             */
            @Override
            public ResultBean initCourse(Long schoolId) {
                return null;
            }

            /**
             * 根据名称查询科目
             *
             * @param courseName
             * @param schoolId
             */
            @Override
            public ResultBean<EduCourse> getCourseByName(String courseName, Long schoolId) {
                return null;
            }
        };
    }
}
