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

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

/**
 * @author lyx
 * @date 2024/1/17
 */
@Component
public class InterServiceFallbackFactory  implements FallbackFactory<InterService> {
	private static final Logger logger = LoggerFactory.getLogger(InterServiceFallbackFactory.class);

	@Override
	public InterService create(Throwable cause) {
		logger.error("fallback; exception was: {}", cause.toString());
		logger.error("fallback; reason was: {}", cause.getMessage());
		return new InterService() {
			@Override public Result<String> saveYkzUserInfo(LoginPhoneDto loginPhoneDto) {
				Result result = new Result();
				result.setSuccess(false);
				result.setMsg("saveYkzUserInfo接口调用失败");
				return result;
			}
		};
	}
}
