2025-12-02 18:46:03 +08:00
|
|
|
|
server:
|
2025-12-05 15:34:02 +08:00
|
|
|
|
port: 8180
|
2025-12-02 18:46:03 +08:00
|
|
|
|
|
|
|
|
|
|
spring:
|
|
|
|
|
|
application:
|
|
|
|
|
|
name: gateway-service
|
|
|
|
|
|
|
2025-12-05 15:34:02 +08:00
|
|
|
|
# Gateway 必须使用 reactive 模式(WebFlux),不能使用 Spring MVC
|
|
|
|
|
|
main:
|
|
|
|
|
|
web-application-type: reactive
|
|
|
|
|
|
|
2025-12-02 18:46:03 +08:00
|
|
|
|
# 配置中心
|
|
|
|
|
|
cloud:
|
|
|
|
|
|
nacos:
|
|
|
|
|
|
discovery:
|
|
|
|
|
|
server-addr: ${NACOS_SERVER_ADDR:localhost:8848}
|
|
|
|
|
|
namespace: dev
|
|
|
|
|
|
group: DEFAULT_GROUP
|
|
|
|
|
|
config:
|
|
|
|
|
|
server-addr: ${NACOS_SERVER_ADDR:localhost:8848}
|
|
|
|
|
|
file-extension: yml
|
|
|
|
|
|
namespace: dev
|
|
|
|
|
|
group: DEFAULT_GROUP
|
|
|
|
|
|
|
2025-12-05 15:34:02 +08:00
|
|
|
|
# Gateway 路由配置(使用新的 webflux 配置路径)
|
2025-12-02 18:46:03 +08:00
|
|
|
|
gateway:
|
2025-12-05 15:34:02 +08:00
|
|
|
|
server:
|
|
|
|
|
|
webflux:
|
|
|
|
|
|
# 服务发现路由(自动路由)
|
|
|
|
|
|
discovery:
|
|
|
|
|
|
locator:
|
|
|
|
|
|
enabled: false # 关闭自动路由,使用手动配置
|
|
|
|
|
|
|
|
|
|
|
|
# 手动配置路由
|
|
|
|
|
|
routes:
|
|
|
|
|
|
# ==================== 认证服务路由 ====================
|
|
|
|
|
|
- id: auth-service
|
|
|
|
|
|
uri: lb://auth-service
|
|
|
|
|
|
predicates:
|
2025-12-11 14:21:36 +08:00
|
|
|
|
- Path=/urban-lifeline/auth/**
|
2025-12-05 15:34:02 +08:00
|
|
|
|
filters:
|
2025-12-11 14:21:36 +08:00
|
|
|
|
# 不需要重写,直接转发保持原路径
|
2025-12-05 15:34:02 +08:00
|
|
|
|
- name: RequestRateLimiter
|
|
|
|
|
|
args:
|
|
|
|
|
|
redis-rate-limiter.replenishRate: 100
|
|
|
|
|
|
redis-rate-limiter.burstCapacity: 200
|
|
|
|
|
|
|
|
|
|
|
|
# ==================== 系统服务路由 ====================
|
|
|
|
|
|
- id: system-service
|
|
|
|
|
|
uri: lb://system-service
|
|
|
|
|
|
predicates:
|
2025-12-11 14:21:36 +08:00
|
|
|
|
- Path=/urban-lifeline/system/**
|
2025-12-05 15:34:02 +08:00
|
|
|
|
|
|
|
|
|
|
# ==================== 日志服务路由 ====================
|
|
|
|
|
|
- id: log-service
|
|
|
|
|
|
uri: lb://log-service
|
|
|
|
|
|
predicates:
|
2025-12-11 14:21:36 +08:00
|
|
|
|
- Path=/urban-lifeline/log/**
|
2025-12-05 15:34:02 +08:00
|
|
|
|
|
|
|
|
|
|
# ==================== 文件服务路由 ====================
|
|
|
|
|
|
- id: file-service
|
|
|
|
|
|
uri: lb://file-service
|
|
|
|
|
|
predicates:
|
2025-12-11 14:21:36 +08:00
|
|
|
|
- Path=/urban-lifeline/file/**
|
2025-12-05 15:34:02 +08:00
|
|
|
|
|
|
|
|
|
|
# ==================== 消息服务路由 ====================
|
|
|
|
|
|
- id: message-service
|
|
|
|
|
|
uri: lb://message-service
|
|
|
|
|
|
predicates:
|
2025-12-11 14:21:36 +08:00
|
|
|
|
- Path=/urban-lifeline/message/**
|
2025-12-05 15:34:02 +08:00
|
|
|
|
|
|
|
|
|
|
# ==================== 招投标服务路由 ====================
|
|
|
|
|
|
- id: bidding-service
|
|
|
|
|
|
uri: lb://bidding-service
|
|
|
|
|
|
predicates:
|
2025-12-11 14:21:36 +08:00
|
|
|
|
- Path=/urban-lifeline/bidding/**
|
2025-12-05 15:34:02 +08:00
|
|
|
|
|
|
|
|
|
|
# ==================== 平台服务路由 ====================
|
|
|
|
|
|
- id: platform-service
|
|
|
|
|
|
uri: lb://platform-service
|
|
|
|
|
|
predicates:
|
2025-12-11 14:21:36 +08:00
|
|
|
|
- Path=/urban-lifeline/platform/**
|
2025-12-05 15:34:02 +08:00
|
|
|
|
|
|
|
|
|
|
# ==================== 工单服务路由 ====================
|
|
|
|
|
|
- id: workcase-service
|
|
|
|
|
|
uri: lb://workcase-service
|
|
|
|
|
|
predicates:
|
2025-12-11 14:21:36 +08:00
|
|
|
|
- Path=/urban-lifeline/workcase/**
|
2025-12-05 15:34:02 +08:00
|
|
|
|
|
|
|
|
|
|
# ==================== 定时任务服务路由 ====================
|
|
|
|
|
|
- id: crontab-service
|
|
|
|
|
|
uri: lb://crontab-service
|
|
|
|
|
|
predicates:
|
2025-12-11 14:21:36 +08:00
|
|
|
|
- Path=/urban-lifeline/crontab/**
|
2025-12-05 15:34:02 +08:00
|
|
|
|
|
|
|
|
|
|
# ==================== AI Agent 服务路由 ====================
|
|
|
|
|
|
- id: agent-service
|
|
|
|
|
|
uri: lb://agent-service
|
|
|
|
|
|
predicates:
|
2025-12-11 14:21:36 +08:00
|
|
|
|
- Path=/urban-lifeline/agent/**
|
2025-12-05 15:34:02 +08:00
|
|
|
|
|
|
|
|
|
|
# 全局跨域配置
|
|
|
|
|
|
globalcors:
|
|
|
|
|
|
cors-configurations:
|
|
|
|
|
|
'[/**]':
|
|
|
|
|
|
allowedOriginPatterns: "*"
|
|
|
|
|
|
allowedMethods:
|
|
|
|
|
|
- GET
|
|
|
|
|
|
- POST
|
|
|
|
|
|
- PUT
|
|
|
|
|
|
- DELETE
|
|
|
|
|
|
- OPTIONS
|
|
|
|
|
|
allowedHeaders: "*"
|
|
|
|
|
|
allowCredentials: true
|
|
|
|
|
|
maxAge: 3600
|
|
|
|
|
|
datasource:
|
|
|
|
|
|
# 按你的实际库名改一下,比如 urban-lifeline_system
|
|
|
|
|
|
url: jdbc:postgresql://127.0.0.1:5432/urban_lifeline # 换成你的 PG 库名
|
|
|
|
|
|
username: postgres # PG 用户
|
|
|
|
|
|
password: postgres # PG 密码
|
|
|
|
|
|
driver-class-name: org.postgresql.Driver
|
2025-12-02 18:46:03 +08:00
|
|
|
|
# Redis 配置(用于限流、缓存)
|
|
|
|
|
|
data:
|
|
|
|
|
|
redis:
|
|
|
|
|
|
host: ${REDIS_HOST:localhost}
|
|
|
|
|
|
port: ${REDIS_PORT:6379}
|
2025-12-05 15:34:02 +08:00
|
|
|
|
password: 123456
|
2025-12-02 18:46:03 +08:00
|
|
|
|
database: 0
|
|
|
|
|
|
timeout: 5000ms
|
|
|
|
|
|
lettuce:
|
|
|
|
|
|
pool:
|
|
|
|
|
|
max-active: 20
|
|
|
|
|
|
max-wait: -1ms
|
|
|
|
|
|
max-idle: 10
|
|
|
|
|
|
min-idle: 5
|
|
|
|
|
|
|
|
|
|
|
|
# 认证配置
|
|
|
|
|
|
auth:
|
|
|
|
|
|
enabled: true
|
2025-12-05 15:34:02 +08:00
|
|
|
|
gateway-mode: true
|
2025-12-02 18:46:03 +08:00
|
|
|
|
token-header: Authorization
|
|
|
|
|
|
token-prefix: "Bearer "
|
|
|
|
|
|
# 认证接口白名单(login/logout/captcha/refresh)
|
2025-12-05 18:24:21 +08:00
|
|
|
|
login-path: /urban-lifeline/auth/login
|
|
|
|
|
|
logout-path: /urban-lifeline/auth/logout
|
|
|
|
|
|
captcha-path: /urban-lifeline/auth/captcha
|
|
|
|
|
|
refresh-path: /urban-lifeline/auth/refresh
|
2025-12-02 18:46:03 +08:00
|
|
|
|
# 通用白名单(Swagger、健康检查等)
|
|
|
|
|
|
whitelist:
|
|
|
|
|
|
- /actuator/**
|
|
|
|
|
|
- /v3/api-docs/**
|
|
|
|
|
|
- /swagger-ui/**
|
|
|
|
|
|
- /swagger-resources/**
|
|
|
|
|
|
- /webjars/**
|
|
|
|
|
|
- /doc.html
|
|
|
|
|
|
- /favicon.ico
|
|
|
|
|
|
- /error
|
2025-12-05 18:24:21 +08:00
|
|
|
|
security:
|
|
|
|
|
|
aes:
|
2025-12-11 14:21:36 +08:00
|
|
|
|
secret-key: MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI= # Base64 编码,32字节(256位)
|
2025-12-02 18:46:03 +08:00
|
|
|
|
# Actuator 监控端点
|
|
|
|
|
|
management:
|
|
|
|
|
|
endpoints:
|
|
|
|
|
|
web:
|
|
|
|
|
|
exposure:
|
|
|
|
|
|
include: health,info,gateway
|
|
|
|
|
|
endpoint:
|
|
|
|
|
|
health:
|
|
|
|
|
|
show-details: always
|
|
|
|
|
|
|
2025-12-05 15:34:02 +08:00
|
|
|
|
# 日志配置(详细配置见 log4j2.xml)
|
2025-12-02 18:46:03 +08:00
|
|
|
|
logging:
|
2025-12-05 15:34:02 +08:00
|
|
|
|
config: classpath:log4j2.xml
|
|
|
|
|
|
charset:
|
|
|
|
|
|
console: UTF-8
|
|
|
|
|
|
file: UTF-8
|