feat(admin): Complete tenant management and module access control system

Major Features:
- Tenant management CRUD (list, create, edit, delete, module configuration)
- Dynamic module management system (modules table with 8 modules)
- Multi-tenant module permission merging (ModuleService)
- Module access control middleware (requireModule)
- User module permission API (GET /api/v1/auth/me/modules)
- Frontend module permission filtering (HomePage + TopNavigation)

Module Integration:
- RVW module integrated with PromptService (editorial + methodology)
- All modules (RVW/PKB/ASL/DC) added authenticate + requireModule middleware
- Fixed ReviewTask foreign key constraint (cross-schema issue)
- Removed all MOCK_USER_ID, unified to request.user?.userId

Prompt Management Enhancements:
- Module names displayed in Chinese (RVW -> 智能审稿)
- Enhanced version history with view content and rollback features
- List page shows both activeVersion and draftVersion columns

Database Changes:
- Added platform_schema.modules table
- Modified tenant_modules table (added index and UUID)
- Removed ReviewTask foreign key to public.users (cross-schema fix)
- Seeded 8 modules: RVW, PKB, ASL, DC, IIT, AIA, SSA, ST

Documentation Updates:
- Updated ADMIN module development status
- Updated TODO checklist (89% progress)
- Updated Prompt management plan (Phase 3.5.5 completed)
- Added module authentication specification

Files Changed: 80+
Status: All features tested and verified locally
Next: User management module development
This commit is contained in:
2026-01-13 07:34:30 +08:00
parent 5523ef36ea
commit d595037316
51 changed files with 3550 additions and 287 deletions

View File

@@ -1,29 +1,44 @@
# Prompt管理系统开发计划
> **版本:** v1.1
> **版本:** v1.2
> **创建日期:** 2026-01-11
> **更新日期:** 2026-01-12
> **优先级:** P0核心通用能力
> **状态:** 🚧 Phase 3.5.1-3.5.4 已完成83%),待 Phase 3.5.5 RVW 集成
> **状态:** Phase 3.5.1-3.5.5 全部完成100%
> **预计工期:** 7个工作日
> **实际进度** Day 1-6 已完成2026-01-11
> **实际完成** Day 1-7 已完成2026-01-12
---
## 🎯 快速导航2026-01-11更新
### ✅ 已完成Phase 3.5.1 - 3.5.4
### ✅ 已完成Phase 3.5.1 - 3.5.5
| 阶段 | 核心产出 | 文件位置 |
|------|---------|---------|
| **3.5.1 基础设施** | capability_schema、表结构、权限、迁移 | `backend/prisma/schema.prisma` |
| **3.5.2 核心服务** | PromptService灰度、渲染、变量校验 | `backend/src/common/prompt/` |
| **3.5.3 管理API** | 8个RESTful接口 | `backend/src/common/prompt/prompt.routes.ts` |
| **3.5.4 前端界面** | 管理端架构、Prompt列表、编辑器 | `frontend-v2/src/pages/admin/` |
| 阶段 | 核心产出 | 文件位置 | 完成日期 |
|------|---------|---------|---------|
| **3.5.1 基础设施** | capability_schema、表结构、权限、迁移 | `backend/prisma/schema.prisma` | 2026-01-11 |
| **3.5.2 核心服务** | PromptService灰度、渲染、变量校验 | `backend/src/common/prompt/` | 2026-01-11 |
| **3.5.3 管理API** | 8个RESTful接口 | `backend/src/common/prompt/prompt.routes.ts` | 2026-01-11 |
| **3.5.4 前端界面** | 管理端架构、Prompt列表、编辑器 | `frontend-v2/src/pages/admin/` | 2026-01-11 |
| **3.5.5 业务集成** | RVW模块集成、认证规范化 | `backend/src/modules/rvw/` | 2026-01-12 ✅ |
### ⏳ 待完成(Phase 3.5.5
### 🆕 Phase 3.5.5 完成内容2026-01-12
- [ ] 改造 RVW 服务使用 `promptService.get()`
- [ ] 端到端测试
**RVW 模块集成:**
- ✅ editorialService.ts - 集成 PromptService移除文件读取
- ✅ methodologyService.ts - 集成 PromptService移除文件读取
- ✅ reviewWorker.ts - 传递 userId 支持灰度预览
- ✅ 修复 ReviewTask 外键约束(跨 schema 问题)
**全模块认证规范化:**
- ✅ RVW/PKB/ASL/DC 模块添加 authenticate 中间件
- ✅ 统一使用 request.user?.userId移除所有 MOCK_USER_ID
- ✅ 前端统一使用 apiClientaxios + JWT interceptor
- ✅ 创建 `docs/04-开发规范/10-模块认证规范.md`
**界面优化:**
- ✅ Prompt 列表模块列显示中文名称
- ✅ 版本历史增强(查看内容、回滚功能)
---