feat(admin): Add user management and upgrade to module permission system
Features - User Management (Phase 4.1): - Database: Add user_modules table for fine-grained module permissions - Database: Add 4 user permissions (view/create/edit/delete) to role_permissions - Backend: UserService (780 lines) - CRUD with tenant isolation - Backend: UserController + UserRoutes (648 lines) - 13 API endpoints - Backend: Batch import users from Excel - Frontend: UserListPage (412 lines) - list/filter/search/pagination - Frontend: UserFormPage (341 lines) - create/edit with module config - Frontend: UserDetailPage (393 lines) - details/tenant/module management - Frontend: 3 modal components (592 lines) - import/assign/configure - API: GET/POST/PUT/DELETE /api/admin/users/* endpoints Architecture Upgrade - Module Permission System: - Backend: Add getUserModules() method in auth.service - Backend: Login API returns modules array in user object - Frontend: AuthContext adds hasModule() method - Frontend: Navigation filters modules based on user.modules - Frontend: RouteGuard checks requiredModule instead of requiredVersion - Frontend: Remove deprecated version-based permission system - UX: Only show accessible modules in navigation (clean UI) - UX: Smart redirect after login (avoid 403 for regular users) Fixes: - Fix UTF-8 encoding corruption in ~100 docs files - Fix pageSize type conversion in userService (String to Number) - Fix authUser undefined error in TopNavigation - Fix login redirect logic with role-based access check - Update Git commit guidelines v1.2 with UTF-8 safety rules Database Changes: - CREATE TABLE user_modules (user_id, tenant_id, module_code, is_enabled) - ADD UNIQUE CONSTRAINT (user_id, tenant_id, module_code) - INSERT 4 permissions + role assignments - UPDATE PUBLIC tenant with 8 module subscriptions Technical: - Backend: 5 new files (~2400 lines) - Frontend: 10 new files (~2500 lines) - Docs: 1 development record + 2 status updates + 1 guideline update - Total: ~4900 lines of code Status: User management 100% complete, module permission system operational
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
###
|
||||
# PKB模块迁移 - API测试脚本
|
||||
# 娴嬭瘯v1鍜寁2璺<EFBFBD>敱鐨勫姛鑳藉畬鏁存€у拰涓€鑷存€?
|
||||
# 测试v1和v2路由的功能完整性和一致<EFBFBD>?
|
||||
###
|
||||
|
||||
@baseUrl = http://localhost:3000
|
||||
@userId = user-mock-001
|
||||
|
||||
### ============================================
|
||||
### 闃舵<EFBFBD>3.1: 鍋ュ悍妫€鏌?
|
||||
### 阶段3.1: 健康检<EFBFBD>?
|
||||
### ============================================
|
||||
|
||||
### 1. PKB v2鍋ュ悍妫€鏌?
|
||||
### 1. PKB v2健康检<EFBFBD>?
|
||||
GET {{baseUrl}}/api/v1/pkb/health
|
||||
Accept: application/json
|
||||
|
||||
@@ -18,15 +18,15 @@ Accept: application/json
|
||||
### 阶段3.2: 知识库CRUD测试
|
||||
### ============================================
|
||||
|
||||
### 2. 鑾峰彇鐭ヨ瘑搴撳垪琛<EFBFBD>紙v1锛?
|
||||
### 2. 获取知识库列表(v1<EFBFBD>?
|
||||
GET {{baseUrl}}/api/v1/knowledge-bases
|
||||
Accept: application/json
|
||||
|
||||
### 3. 鑾峰彇鐭ヨ瘑搴撳垪琛<EFBFBD>紙v2锛?
|
||||
### 3. 获取知识库列表(v2<EFBFBD>?
|
||||
GET {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases
|
||||
Accept: application/json
|
||||
|
||||
### 4. 鍒涘缓鐭ヨ瘑搴擄紙v2锛?
|
||||
### 4. 创建知识库(v2<EFBFBD>?
|
||||
POST {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases
|
||||
Content-Type: application/json
|
||||
|
||||
@@ -35,7 +35,7 @@ Content-Type: application/json
|
||||
"description": "这是一个通过v2 API创建的测试知识库"
|
||||
}
|
||||
|
||||
### 5. 鍒涘缓鐭ヨ瘑搴擄紙v1 - 瀵规瘮锛?
|
||||
### 5. 创建知识库(v1 - 对比<EFBFBD>?
|
||||
POST {{baseUrl}}/api/v1/knowledge-bases
|
||||
Content-Type: application/json
|
||||
|
||||
@@ -44,54 +44,54 @@ Content-Type: application/json
|
||||
"description": "这是一个通过v1 API创建的测试知识库"
|
||||
}
|
||||
|
||||
### 6. 鑾峰彇鐭ヨ瘑搴撹<EFBFBD>鎯咃紙v2锛?
|
||||
### 6. 获取知识库详情(v2<EFBFBD>?
|
||||
# 替换为实际的知识库ID
|
||||
@kbId = f6ebe476-c50f-4222-83d2-c2525edc6054
|
||||
GET {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{kbId}}
|
||||
Accept: application/json
|
||||
|
||||
### 7. 鑾峰彇鐭ヨ瘑搴撹<EFBFBD>鎯咃紙v1 - 瀵规瘮锛?
|
||||
### 7. 获取知识库详情(v1 - 对比<EFBFBD>?
|
||||
GET {{baseUrl}}/api/v1/knowledge-bases/{{kbId}}
|
||||
Accept: application/json
|
||||
|
||||
### 8. 鏇存柊鐭ヨ瘑搴擄紙v2锛?
|
||||
### 8. 更新知识库(v2<EFBFBD>?
|
||||
PUT {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{kbId}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "更新后的知识库名称v2",
|
||||
"description": "閫氳繃v2 API鏇存柊鐨勬弿杩?
|
||||
"description": "通过v2 API更新的描<EFBFBD>?
|
||||
}
|
||||
|
||||
### 9. 鑾峰彇鐭ヨ瘑搴撶粺璁★紙v2锛?
|
||||
### 9. 获取知识库统计(v2<EFBFBD>?
|
||||
GET {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{kbId}}/stats
|
||||
Accept: application/json
|
||||
|
||||
### 10. 鑾峰彇鐭ヨ瘑搴撶粺璁★紙v1 - 瀵规瘮锛?
|
||||
### 10. 获取知识库统计(v1 - 对比<EFBFBD>?
|
||||
GET {{baseUrl}}/api/v1/knowledge-bases/{{kbId}}/stats
|
||||
Accept: application/json
|
||||
|
||||
### ============================================
|
||||
### 闃舵<EFBFBD>3.3: RAG妫€绱㈡祴璇?
|
||||
### 阶段3.3: RAG检索测<EFBFBD>?
|
||||
### ============================================
|
||||
|
||||
### 11. RAG妫€绱<EFBFBD>紙v2锛?
|
||||
GET {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{kbId}}/search?query=闃垮皵鍏规捣榛樼棁鐨勬不鐤楁柟娉?top_k=5
|
||||
### 11. RAG检索(v2<EFBFBD>?
|
||||
GET {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{kbId}}/search?query=阿尔兹海默症的治疗方<EFBFBD>?top_k=5
|
||||
Accept: application/json
|
||||
|
||||
### 12. RAG妫€绱<EFBFBD>紙v1 - 瀵规瘮锛?
|
||||
GET {{baseUrl}}/api/v1/knowledge-bases/{{kbId}}/search?query=闃垮皵鍏规捣榛樼棁鐨勬不鐤楁柟娉?top_k=5
|
||||
### 12. RAG检索(v1 - 对比<EFBFBD>?
|
||||
GET {{baseUrl}}/api/v1/knowledge-bases/{{kbId}}/search?query=阿尔兹海默症的治疗方<EFBFBD>?top_k=5
|
||||
Accept: application/json
|
||||
|
||||
### ============================================
|
||||
### 阶段3.4: 文档选择(全文阅读模式)
|
||||
### ============================================
|
||||
|
||||
### 13. 鑾峰彇鏂囨。閫夋嫨锛坴2锛?
|
||||
### 13. 获取文档选择(v2<EFBFBD>?
|
||||
GET {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{kbId}}/document-selection?max_files=7&max_tokens=750000
|
||||
Accept: application/json
|
||||
|
||||
### 14. 鑾峰彇鏂囨。閫夋嫨锛坴1 - 瀵规瘮锛?
|
||||
### 14. 获取文档选择(v1 - 对比<E5AFB9>?
|
||||
GET {{baseUrl}}/api/v1/knowledge-bases/{{kbId}}/document-selection?max_files=7&max_tokens=750000
|
||||
Accept: application/json
|
||||
|
||||
@@ -103,21 +103,21 @@ Accept: application/json
|
||||
GET {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{kbId}}
|
||||
Accept: application/json
|
||||
|
||||
### 16. 鑾峰彇鍗曚釜鏂囨。璇︽儏锛坴2锛?
|
||||
### 16. 获取单个文档详情(v2<EFBFBD>?
|
||||
# 替换为实际的文档ID
|
||||
@docId = your-document-id
|
||||
GET {{baseUrl}}/api/v1/pkb/knowledge/documents/{{docId}}
|
||||
Accept: application/json
|
||||
|
||||
### ============================================
|
||||
### 闃舵<EFBFBD>3.6: 鎵瑰<EFBFBD>鐞嗗姛鑳芥祴璇?
|
||||
### 阶段3.6: 批处理功能测<EFBFBD>?
|
||||
### ============================================
|
||||
|
||||
### 17. 鑾峰彇鎵瑰<EFBFBD>鐞嗘ā鏉匡紙v2锛?
|
||||
### 17. 获取批处理模板(v2<EFBFBD>?
|
||||
GET {{baseUrl}}/api/v1/pkb/batch-tasks/batch/templates
|
||||
Accept: application/json
|
||||
|
||||
### 18. 鍒涘缓鎵瑰<EFBFBD>鐞嗕换鍔★紙v2锛?
|
||||
### 18. 创建批处理任务(v2<EFBFBD>?
|
||||
POST {{baseUrl}}/api/v1/pkb/batch-tasks/batch/execute
|
||||
Content-Type: application/json
|
||||
|
||||
@@ -134,15 +134,15 @@ Content-Type: application/json
|
||||
### 阶段3.7: 边界条件测试
|
||||
### ============================================
|
||||
|
||||
### 19. 娴嬭瘯涓嶅瓨鍦ㄧ殑鐭ヨ瘑搴擄紙v2锛?
|
||||
### 19. 测试不存在的知识库(v2<EFBFBD>?
|
||||
GET {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/00000000-0000-0000-0000-000000000000
|
||||
Accept: application/json
|
||||
|
||||
### 20. 娴嬭瘯鏃犳晥鐨勬煡璇㈠弬鏁帮紙v2锛?
|
||||
### 20. 测试无效的查询参数(v2<EFBFBD>?
|
||||
GET {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{kbId}}/search?query=&top_k=0
|
||||
Accept: application/json
|
||||
|
||||
### 21. 娴嬭瘯瓒呭ぇtop_k鍙傛暟锛坴2锛?
|
||||
### 21. 测试超大top_k参数(v2<EFBFBD>?
|
||||
GET {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{kbId}}/search?query=测试&top_k=1000
|
||||
Accept: application/json
|
||||
|
||||
@@ -150,7 +150,7 @@ Accept: application/json
|
||||
### 阶段3.8: 清理测试数据(可选)
|
||||
### ============================================
|
||||
|
||||
### 22. 鍒犻櫎娴嬭瘯鐭ヨ瘑搴擄紙v2锛?
|
||||
### 22. 删除测试知识库(v2<EFBFBD>?
|
||||
# @testKbId = 从创建响应中获取的ID
|
||||
DELETE {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{testKbId}}
|
||||
|
||||
@@ -169,3 +169,5 @@ DELETE {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{testKbId}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user