[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:
11
src/Backend/SolutionErp.Domain/Master/Department.cs
Normal file
11
src/Backend/SolutionErp.Domain/Master/Department.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using SolutionErp.Domain.Common;
|
||||
|
||||
namespace SolutionErp.Domain.Master;
|
||||
|
||||
public class Department : AuditableEntity
|
||||
{
|
||||
public string Code { get; set; } = string.Empty; // vd "CCM", "PRO", "FIN"
|
||||
public string Name { get; set; } = string.Empty; // vd "Phòng Kiểm soát Chi phí"
|
||||
public Guid? ManagerUserId { get; set; } // TPB — Trưởng Phòng ban
|
||||
public string? Note { get; set; }
|
||||
}
|
||||
14
src/Backend/SolutionErp.Domain/Master/Project.cs
Normal file
14
src/Backend/SolutionErp.Domain/Master/Project.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using SolutionErp.Domain.Common;
|
||||
|
||||
namespace SolutionErp.Domain.Master;
|
||||
|
||||
public class Project : AuditableEntity
|
||||
{
|
||||
public string Code { get; set; } = string.Empty; // vd "FLOCK 01"
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public DateTime? StartDate { get; set; }
|
||||
public DateTime? EndDate { get; set; }
|
||||
public Guid? ManagerUserId { get; set; } // PM — Giám đốc Dự án
|
||||
public decimal? BudgetTotal { get; set; } // Tổng ngân sách dự án (tham chiếu cho CCM check)
|
||||
public string? Note { get; set; }
|
||||
}
|
||||
16
src/Backend/SolutionErp.Domain/Master/Supplier.cs
Normal file
16
src/Backend/SolutionErp.Domain/Master/Supplier.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using SolutionErp.Domain.Common;
|
||||
|
||||
namespace SolutionErp.Domain.Master;
|
||||
|
||||
public class Supplier : AuditableEntity
|
||||
{
|
||||
public string Code { get; set; } = string.Empty; // Mã NCC (viết tắt, dùng trong mã HĐ)
|
||||
public string Name { get; set; } = string.Empty; // Tên công ty đầy đủ
|
||||
public SupplierType Type { get; set; }
|
||||
public string? TaxCode { get; set; } // Mã số thuế
|
||||
public string? Phone { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? Address { get; set; }
|
||||
public string? ContactPerson { get; set; } // Người liên hệ
|
||||
public string? Note { get; set; }
|
||||
}
|
||||
10
src/Backend/SolutionErp.Domain/Master/SupplierType.cs
Normal file
10
src/Backend/SolutionErp.Domain/Master/SupplierType.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace SolutionErp.Domain.Master;
|
||||
|
||||
public enum SupplierType
|
||||
{
|
||||
NhaCungCap = 1, // NCC — Nhà cung cấp
|
||||
NhaThauPhu = 2, // NTP — Nhà thầu phụ
|
||||
ToDoi = 3, // TĐ — Tổ đội
|
||||
DonViDichVu = 4, // ĐVDV — Đơn vị dịch vụ
|
||||
ChuDauTu = 5, // CĐT — Chủ đầu tư (đặc biệt, bypass quy trình CCM)
|
||||
}
|
||||
Reference in New Issue
Block a user