parent
7c2e1b684d
commit
f2a6a46d29
@ -0,0 +1,26 @@
|
|||||||
|
package com.ruoyi.system.api;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.system.api.factory.RemoteConfigFallbackFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统配置服务
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-02-20
|
||||||
|
*/
|
||||||
|
@FeignClient(contextId = "remoteConfigService",
|
||||||
|
value = ServiceNameConstants.SYSTEM_SERVICE,
|
||||||
|
fallbackFactory = RemoteConfigFallbackFactory.class)
|
||||||
|
public interface RemoteConfigService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据参数键名查询参数值
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/config/configKeyForRPC/{configKey}")
|
||||||
|
R<String> getConfigKeyForRPC(@PathVariable("configKey") String configKey);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.ruoyi.system.api.factory;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.system.api.RemoteConfigService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-02-20
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Log4j2
|
||||||
|
public class RemoteConfigFallbackFactory implements FallbackFactory<RemoteConfigService> {
|
||||||
|
@Override
|
||||||
|
public RemoteConfigService create(Throwable cause) {
|
||||||
|
return new RemoteConfigService() {
|
||||||
|
@Override
|
||||||
|
public R<String> getConfigKeyForRPC(String configKey) {
|
||||||
|
log.error("系统配置服务调用失败:{}", cause.getMessage());
|
||||||
|
return R.fail("系统配置服务调用失败");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||||
com.ruoyi.system.api.factory.RemoteUserFallbackFactory,\
|
com.ruoyi.system.api.factory.RemoteUserFallbackFactory,\
|
||||||
com.ruoyi.system.api.factory.RemoteLogFallbackFactory, \
|
com.ruoyi.system.api.factory.RemoteLogFallbackFactory, \
|
||||||
com.ruoyi.system.api.factory.RemoteFileFallbackFactory
|
com.ruoyi.system.api.factory.RemoteFileFallbackFactory,\
|
||||||
|
com.ruoyi.system.api.factory.RemoteConfigFallbackFactory
|
||||||
|
Loading…
Reference in new issue