[CLAUDE] Scaffold: khoi tao SOLUTION_ERP Phase 0
- .NET 10 Clean Architecture: Domain/Application/Infrastructure/Api (4 project) - 2 React + Vite + TS app: fe-admin (:8082), fe-user (:8080) voi proxy /api - Node engines >=20, .nvmrc = 20 cho CI (bai hoc NamGroup) - SQL Server 2022 qua docker-compose (dev) - Parse 8 FORM -> docs/forms-spec.md (catalog + ma HD format RG-001) - Parse QUY_TRINH -> docs/workflow-contract.md (9 phase state machine + role matrix) - docs: CLAUDE.md, STATUS.md, PROJECT-MAP.md, migration-todos.md (roadmap 5 phase) - .claude/skills: 3 placeholder (contract-workflow, form-engine, permission-matrix) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
164
docs/changelog/migration-todos.md
Normal file
164
docs/changelog/migration-todos.md
Normal file
@ -0,0 +1,164 @@
|
||||
# Migration To-dos — Atomic Roadmap
|
||||
|
||||
> Mỗi item là 1 task atomic (~2-8h work). Tick `[x]` khi xong. Link session log nếu có.
|
||||
|
||||
## Phase 0 — Draft Scaffold (T1)
|
||||
|
||||
- [x] Tạo cấu trúc thư mục `SOLUTION_ERP/`
|
||||
- [x] Scaffold .NET 10 solution `SolutionErp.slnx`
|
||||
- [x] Scaffold 4 project: `SolutionErp.{Domain, Application, Infrastructure, Api}`
|
||||
- [x] Wire Clean Arch references (Api → App/Infra, Infra → App, App → Domain)
|
||||
- [x] Install NuGet base: MediatR, FluentValidation, AutoMapper, EF Core SqlServer, Identity, JWT, Swagger, Serilog
|
||||
- [x] Scaffold 2 React + Vite apps `fe-admin` + `fe-user` với TS template
|
||||
- [x] Config vite.config.ts: port, strictPort, proxy `/api`, alias `@`
|
||||
- [x] Pin Node `>=20` trong package.json + `.nvmrc` cho CI
|
||||
- [x] Parse 8 form → `docs/forms-spec.md`
|
||||
- [x] Parse quy trình → `docs/workflow-contract.md`
|
||||
- [x] Viết `docs/{CLAUDE,STATUS,PROJECT-MAP}.md`
|
||||
- [ ] Viết `.gitignore`, `README.md`, `global.json`, `docker-compose.yml`
|
||||
- [ ] Tạo placeholder skill folders: `contract-workflow`, `form-engine`, `permission-matrix`
|
||||
- [ ] `git init` + commit đầu
|
||||
- [ ] Push Gitea remote (chờ URL từ user)
|
||||
|
||||
## Phase 1 — Alpha Core (T2-4)
|
||||
|
||||
### Backend foundation
|
||||
|
||||
- [ ] `Domain/BaseEntity.cs` (Id, CreatedAt, UpdatedAt, CreatedBy, UpdatedBy)
|
||||
- [ ] `Domain/AuditableEntity : BaseEntity` (IsDeleted, DeletedAt, DeletedBy)
|
||||
- [ ] `Domain/ValueObjects/ContractCode.cs` (wrap string theo format RG-001)
|
||||
- [ ] `Domain/Enums/ContractType.cs`, `ContractPhase.cs`, `ApprovalDecision.cs`
|
||||
- [ ] `Application/Common/IApplicationDbContext.cs` interface
|
||||
- [ ] `Application/Common/IDateTime.cs`, `ICurrentUser.cs`
|
||||
- [ ] `Application/DependencyInjection.cs` — register MediatR, FluentValidation, AutoMapper
|
||||
- [ ] `Infrastructure/Persistence/ApplicationDbContext.cs` : `IdentityDbContext<User, Role, Guid>`, `IApplicationDbContext`
|
||||
- [ ] Configurations per entity qua `IEntityTypeConfiguration<T>`
|
||||
- [ ] `Infrastructure/DependencyInjection.cs` — register DbContext, Identity, services
|
||||
- [ ] `Api/Program.cs` setup: services, Serilog, auth, Swagger, CORS, middleware
|
||||
- [ ] `Api/Middleware/GlobalExceptionMiddleware.cs`
|
||||
|
||||
### Auth + Identity
|
||||
|
||||
- [ ] `Domain/Entities/User : IdentityUser<Guid>`, `Role : IdentityRole<Guid>`
|
||||
- [ ] Migration 1: `Init` (Identity tables)
|
||||
- [ ] `Application/Auth/Commands/LoginCommand` + handler + validator
|
||||
- [ ] `Application/Auth/Commands/RefreshTokenCommand`
|
||||
- [ ] `Api/Controllers/AuthController` (login, refresh, logout, me)
|
||||
- [ ] JWT config: issuer, audience, key, expiry 1h + refresh 7d
|
||||
- [ ] Seed admin: `admin@solutionerp.local` / `Admin@123456`
|
||||
- [ ] Test login → get token → call `/me` OK
|
||||
|
||||
### Permission Matrix
|
||||
|
||||
- [ ] `Domain/Entities/MenuItem` (Key, Label, ParentKey, Order, Icon)
|
||||
- [ ] `Domain/Entities/Permission` (RoleId, MenuKey, CanRead, CanCreate, CanUpdate, CanDelete)
|
||||
- [ ] Seed default menu tree (based on FE screens list)
|
||||
- [ ] `Application/Permissions/Queries/GetMyMenuTree` — resolve per-user
|
||||
- [ ] `Api/Controllers/MenusController` + `RolesController` + `PermissionsController`
|
||||
- [ ] Admin UI: Permission Matrix grid (role × menu × CRUD checkbox)
|
||||
|
||||
### CRUD master data
|
||||
|
||||
- [ ] `Domain/Entities/Supplier` (Code, Name, TaxCode, Phone, Email, Address, Type: NCC/NTP/TĐ/ĐVDV)
|
||||
- [ ] `Domain/Entities/Project` (Code, Name, StartDate, EndDate, Manager)
|
||||
- [ ] `Domain/Entities/Department` (Code, Name, Manager)
|
||||
- [ ] CQRS + Controller + Migration cho 3 entity
|
||||
- [ ] FE admin 3 trang CRUD (list, create, edit, delete confirm)
|
||||
- [ ] Pagination, search, sort server-side
|
||||
|
||||
### Contract draft (chưa workflow — chỉ CRUD)
|
||||
|
||||
- [ ] `Domain/Entities/Contract` (skeleton: Id, Type, SupplierId, ProjectId, Phase=DangChon, DraftData)
|
||||
- [ ] API create/update/list/delete draft
|
||||
- [ ] FE admin: list contracts + filter
|
||||
- [ ] FE user: "HĐ của tôi" list
|
||||
|
||||
### FE setup
|
||||
|
||||
- [ ] Install Tailwind CSS cho 2 app + config content paths
|
||||
- [ ] Install shadcn/ui CLI, init 2 app
|
||||
- [ ] Install: `@tanstack/react-query`, `react-router-dom`, `axios`, `lucide-react`, `sonner`
|
||||
- [ ] `src/lib/api.ts` — axios instance + interceptor JWT
|
||||
- [ ] `src/contexts/AuthContext.tsx` — token từ localStorage
|
||||
- [ ] `src/components/PermissionGuard.tsx` + `usePermission()` hook
|
||||
- [ ] Layout shell: sidebar + header + content
|
||||
- [ ] Route với protected route + role guard
|
||||
- [ ] Toast notifications (sonner)
|
||||
|
||||
### Exit criteria Phase 1
|
||||
|
||||
- [ ] Admin login → tạo NCC/Project → tạo role "Nhân viên CCM" → gán permission menu "Contracts.Read"
|
||||
- [ ] User CCM login → thấy menu Contracts, không thấy menu Admin
|
||||
- [ ] Tạo Contract draft → list hiển thị, không bị 403 sai
|
||||
|
||||
## Phase 2 — Form Engine (T5-6)
|
||||
|
||||
- [ ] Khảo sát: OpenXml vs Aspose.Words — chọn 1 (Aspose có license phí; OpenXml free nhưng verbose)
|
||||
- [ ] Convert 3 file `.doc` → `.docx` (COM automation PowerShell hoặc LibreOffice headless)
|
||||
- [ ] Parse chi tiết field của 5 template HĐ — mỗi form thành JSON spec
|
||||
- [ ] `Domain/Entities/ContractTemplate` (Id, FormCode, Name, TemplateFile path, FieldSpec JSON)
|
||||
- [ ] `Application/Forms/Services/IFormRenderer` — input: template + data dict → output: byte[] (.docx)
|
||||
- [ ] Implement `DocxRenderer` (OpenXml-based replace placeholder)
|
||||
- [ ] Implement `XlsxRenderer` cho FO-002.07 (dùng EPPlus/ClosedXML)
|
||||
- [ ] `Api/Controllers/FormsController` — GET /templates, POST /render
|
||||
- [ ] FE user: form builder — chọn template → dynamic form → preview → export
|
||||
- [ ] FE admin: upload template mới, edit field mapping
|
||||
- [ ] Lưu `ContractClause` (FO-002.04) dạng rich text, admin edit qua TipTap/TinyMCE
|
||||
- [ ] Import/export template (để backup)
|
||||
- [ ] Test: 1 HĐ Giao khoán filled → export .docx mở bằng Word y hệt mẫu
|
||||
|
||||
## Phase 3 — Workflow State Machine (T7-9)
|
||||
|
||||
- [ ] `Domain/Entities/ContractApproval` + `ContractComment` + `ContractAttachment`
|
||||
- [ ] `Domain/Entities/Contract` update: thêm `Phase`, `SlaDeadline`, `BypassProcurementAndCCM`
|
||||
- [ ] `Domain/Services/IContractWorkflowService.TransitionAsync(...)` — state guard + role guard + side effects
|
||||
- [ ] `Infrastructure/Services/ContractCodeGenerator` (implement RG-001) với locking cho seq
|
||||
- [ ] `Infrastructure/HostedServices/SlaExpiryJob` — check mỗi 15min, auto-approve quá hạn
|
||||
- [ ] `Infrastructure/Services/NotificationService` — email (MailKit) + in-app (SignalR optional)
|
||||
- [ ] MediatR behavior: `AuditBehavior` — log mọi command
|
||||
- [ ] API: `POST /api/contracts/{id}/transitions` body: `{targetPhase, comment}`
|
||||
- [ ] FE user Inbox: list "HĐ chờ tôi xử lý" (query by current phase + user role)
|
||||
- [ ] FE Contract detail page: timeline 9 phase, approval panel, comment thread
|
||||
- [ ] Upload attachment (scan có chữ ký đối tác)
|
||||
- [ ] Notification UI: badge count, dropdown, click → detail
|
||||
- [ ] E2E test: happy path end-to-end 1 HĐ qua 9 phase
|
||||
- [ ] E2E test: reject → quay về DangSoanThao
|
||||
- [ ] E2E test: SLA expired → auto-approve + log
|
||||
|
||||
## Phase 4 — Reporting + Polish (T10-11)
|
||||
|
||||
- [ ] Dashboard admin: số HĐ theo phase, top NCC, top dự án, tổng giá trị theo tháng
|
||||
- [ ] Excel export theo bộ lọc (dùng EPPlus)
|
||||
- [ ] Report: HĐ quá hạn SLA bao nhiêu lần theo phase/role
|
||||
- [ ] UX polish: skeleton loader, empty state, error boundary có recovery button
|
||||
- [ ] Accessibility: keyboard nav, focus trap modal, aria labels
|
||||
- [ ] Dark mode (optional, nếu rảnh)
|
||||
- [ ] Performance: index DB cho query hot (SupplierId, ProjectId, Phase)
|
||||
- [ ] Tài liệu user guide: quy trình tạo HĐ + duyệt
|
||||
- [ ] UAT với 5-10 HĐ dữ liệu thật từ bộ phận Cung ứng
|
||||
|
||||
## Phase 5 — Production (T12-13)
|
||||
|
||||
- [ ] `docs/guides/cicd.md` — CI/CD runbook
|
||||
- [ ] Gitea Actions workflow `.gitea/workflows/deploy.yml` — build .NET + 2 FE, deploy IIS qua SSH/WinRM
|
||||
- [ ] Pin Node 20.x trong workflow, test CI sớm (không để surprise cuối dự án)
|
||||
- [ ] `scripts/deploy-iis.ps1` — stop app pool, xcopy, start app pool
|
||||
- [ ] Windows Server setup: IIS + URL Rewrite + ARR (reverse proxy FE → IIS)
|
||||
- [ ] SQL Server prod: backup plan daily + weekly full
|
||||
- [ ] HTTPS certificate (Let's Encrypt qua win-acme hoặc mua cert)
|
||||
- [ ] `appsettings.Production.json` + user secrets
|
||||
- [ ] Security audit: owasp top 10 check
|
||||
- [ ] Rate limiting middleware (AspNetCoreRateLimit hoặc built-in)
|
||||
- [ ] Health check endpoint `/health` cho IIS probe
|
||||
- [ ] Error tracking: Serilog → file rolling daily, retention 30 ngày
|
||||
- [ ] Runbook: restart app, rollback migration, restore backup
|
||||
- [ ] UAT production 1 tuần với 2-3 user thật
|
||||
- [ ] Go-live checklist: backup, rollback plan, on-call contact
|
||||
|
||||
## Post-launch (Phase 6+ — future)
|
||||
|
||||
- [ ] E-signature integration (VNPT CA hoặc FPT CA)
|
||||
- [ ] Tích hợp Bravo / SAP ERP import NCC
|
||||
- [ ] Mobile app (React Native?) cho BOD duyệt ngoài giờ
|
||||
- [ ] AI: gợi ý điền form dựa HĐ cũ, OCR scan HĐ đối tác
|
||||
- [ ] Multi-tenant nếu có công ty thứ 2
|
||||
Reference in New Issue
Block a user