[CLAUDE] Phase1.2: CRUD Master + Permission Matrix + FE admin pages
Backend:
- Domain/Master: Supplier (+ SupplierType 5 loai), Project, Department (AuditableEntity)
- Domain/Identity: MenuItem, Permission, MenuKeys const (12 menu)
- EF Configurations voi unique Code + query filter IsDeleted
- DbSets + IApplicationDbContext interface update
- Application: PagedResult + PagedRequest generic
- Application/Master CQRS CRUD 3 entity (Create/Update/Delete/Get/List voi paging search sort)
- Application/Permissions: GetMyMenuTree (union OR role, filter tree), ListMenuItems, ListPermissionsByRole, UpsertPermission (guard admin khong tu giam quyen), ListRoles
- Api/Authorization: MenuPermissionRequirement + Handler (Admin bypass, query DB)
- Program.cs: register 48 policy {menu}.{action} tu MenuKeys x Actions
- Api/Controllers: Suppliers, Projects, Departments, Menus, Roles, Permissions
- DbInitializer: seed 12 menu + admin full CRUD permissions
- Migration AddMasterData + AddPermissions
Frontend (fe-admin):
- Types: menuKeys.ts const, menu.ts (MenuNode/Role/Permission), master.ts (Supplier/Project/Department + SupplierType const-object)
- AuthContext: load menu from /menus/me, cache localStorage, refreshMenu()
- usePermission hook + PermissionGuard component (wrap button)
- UI kit them: Dialog (modal overlay), Textarea, Select
- Generic: DataTable (column config, sortable, loading, empty) + Pagination
- PageHeader component
- apiError helper extract message tu ProblemDetails
- Layout rewrite: render menu dong tu AuthContext.menu (MenuGroup collapsible + NavLink + lucide icon map)
- Pages: master/Suppliers, master/Projects, master/Departments (CRUD + search + sort + paging + Dialog form)
- Page system/Permissions: ma tran Role x MenuKey x CRUD checkbox (tick tu dong PUT upsert)
- App.tsx them 4 route moi
Bug fix:
- MenuPermissionHandler: EF expression tree khong support switch expression -> tach switch ra ngoai AnyAsync
- TS erasableSyntaxOnly khong cho enum -> SupplierType const-object pattern (typeof[keyof])
E2E verified via Vite proxy:
- GET /menus/me -> 6 root + 6 child nodes (12 menus)
- GET /roles -> 12 roles
- POST/GET/PUT/DELETE /suppliers -> full CRUD, soft delete OK
- tsc -b fe-admin pass
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@ -2,67 +2,64 @@
|
||||
|
||||
> **Update rule:** trước khi bắt đầu 1 task → ghi row vào `🔥 In Progress`. Xong → chuyển sang `✅ Recently Done`.
|
||||
|
||||
**Last updated:** 2026-04-21 11:00
|
||||
**Last updated:** 2026-04-21 11:30
|
||||
|
||||
## 📍 Phase hiện tại: **Phase 1 — Alpha Core** (foundation xong, chờ đợt 2)
|
||||
## 📍 Phase hiện tại: **Phase 1 — Alpha Core (đợt 2 xong)** — sẵn sàng Phase 2 Form Engine
|
||||
|
||||
## 🔥 In Progress
|
||||
|
||||
_(không có — Phase 1 foundation xong, chờ quyết định bước tiếp)_
|
||||
_(không có — Phase 1 đợt 2 hoàn tất)_
|
||||
|
||||
## ✅ Recently Done (newest on top)
|
||||
|
||||
| Ngày | Ai | Task | Commit |
|
||||
|---|---|---|---|
|
||||
| 2026-04-21 | Claude | **Docs addition** — `database-guide.md` (conventions + schema + ERD + migration workflow) + `flows/` 6 doc (auth implemented + permission/contract-create/contract-approve/form-render/sla-expiry planned) | (sắp commit) |
|
||||
| 2026-04-21 | Claude | **Phase 1 foundation HOÀN TẤT** — BE (Clean Arch + Identity + JWT + migration) + FE (2 app, Tailwind 4, Router, AuthContext, Login) — E2E login pass qua Vite proxy | `702411f` |
|
||||
| 2026-04-21 | Claude | **Phase 1 đợt 2 HOÀN TẤT** — BE: Supplier/Project/Department CRUD + Permission Matrix (MenuItem/Permission + Authorization handler) + 2 migration. FE: DataTable/Dialog generic, usePermission, PermissionGuard, 3 trang CRUD admin, Permission Matrix page, Layout menu động | (sắp commit) |
|
||||
| 2026-04-21 | Claude | **Docs addition** — `database-guide.md` + `flows/` 6 doc | `49a5f57` |
|
||||
| 2026-04-21 | Claude | **Phase 1 foundation HOÀN TẤT** — BE Clean Arch + Identity + JWT + FE 2 app + Tailwind 4 + login E2E | `702411f` |
|
||||
| 2026-04-21 | Claude | **Phase 0 HOÀN TẤT** — scaffold + parse FORM/QUY_TRINH + docs + skills + git init | `25dad7f` |
|
||||
|
||||
Session logs:
|
||||
- [`changelog/sessions/2026-04-21-1045-phase0-scaffold.md`](changelog/sessions/2026-04-21-1045-phase0-scaffold.md)
|
||||
- [`changelog/sessions/2026-04-21-1100-phase1-foundation.md`](changelog/sessions/2026-04-21-1100-phase1-foundation.md)
|
||||
- [`changelog/sessions/2026-04-21-1130-phase1-cruds-permission.md`](changelog/sessions/2026-04-21-1130-phase1-cruds-permission.md)
|
||||
|
||||
## 🎯 Next up — Phase 1 đợt 2 (CRUD master + Permission Matrix)
|
||||
## 🎯 Next up — Phase 2 Form Engine (có thể bắt ngay)
|
||||
|
||||
### Backend
|
||||
- [ ] `Domain/Entities/Supplier`, `Project`, `Department` (+ EF configurations)
|
||||
- [ ] `Application/Suppliers/{Commands,Queries}/*` (Create, Update, Delete, GetById, List)
|
||||
- [ ] Tương tự cho Project + Department
|
||||
- [ ] `Api/Controllers/{SuppliersController, ProjectsController, DepartmentsController}`
|
||||
- [ ] Pagination, search, sort server-side (`GetListQuery` với `PagedResult<T>`)
|
||||
- [ ] Migration 2: `AddMasterData`
|
||||
- [ ] Convert 3 file `.doc` (FO-002.02/03/06) → `.docx` qua PowerShell COM hoặc LibreOffice headless
|
||||
- [ ] Parse chi tiết field specs cho 5 template HĐ → JSON spec
|
||||
- [ ] Add NuGet: DocumentFormat.OpenXml, ClosedXML
|
||||
- [ ] `Domain/Entities/ContractTemplate`, `ContractClause` + EF config
|
||||
- [ ] `Application/Forms/Services/IFormRenderer` + `DocxRenderer` + `XlsxRenderer`
|
||||
- [ ] `Api/Controllers/FormsController` (list template, get spec, render preview, render final)
|
||||
- [ ] FE: form builder dynamic render từ fieldSpec
|
||||
- [ ] FE admin: upload template + manage ContractClause (rich text editor)
|
||||
- [ ] Test: FO-002.05 Giao khoán render → docx khớp mẫu 100%
|
||||
|
||||
### Permission Matrix
|
||||
- [ ] `Domain/Entities/MenuItem`, `Permission`
|
||||
- [ ] Seed default menu tree (based on FE screens)
|
||||
- [ ] `Application/Permissions/Queries/GetMyMenuTreeQuery`
|
||||
- [ ] `Api/Controllers/{MenusController, RolesController, PermissionsController}`
|
||||
- [ ] Admin UI: Permission Matrix grid (role × menu × CRUD checkbox)
|
||||
Chi tiết: [`docs/flows/form-render-flow.md`](flows/form-render-flow.md) + [`docs/changelog/migration-todos.md`](changelog/migration-todos.md) section Phase 2.
|
||||
|
||||
### Contract draft (chưa workflow)
|
||||
- [ ] `Domain/Entities/Contract` skeleton (không state machine)
|
||||
- [ ] Basic CRUD controller + FE list page
|
||||
## 🔄 Còn có thể làm parallel (optional, không block Phase 2)
|
||||
|
||||
### FE
|
||||
- [ ] `<PermissionGuard menuKey="Contracts">` + `usePermission()` hook
|
||||
- [ ] 3 trang CRUD admin (Suppliers / Projects / Departments) với table + modal
|
||||
- [ ] Route guard theo role (admin-only routes)
|
||||
- [ ] FE Users management (tạo user + gán role) — cần để test permission với role khác Admin
|
||||
- [ ] FE Roles CRUD (tạo custom role mới)
|
||||
- [ ] Contract entity skeleton (không state machine, chỉ CRUD draft)
|
||||
- [ ] E2E test permission: tạo user role Drafter-only → verify không thấy menu System/Admin
|
||||
|
||||
## 📊 Thông số sau Phase 1 foundation
|
||||
## 📊 Thông số sau Phase 1 đợt 2
|
||||
|
||||
- **Backend LOC:** ~400 (Domain 60 + Application 170 + Infrastructure 190 + Api 120)
|
||||
- **Frontend LOC:** ~450 mỗi app (shared 90%)
|
||||
- **Build time:** .NET ~4s, FE TS check ~3s mỗi app, Vite dev ~3s ready
|
||||
- **E2E verified:** Login (fe-admin proxy + fe-user proxy) → API → JWT + user info + /me
|
||||
- **Backend LOC:** ~1500 (Domain 150 + Application 800 + Infrastructure 350 + Api 200)
|
||||
- **Migrations:** Init + AddMasterData + AddPermissions
|
||||
- **DB tables:** 7 Identity + 3 Master (Suppliers/Projects/Departments) + 2 Permission (MenuItems/Permissions)
|
||||
- **API endpoints:** 20+ (Auth 4 + Suppliers 5 + Projects 5 + Departments 5 + Menus 2 + Roles 1 + Permissions 2)
|
||||
- **Frontend routes:** 5 (Dashboard + 3 CRUD + Permission Matrix)
|
||||
- **FE LOC:** ~1700 (fe-admin; fe-user vẫn minimal)
|
||||
|
||||
## 🚨 Blockers / risks
|
||||
|
||||
- ⏳ **Gitea remote** chưa có URL — push sau
|
||||
- ⚠️ **Swashbuckle 10.x** không tương thích với .NET 10 + Microsoft.OpenApi 2.0 — đã downgrade về 6.9.0. Theo dõi update sau.
|
||||
- ⚠️ **MediatR 14.x** breaking changes — đã downgrade về 12.4.1. Ok cho Phase 1-5.
|
||||
- ⚠️ **Microsoft.AspNetCore.OpenApi** đã remove (conflict Swashbuckle 6.9). Nếu sau muốn dùng built-in OpenAPI thì phải chọn 1 trong 2.
|
||||
- ⚠️ **Design-time DB (`SolutionErp_Design`)** được tạo khi chạy `dotnet ef` — có thể drop an toàn (không chứa data thật)
|
||||
- ⚠️ **3 file `.doc` FORM** chưa convert được — Phase 2
|
||||
- ⏳ **Gitea remote** — URL chờ user cấp
|
||||
- ⚠️ **fe-user** chưa được update với menu động — Phase 2 sẽ sync
|
||||
- ⚠️ **Users CRUD** chưa có UI → khó test permission với non-admin role thật
|
||||
- ⚠️ **3 file `.doc`** Phase 2 cần convert COM
|
||||
|
||||
## Credentials mặc định
|
||||
|
||||
@ -72,6 +69,6 @@ Password: Admin@123456
|
||||
```
|
||||
|
||||
URLs dev:
|
||||
- API: http://localhost:5443 — Swagger ở `/swagger`
|
||||
- API: http://localhost:5443 — Swagger `/swagger`
|
||||
- Admin FE: http://localhost:8082
|
||||
- User FE: http://localhost:8080
|
||||
|
||||
Reference in New Issue
Block a user