package com.crunii.micro.feign.client.fallbackfactory;

import com.crunii.micro.common.dto.Result;
import com.crunii.micro.feign.client.StudyCenterService;
import com.crunii.micro.feign.client.dto.TestPaperVO;
import com.crunii.micro.feign.client.dto.YcqYjsCourseMgrResp;
import com.crunii.micro.feign.client.dto.YcqYjsSpecialMgr;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.math.BigInteger;
import java.util.List;

@Component
public class StudyCenterServiceFallbackFactory implements FallbackFactory<StudyCenterService> {
    private static final Logger logger = LoggerFactory.getLogger(StudyCenterServiceFallbackFactory.class);

    @Override
    public StudyCenterService create(Throwable cause) {
        logger.error("fallback; exception was: {}", cause.toString());
        logger.error("fallback; reason was: {}", cause.getMessage());
        return new StudyCenterService() {
            @Override
            public Result<List<YcqYjsCourseMgrResp>> queryCourseInfoBySpecialType(YcqYjsSpecialMgr ycqYjsSpecialMgr) {
                Result<List<YcqYjsCourseMgrResp>> result = new Result();
                result.setSuccess(false);
                result.setMsg("queryCourseInfoBySpecialType接口调用失败");
                return result;
            }

            @Override
            public Result<YcqYjsCourseMgrResp> queryById(BigInteger id) {
                Result<YcqYjsCourseMgrResp> result = new Result();
                result.setSuccess(false);
                result.setMsg("queryById接口调用失败");
                return result;
            }

            @Override
            public Result<TestPaperVO> getTestPaperInfo(Long id) {

                Result<TestPaperVO> result = new Result();
                result.setSuccess(false);
                result.setMsg("getTestPaperInfo接口调用失败");
                return result;
            }
        };
    }
}
