Skip to content

架构总览

目录结构

pangza-admin-express/
├── src/
│   ├── index.ts
│   ├── config/
│   ├── business/
│   │   ├── entity / mapper / service / controller
│   │   ├── advice/              # @ControllerAdvice 全局异常
│   │   └── schedule/tasks/
│   ├── core/
│   │   ├── Application/
│   │   ├── Auth / Log / Validate / Json / Exception
│   │   ├── RateLimit / encrypt / schedule
│   │   ├── ORM / Redis / Service
│   └── utils/
├── pangza-admin-ui/
└── package.json

启动链路

ts
Application.registry(cors())
  .registry(json())
  .registry(encryptMiddleware())
  .registry(Auth({
    tokenName: 'Authorization',
    tokenPrefix: '',
    timeout: 30 * 24 * 60 * 60 * 1000,
    activityTimeout: -1,
    allowConcurrentLogin: false,
    isShare: false,
    tokenStyle: 'uuid',
    ignore: [/* login / public ... */],
  }))
  .registry(Log())
  // 可选:.registry(Json({ dateFormat: '...' }))
  .start()

void initScheduleJobs()

业务扫描顺序

  1. entity
  2. mapper
  3. service
  4. controller
  5. advice

请求处理流程

HTTP
  → cors / json / encrypt / Auth / Log
  → 路由匹配
  → 鉴权 → 限流/防重
  → 参数注入 → @Validate?
  → Controller → Service → Mapper
  → ObjectMapper → ResponseData
  → (异常则 Advice / handleException)
  → 异步操作日志

相关章节

基于 VitePress 构建