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,21 +1,21 @@
|
||||
# 工具C Day 4 前端基础框架完成
|
||||
|
||||
> **日期**: 2025-12-07
|
||||
> **寮€鍙戠洰鏍?*: 鍓嶇<E98D93>鍩虹<E98DA9>妗嗘灦锛圓G Grid + 甯冨眬锛?
|
||||
> **寮€鍙戠姸鎬?*: 鉁?鍏ㄩ儴瀹屾垚
|
||||
> **开发目标**: 前端基础框架(AG Grid + 布局)
|
||||
> **开发状态**: ✅ 全部完成
|
||||
|
||||
---
|
||||
|
||||
## 鉁?瀹屾垚浠诲姟锛?/8锛?00%锛?
|
||||
## ✅ 完成任务(8/8,100%)
|
||||
|
||||
1. 鉁?瀹夎<E780B9>渚濊禆锛圓G Grid Community + Prism.js锛?
|
||||
2. 鉁?鍒涘缓鏂囦欢缁撴瀯锛坱ool-c鐩<EFBFBD>綍 + 3涓<EFBFBD>瓙鐩<EFBFBD>綍锛?
|
||||
3. 鉁?鍒涘缓涓诲叆鍙?index.tsx锛?58琛岋級
|
||||
4. 鉁?鍒涘缓Header缁勪欢锛?1琛岋級
|
||||
5. 鉁?鍒涘缓Toolbar缁勪欢锛?04琛岋級
|
||||
6. 鉁?鍒涘缓DataGrid缁勪欢锛?11琛岋紝AG Grid闆嗘垚锛?
|
||||
7. 鉁?鏇存柊璺<E69F8A>敱閰嶇疆锛坉c/index.tsx锛?
|
||||
8. 鉁?鏇存柊Portal鍚<EFBFBD>敤Tool C锛坰tatus: 'ready'锛?
|
||||
1. ✅ 安装依赖(AG Grid Community + Prism.js)
|
||||
2. ✅ 创建文件结构(tool-c目录 + 3个子目录)
|
||||
3. ✅ 创建主入口 index.tsx(258行)
|
||||
4. ✅ 创建Header组件(91行)
|
||||
5. ✅ 创建Toolbar组件(104行)
|
||||
6. ✅ 创建DataGrid组件(111行,AG Grid集成)
|
||||
7. ✅ 更新路由配置(dc/index.tsx)
|
||||
8. ✅ 更新Portal启用Tool C(status: 'ready')
|
||||
|
||||
---
|
||||
|
||||
@@ -24,88 +24,88 @@
|
||||
```
|
||||
frontend-v2/src/modules/dc/
|
||||
├── pages/tool-c/
|
||||
鈹? 鈹溾攢鈹€ index.tsx # 258琛?鉁?
|
||||
鈹? 鈹溾攢鈹€ components/
|
||||
鈹? 鈹? 鈹溾攢鈹€ Header.tsx # 91琛?鉁?
|
||||
鈹? 鈹? 鈹溾攢鈹€ Toolbar.tsx # 104琛?鉁?
|
||||
鈹? 鈹? 鈹溾攢鈹€ DataGrid.tsx # 111琛?鉁?
|
||||
鈹? 鈹? 鈹溾攢鈹€ Sidebar.tsx # 149琛?鉁?(楠ㄦ灦鐗?
|
||||
鈹? 鈹? 鈹斺攢鈹€ ag-grid-custom.css # 113琛?鉁?
|
||||
鈹? 鈹斺攢鈹€ types/
|
||||
鈹? 鈹斺攢鈹€ index.tsx # 62琛?鉁?
|
||||
│ ├── index.tsx # 258行 ✅
|
||||
│ ├── components/
|
||||
│ │ ├── Header.tsx # 91行 ✅
|
||||
│ │ ├── Toolbar.tsx # 104行 ✅
|
||||
│ │ ├── DataGrid.tsx # 111行 ✅
|
||||
│ │ ├── Sidebar.tsx # 149行 ✅ (骨架版)
|
||||
│ │ └── ag-grid-custom.css # 113行 ✅
|
||||
│ └── types/
|
||||
│ └── index.tsx # 62行 ✅
|
||||
└── api/
|
||||
鈹斺攢鈹€ toolC.ts # 218琛?鉁?
|
||||
└── toolC.ts # 218行 ✅
|
||||
|
||||
鎬讳唬鐮侊細~1106琛?
|
||||
总代码:~1106行
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎯 核心成果
|
||||
|
||||
### 1. AG Grid Community闆嗘垚 鉁?
|
||||
### 1. AG Grid Community集成 ✅
|
||||
- **版本**: 31.0.0
|
||||
- **功能**:
|
||||
- Excel风格表格渲染
|
||||
- 鍒楁帓搴忋€佽繃婊ゃ€佽皟鏁村<EFBFBD>搴?
|
||||
- 缂哄け鍊奸珮浜<EFBFBD>紙绾㈣壊鏂滀綋锛?
|
||||
- 列排序、过滤、调整宽度
|
||||
- 缺失值高亮(红色斜体)
|
||||
- 数值右对齐
|
||||
- 鏂戦┈绾硅儗鏅?
|
||||
- 铏氭嫙婊氬姩锛堟敮鎸佸ぇ鏁版嵁锛?
|
||||
- 斑马纹背景
|
||||
- 虚拟滚动(支持大数据)
|
||||
|
||||
### 2. Emerald缁胯壊涓婚<EFBFBD> 鉁?
|
||||
### 2. Emerald绿色主题 ✅
|
||||
- 还原原型图V6设计风格
|
||||
- 鑷<EFBFBD>畾涔堿G Grid鏍峰紡锛坅g-grid-custom.css锛?
|
||||
- Tailwind CSS鍘熷瓙鍖栨牱寮?
|
||||
- 自定义AG Grid样式(ag-grid-custom.css)
|
||||
- Tailwind CSS原子化样式
|
||||
|
||||
### 3. 瀹屾暣甯冨眬妗嗘灦 鉁?
|
||||
### 3. 完整布局框架 ✅
|
||||
```
|
||||
鈹屸攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€ Header (h-14) 鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?
|
||||
鈹溾攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹<EFBFBD>攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?
|
||||
鈹?Left Panel 鈹?Right Sidebar 鈹?
|
||||
鈹?鈹屸攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?鈹?(w-420px) 鈹?
|
||||
鈹?鈹?Toolbar (7btn) 鈹?鈹? 鈹?
|
||||
鈹?鈹斺攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?鈹?[Chat寰匘ay5] 鈹?
|
||||
鈹?鈹屸攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?鈹? 鈹?
|
||||
鈹?鈹? AG Grid琛ㄦ牸 鈹?鈹? 鈹?
|
||||
鈹?鈹? (flex-1) 鈹?鈹? 鈹?
|
||||
鈹?鈹斺攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?鈹? 鈹?
|
||||
鈹斺攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹粹攢鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹?
|
||||
┌──────────── Header (h-14) ────────────┐
|
||||
├────────────────────┬─────────────────┤
|
||||
│ Left Panel │ Right Sidebar │
|
||||
│ ┌────────────────┐ │ (w-420px) │
|
||||
│ │ Toolbar (7btn) │ │ │
|
||||
│ └────────────────┘ │ [Chat待Day5] │
|
||||
│ ┌────────────────┐ │ │
|
||||
│ │ AG Grid表格 │ │ │
|
||||
│ │ (flex-1) │ │ │
|
||||
│ └────────────────┘ │ │
|
||||
└────────────────────┴─────────────────┘
|
||||
```
|
||||
|
||||
### 4. API灏佽<EFBFBD>瀹屾垚 鉁?
|
||||
- **鏂囦欢**: api/toolC.ts锛?18琛岋級
|
||||
- **鏂规硶**: 8涓?
|
||||
### 4. API封装完成 ✅
|
||||
- **文件**: api/toolC.ts(218行)
|
||||
- **方法**: 8个
|
||||
- uploadFile()
|
||||
- getSession()
|
||||
- getPreviewData()
|
||||
- updateHeartbeat()
|
||||
- generateCode()
|
||||
- executeCode()
|
||||
- processMessage() 猸?鏍稿績
|
||||
- processMessage() ⭐ 核心
|
||||
- getChatHistory()
|
||||
|
||||
### 5. 璺<EFBFBD>敱闆嗘垚 鉁?
|
||||
### 5. 路由集成 ✅
|
||||
- **路径**: `/data-cleaning/tool-c`
|
||||
- **Portal**: Tool C鍗$墖宸插惎鐢<EFBFBD>紙status: 'ready'锛?
|
||||
- **鎳掑姞杞?*: React.lazy()
|
||||
- **Portal**: Tool C卡片已启用(status: 'ready')
|
||||
- **懒加载**: React.lazy()
|
||||
- **测试**: 可点击进入(需要启动前端服务验证)
|
||||
|
||||
---
|
||||
|
||||
## 鈴革笍 Day 5寰呭畬鎴愶紙棰勮<EFBFBD>6-8灏忔椂锛?
|
||||
## ⏸️ Day 5待完成(预计6-8小时)
|
||||
|
||||
### 鏍稿績浠诲姟锛?涓<>粍浠讹級
|
||||
1. 鈴革笍 MessageItem.tsx - 娑堟伅娓叉煋锛堢敤鎴?AI/绯荤粺锛?
|
||||
2. 鈴革笍 CodeBlock.tsx - 浠g爜楂樹寒锛圥rism.js锛?
|
||||
3. 鈴革笍 InputArea.tsx - 杈撳叆妗嗕氦浜?
|
||||
### 核心任务(4个组件)
|
||||
1. ⏸️ MessageItem.tsx - 消息渲染(用户/AI/系统)
|
||||
2. ⏸️ CodeBlock.tsx - 代码高亮(Prism.js)
|
||||
3. ⏸️ InputArea.tsx - 输入框交互
|
||||
4. ⏸️ InsightsPanel.tsx - 数据洞察卡片
|
||||
|
||||
### 集成任务
|
||||
5. 鈴革笍 瀹屽杽Sidebar缁勪欢锛堝畬鏁碈hat浜や簰锛?
|
||||
5. ⏸️ 完善Sidebar组件(完整Chat交互)
|
||||
6. ⏸️ 文件上传完整流程
|
||||
7. ⏸️ API完整集成
|
||||
8. 鈴革笍 绔<>埌绔<E59F8C>祴璇?
|
||||
8. ⏸️ 端到端测试
|
||||
|
||||
---
|
||||
|
||||
@@ -113,23 +113,23 @@ frontend-v2/src/modules/dc/
|
||||
|
||||
| 组件 | Day 1 | Day 2 | Day 3 | Day 4 | 总计 |
|
||||
|------|-------|-------|-------|-------|------|
|
||||
| Python寰<EFBFBD>湇鍔?| 鉁?100% | - | +浼樺寲 | - | 鉁?100% |
|
||||
| Node.js鍚庣<EFBFBD> | 鉁?20% | 鉁?+30% | 鉁?+35% | - | 鉁?85% |
|
||||
| 鍓嶇<EFBFBD>鐣岄潰 | - | - | - | 鉁?40% | 馃毀 40% |
|
||||
| 鏁版嵁搴?| - | 鉁?1琛?| 鉁?+1琛?| - | 鉁?2琛?|
|
||||
| Python微服务 | ✅ 100% | - | +优化 | - | ✅ 100% |
|
||||
| Node.js后端 | ✅ 20% | ✅ +30% | ✅ +35% | - | ✅ 85% |
|
||||
| 前端界面 | - | - | - | ✅ 40% | 🚧 40% |
|
||||
| 数据库 | - | ✅ 1表 | ✅ +1表 | - | ✅ 2表 |
|
||||
| **总体** | **15%** | **35%** | **60%** | **70%** | **70%** 🚧 |
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Day 5验收标准
|
||||
|
||||
**绔<EFBFBD>埌绔<EFBFBD>祦绋?*锛?
|
||||
**端到端流程**:
|
||||
1. [ ] 访问`/data-cleaning/tool-c`
|
||||
2. [ ] 点击上传文件
|
||||
3. [ ] 閫夋嫨`cqol-demo.csv`锛?1鍒梮300+琛岋級
|
||||
3. [ ] 选择`cqol-demo.csv`(21列x300+行)
|
||||
4. [ ] AG Grid显示完整数据
|
||||
5. [ ] 鍦–hat杈撳叆锛?鎶妔ex鍒楃殑缂哄け鍊煎~琛ヤ负浼楁暟"
|
||||
6. [ ] AI鐢熸垚Python浠g爜骞舵樉绀?
|
||||
5. [ ] 在Chat输入:"把sex列的缺失值填补为众数"
|
||||
6. [ ] AI生成Python代码并显示
|
||||
7. [ ] 点击"执行代码"按钮
|
||||
8. [ ] 表格数据实时更新
|
||||
9. [ ] 对话历史正常显示
|
||||
@@ -138,7 +138,7 @@ frontend-v2/src/modules/dc/
|
||||
|
||||
## 📝 测试数据
|
||||
|
||||
- **鏂囦欢1**: `cqol-demo.csv`锛?1鍒梮313琛岋級
|
||||
- **文件1**: `cqol-demo.csv`(21列x313行)
|
||||
- 真实医疗数据(口腔医学)
|
||||
- 包含缺失值、数值列、分类列
|
||||
|
||||
@@ -157,35 +157,35 @@ frontend-v2/src/modules/dc/
|
||||
- `lucide-react`: ^0.x
|
||||
- `axios`: ^1.x
|
||||
|
||||
### 寮€鍙戝伐鍏?
|
||||
### 开发工具
|
||||
- TypeScript(严格模式)
|
||||
- Tailwind CSS
|
||||
- React Hooks
|
||||
|
||||
---
|
||||
|
||||
## 馃殌 缁欎笅涓€涓狝I鐨勬彁绀?
|
||||
## 🚀 给下一个AI的提示
|
||||
|
||||
### 褰撳墠鐘舵€侊紙2025-12-07锛?
|
||||
- 鉁?**Day 1-3**: 鍚庣<EFBFBD>瀹屾暣锛圥ython + Node.js + 鏁版嵁搴擄級
|
||||
- 鉁?**Day 4**: 鍓嶇<EFBFBD>鍩虹<EFBFBD>妗嗘灦锛圓G Grid + Header + Toolbar锛?
|
||||
- 馃毀 **Day 5杩涜<EFBFBD>涓?*: Chat缁勪欢寰呭紑鍙?
|
||||
### 当前状态(2025-12-07)
|
||||
- ✅ **Day 1-3**: 后端完整(Python + Node.js + 数据库)
|
||||
- ✅ **Day 4**: 前端基础框架(AG Grid + Header + Toolbar)
|
||||
- 🚧 **Day 5进行中**: Chat组件待开发
|
||||
|
||||
### 立即任务清单
|
||||
```
|
||||
Day 5 (6-8小时):
|
||||
1. 创建MessageItem.tsx(~100行)
|
||||
2. 鍒涘缓CodeBlock.tsx锛垀80琛岋紝闆嗘垚Prism.js锛?
|
||||
2. 创建CodeBlock.tsx(~80行,集成Prism.js)
|
||||
3. 创建InputArea.tsx(~60行)
|
||||
4. 创建InsightsPanel.tsx(~80行)
|
||||
5. 完善Sidebar.tsx(添加Tab切换、完整交互)
|
||||
6. 鍦╥ndex.tsx涓<EFBFBD>泦鎴愭枃浠朵笂浼?
|
||||
7. 娴嬭瘯绔<EFBFBD>埌绔<EFBFBD>祦绋?
|
||||
6. 在index.tsx中集成文件上传
|
||||
7. 测试端到端流程
|
||||
8. 修复Bug
|
||||
```
|
||||
|
||||
### 关键文件位置
|
||||
- **鍓嶇<EFBFBD>涓诲叆鍙?*: `frontend-v2/src/modules/dc/pages/tool-c/index.tsx`
|
||||
- **前端主入口**: `frontend-v2/src/modules/dc/pages/tool-c/index.tsx`
|
||||
- **API封装**: `frontend-v2/src/modules/dc/api/toolC.ts`
|
||||
- **路由配置**: `frontend-v2/src/modules/dc/index.tsx`
|
||||
- **Portal入口**: `frontend-v2/src/modules/dc/pages/Portal.tsx`
|
||||
@@ -196,20 +196,19 @@ Day 5 (6-8小时):
|
||||
|
||||
### 测试数据
|
||||
- **路径**: `docs/03-业务模块/DC-数据清洗整理/05-测试文档/03-测试数据/cqol-demo.csv`
|
||||
- **瑙勬ā**: 21鍒?x 313琛?
|
||||
- **鐗圭偣**: 鐪熷疄鍖荤枟鏁版嵁锛屽惈缂哄け鍊?
|
||||
- **规模**: 21列 x 313行
|
||||
- **特点**: 真实医疗数据,含缺失值
|
||||
|
||||
### 鍙傝€冩枃妗?
|
||||
- **Day 4-5寮€鍙戣<EFBFBD>鍒?*: `docs/03-涓氬姟妯″潡/DC-鏁版嵁娓呮礂鏁寸悊/04-寮€鍙戣<E98D99>鍒?宸ュ叿C_Day4-5鍓嶇<E98D93>寮€鍙戣<E98D99>鍒?md`
|
||||
- **鍘熷瀷鍥?*: `docs/03-涓氬姟妯″潡/DC-鏁版嵁娓呮礂鏁寸悊/03-UI璁捐<E79281>/宸ュ叿C_鍘熷瀷璁捐<E79281>V6 .html`
|
||||
- **Tool B鍙傝€?*: `frontend-v2/src/modules/dc/pages/tool-b/`锛堢浉浼肩殑寮€鍙戞ā寮忥級
|
||||
### 参考文档
|
||||
- **Day 4-5开发计划**: `docs/03-业务模块/DC-数据清洗整理/04-开发计划/工具C_Day4-5前端开发计划.md`
|
||||
- **原型图**: `docs/03-业务模块/DC-数据清洗整理/03-UI设计/工具C_原型设计V6 .html`
|
||||
- **Tool B参考**: `frontend-v2/src/modules/dc/pages/tool-b/`(相似的开发模式)
|
||||
|
||||
---
|
||||
|
||||
**缁存姢鑰?*: AI Assistant
|
||||
**Git鎻愪氦**: 寰匘ay 5瀹屾垚鍚庝竴璧锋彁浜?
|
||||
**涓嬩竴姝?*: 寮€鍙慏ay 5 Chat缁勪欢
|
||||
|
||||
**维护者**: AI Assistant
|
||||
**Git提交**: 待Day 5完成后一起提交
|
||||
**下一步**: 开发Day 5 Chat组件
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user