增加门店服务路由配置

This commit is contained in:
2025-07-09 00:07:36 +08:00
parent 040a57187f
commit c359157826
5 changed files with 53 additions and 10 deletions

View File

@ -0,0 +1,20 @@
package com.sczx.gateway.component;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.gateway.event.RefreshRoutesEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class DynamicRouteScheduler {
@Autowired
private ApplicationEventPublisher publisher;
// 每30秒刷新一次路由可按需调整
@Scheduled(fixedRate = 30_000)
public void refreshRoutes() {
publisher.publishEvent(new RefreshRoutesEvent(this));
}
}