Appearance
micro-java 架构与请求链路
整体拓扑
text
contracts/openapi + schema.sql
│
▼
┌─────────────────────────────────────────────┐
│ gateway (:8080) │
│ Spring Cloud Gateway + Resilience4j │
│ /api/v1/auth/** → auth-service │
│ /api/v1/system/** → system-service │
│ /api/v1/monitor/** → monitor-service │
└──────┬──────────────┬──────────────┬──────┘
│ │ │
Nacos 服务发现 │ │
│ │ │
┌───────────▼──┐ ┌────────▼────────┐ ┌──▼──────────────┐
│ auth-service │ │ system-service │ │ monitor-service │
│ (:8081) │ │ (:8082) │ │ (:8083) │
│ 登录/Token │ │ RBAC+平台+init │ │ 日志+Quartz │
│ 写登录日志 │ │ Seata / MQ │ │ │
└──────┬───────┘ └────────┬─────────┘ └────────┬────────┘
└───────────────────┼─────────────────────┘
▼
MySQL (:3306)模块职责
xichen-domain
19 个 Entity、对应 Mapper、auth/system/monitor DTO。被 common 与各业务服务依赖。
xichen-common
JWT、Security、ApiResponse、OperLog AOP、CustomUserDetailsService。被三个业务服务 @Import。
auth-service
/api/v1/auth/*、/api/v1/health- 直连 MySQL;登录日志 写入(
SysLogininforService)
system-service
/api/v1/system/*— 12 个 Controller(RBAC + 平台 + database init)spring.datasource直连 MySQLUserEventPublisher(RabbitMQ/Kafka)assignRoles— Seata@GlobalTransactional
详见 System。
monitor-service
/api/v1/monitor/*— 操作/登录日志、定时任务- Quartz 启动加载
sys_job - 登录日志 只读管理(写入在 auth-service)
详见 Monitor。
gateway
- 对外 8080;不做 JWT 校验
- Resilience4j 熔断 + GET 重试 →
/fallback
前端登录时序
mermaid
sequenceDiagram
participant F as admin 前端
participant G as gateway :8080
participant A as auth-service
participant S as system-service
participant M as monitor-service
participant DB as MySQL
F->>G: POST /api/v1/auth/login
G->>A: 转发
A->>DB: 校验用户、写 logininfor
A-->>F: LoginResponse
F->>G: GET /api/v1/system/users (Bearer)
G->>S: 转发 + JWT 校验
F->>G: GET /api/v1/monitor/operlogs (Bearer)
G->>M: 转发 + JWT 校验网关路由表
| 路由 id | 路径 | 目标 |
|---|---|---|
| auth-service | /api/v1/auth/**、/api/v1/health | lb://auth-service |
| system-service | /api/v1/system/** | lb://system-service |
| monitor-service | /api/v1/monitor/** | lb://monitor-service |
| *-swagger | /auth-service/...、/system-service/...、/monitor-service/... | 对应服务 StripPrefix=1 |
默认端口
| 组件 | 端口 | 环境变量 |
|---|---|---|
| gateway | 8080 | SERVER_PORT |
| auth-service | 8081 | SERVER_PORT |
| system-service | 8082 | SERVER_PORT |
| monitor-service | 8083 | SERVER_PORT |
| Nacos | 8848 | NACOS_ADDR |
| RabbitMQ | 5672 | RABBITMQ_HOST |
| Seata | 8091 | SEATA_SERVER |
Monorepo 构建
- 不纳入 Turbo
build - 改
xichen-domain/xichen-common后:mvn install -DskipTests - 与 server-java 同步:
scripts/sync-from-server-java.ps1