feat: 接入真实登录与成员权限

- auth/members/messages: 新增超级管理员登录、成员权限和密码消息流程
- agent-config/agent: 支持服务端保存 Agent 配置并取消未配置 mock 成功结果
- projects/deploy-runs/settings: 按当前用户权限保护真实接口
- prisma: 新增用户、项目权限和平台消息表结构
This commit is contained in:
湛兮
2026-06-12 00:38:23 +08:00
parent cf1bebf625
commit bc3aa31289
83 changed files with 3844 additions and 378 deletions
+34 -29
View File
@@ -1,42 +1,47 @@
# Backend RTK
# 后端 RTK
## Architecture
## 架构
- Framework: NestJS + TypeScript.
- Package manager: pnpm.
- Data access: Prisma Client and Prisma migrations.
- Default local behavior: seeded project configuration keeps APIs runnable while MySQL is not configured; production uses real Jenkins and Gitea clients when credentials are injected.
- 框架:NestJS + TypeScript
- 包管理器:pnpm
- 数据访问:Prisma Client Prisma migrations
- 本地默认行为:未配置 MySQL 时使用种子项目和内存数据保持 API 可运行;生产环境注入凭据后使用真实 Jenkins Gitea 客户端。
## Module Map
## 模块地图
- `config`: environment schema and validation.
- `prisma`: PrismaService and DB health boundary.
- `health`: runtime and dependency summary.
- `projects`: project configuration API and repository.
- `deploy-runs`: deploy run API, status model, BPMN step summary.
- `integrations/jenkins`: Jenkins API client boundary.
- `integrations/gitea`: Gitea API client boundary.
- `notifications/wecom`: notification provider boundary for WeCom, Feishu, and generic webhook adapters.
- `agent`: LLM proxy client boundary for DevOps-only workflows.
- `audit`: sanitized audit record boundary.
- `config`:环境变量 schema 和校验。
- `prisma`PrismaService 和数据库健康边界。
- `health`:运行时和依赖健康摘要。
- `auth`:登录鉴权、密码管理、登录 token 和当前用户上下文。
- `members`:成员管理和项目权限分配。
- `messages`:平台消息通知,当前用于普通成员忘记密码请求。
- `projects`:项目配置 API 和 Repository
- `deploy-runs`:发布记录 API、状态模型和 BPMN 步骤摘要。
- `integrations/jenkins`Jenkins API 客户端边界。
- `integrations/gitea`Gitea API 客户端边界。
- `notifications/wecom`:企微、飞书和通用 webhook 通知边界。
- `agent-config`:Agent 系统级配置、密钥加密和连接测试。
- `agent`:只面向运维工作流的 LLM 代理边界。
- `audit`:脱敏审计记录边界。
## Data Access Rules
## 数据访问规则
1. Controllers call services.
2. Services call repositories and integration clients.
3. Repositories call Prisma.
4. Raw SQL is exceptional and repository-only.
5. Transactions are required for deploy run writes once persistence is enabled.
1. Controller 调用 service
2. Service 调用 repository 和集成客户端。
3. Repository 调用 Prisma
4. 原生 SQL 只允许作为例外,并且只能放在 repository
5. 启用持久化写入后,发布记录写入必须使用事务。
## Environment Rules
## 环境规则
- `.env.example` may contain placeholders only.
- `.env` is local-only and ignored by git.
- Missing external integration configuration should degrade to `not_configured` in health checks, not crash local development.
- `.env.example` 只能包含占位值。
- `.env` 只用于本地并且不能提交。
- 缺少外部集成配置时,健康检查应降级为 `not_configured`,不能导致本地开发启动失败。
- 生产环境保存 Agent 密钥必须配置 `SECRET_ENCRYPTION_KEY`
## Verification
## 验证
Run these before handing off backend changes when dependencies are available:
依赖可用时,交付前运行:
```bash
pnpm install