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

import com.crunii.micro.common.dto.Result;
import com.crunii.micro.feign.client.OneAffairService;
import com.crunii.micro.feign.client.dto.StudentDetailVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

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

    @Override
    public OneAffairService create(Throwable cause) {
        logger.error("fallback; exception was: {}", cause.toString());
        logger.error("fallback; reason was: {}", cause.getMessage());

        return new OneAffairService() {

            @Override
            public Result<StudentDetailVo> selectStudentByIdentityCardNo(String identityCardNo) {
                Result<StudentDetailVo> result = new Result();
                result.setSuccess(false);
                result.setMsg("selectStudentByIdentityCardNo接口调用失败");
                return result;
            }

        };
    }
}
