服务打包初步结构

This commit is contained in:
2026-01-02 14:56:14 +08:00
parent 19026c1b30
commit 89bc8bf1d4
77 changed files with 5290 additions and 2070 deletions

View File

@@ -1,12 +0,0 @@
# 开发环境专用配置
# 注意不要在这里配置routes会覆盖application.yml的配置
# 路由配置统一在application.yml中管理
# 开发环境日志
logging:
config: classpath:log4j2.xml
charset:
console: UTF-8
file: UTF-8
level:
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping: TRACE

View File

@@ -1,50 +1,40 @@
# ================== Gateway 服务配置 ==================
server:
port: 8180
port: 8080
spring:
application:
name: gateway-service
# Gateway 必须使用 reactive 模式WebFlux不能使用 Spring MVC
# Gateway 必须使用 reactive 模式
main:
web-application-type: reactive
# 配置中心
cloud:
nacos:
discovery:
server-addr: ${NACOS_SERVER_ADDR:localhost:8848}
namespace: dev
group: DEFAULT_GROUP
config:
enabled: false # 禁用Nacos配置中心使用本地配置
server-addr: ${NACOS_SERVER_ADDR:localhost:8848}
file-extension: yml
namespace: dev
group: DEFAULT_GROUP
enabled: false
# Gateway 路由配置
gateway:
# 服务发现路由(自动路由)
discovery:
locator:
enabled: false # 关闭自动路由,使用手动配置
enabled: false
# 手动配置路由
routes:
# ==================== 认证服务路由 ====================
# 认证服务
- id: auth-service
uri: lb://auth-service
predicates:
- Path=/urban-lifeline/auth/**
filters:
- StripPrefix=1 # 去掉前缀:/urban-lifeline/auth/login → /auth/login
- StripPrefix=1
- name: RequestRateLimiter
args:
redis-rate-limiter.replenishRate: 100
redis-rate-limiter.burstCapacity: 200
# ==================== 系统服务路由 ====================
# 系统服务
- id: system-service
uri: lb://system-service
predicates:
@@ -52,7 +42,7 @@ spring:
filters:
- StripPrefix=1
# ==================== 日志服务路由 ====================
# 日志服务
- id: log-service
uri: lb://log-service
predicates:
@@ -60,7 +50,7 @@ spring:
filters:
- StripPrefix=1
# ==================== 文件服务路由 ====================
# 文件服务
- id: file-service
uri: lb://file-service
predicates:
@@ -68,7 +58,7 @@ spring:
filters:
- StripPrefix=1
# ==================== 消息服务路由 ====================
# 消息服务
- id: message-service
uri: lb://message-service
predicates:
@@ -76,7 +66,7 @@ spring:
filters:
- StripPrefix=1
# ==================== 招投标服务路由 ====================
# 招投标服务
- id: bidding-service
uri: lb://bidding-service
predicates:
@@ -84,7 +74,7 @@ spring:
filters:
- StripPrefix=1
# ==================== 平台服务路由 ====================
# 平台服务
- id: platform-service
uri: lb://platform-service
predicates:
@@ -92,7 +82,7 @@ spring:
filters:
- StripPrefix=1
# ==================== 工单服务 WebSocket 路由 ====================
# 工单服务 WebSocket
- id: workcase-websocket
uri: lb:ws://workcase-service
predicates:
@@ -100,7 +90,7 @@ spring:
filters:
- StripPrefix=1
# ==================== 工单服务路由 ====================
# 工单服务
- id: workcase-service
uri: lb://workcase-service
predicates:
@@ -108,7 +98,7 @@ spring:
filters:
- StripPrefix=1
# ==================== 定时任务服务路由 ====================
# 定时任务服务
- id: crontab-service
uri: lb://crontab-service
predicates:
@@ -116,7 +106,7 @@ spring:
filters:
- StripPrefix=1
# ==================== AI 服务路由 ====================
# AI 服务
- id: ai-service
uri: lb://ai-service
predicates:
@@ -129,28 +119,14 @@ spring:
cors-configurations:
'[/**]':
allowedOriginPatterns: "*"
allowedMethods:
- GET
- POST
- PUT
- DELETE
- OPTIONS
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
# Redis 配置(用于限流、缓存)
# Redis 连接池配置Gateway 限流用)
data:
redis:
host: ${REDIS_HOST:localhost}
port: ${REDIS_PORT:6379}
password: 123456
database: 0
timeout: 5000ms
lettuce:
pool:
@@ -159,18 +135,15 @@ spring:
max-idle: 10
min-idle: 5
# 认证配置
# ================== Gateway 认证配置 ==================
auth:
enabled: true
# gateway-mode 是给下游微服务用的gateway本身不需要此配置
token-header: Authorization
token-prefix: "Bearer "
# 认证接口白名单login/logout/captcha/refresh
login-path: /urban-lifeline/auth/login
logout-path: /urban-lifeline/auth/logout
captcha-path: /urban-lifeline/auth/captcha
refresh-path: /urban-lifeline/auth/refresh
# 通用白名单Swagger、健康检查等
whitelist:
- /actuator/**
- /v3/api-docs/**
@@ -180,20 +153,14 @@ auth:
- /doc.html
- /favicon.ico
- /error
# 各服务的 Swagger 文档
- /urban-lifeline/*/v3/api-docs/**
- /urban-lifeline/*/swagger-ui/**
# file 服务白名单
- /urban-lifeline/file/download/**
# ai 服务白名单
- /urban-lifeline/ai/chat/**
- /urban-lifeline/system/guest/identify
# workcase 会议入口白名单支持URL参数token认证
- /urban-lifeline/workcase/meeting/*/entry
security:
aes:
secret-key: MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI= # Base64 编码32字节256位
# Actuator 监控端点
# ================== Actuator ==================
management:
endpoints:
web:
@@ -202,12 +169,3 @@ management:
endpoint:
health:
show-details: always
# 日志配置(详细配置见 log4j2.xml
logging:
config: classpath:log4j2.xml
charset:
console: UTF-8
file: UTF-8
level:
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping: TRACE