[CLAUDE] Domain+App+Api: 4 master catalogs cho Details (migration 10)
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 2m48s
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 2m48s
User feedback: thêm Master Data cho phần Chi tiết (line items) — autocomplete khi user nhập field thay vì gõ tay free text. ## 4 entities mới (Domain/Master/Catalogs/) | Entity | Bảng | Dùng cho HĐ Detail | |---|---|---| | UnitOfMeasure | UnitsOfMeasure | Tất cả 7 type (DonViTinh) | | MaterialItem | MaterialItems | NCC + Mua bán + Nguyên tắc NCC (MaSP/TenSP) | | ServiceItem | ServiceItems | Dịch vụ + Nguyên tắc DV (MaDichVu/TenDichVu) | | WorkItem | WorkItems | Thầu phụ + Giao khoán (HangMuc/MaCongViec) | Common pattern: Code unique (filter IsDeleted=0) + Name + Category + DefaultUnit + AuditableEntity (soft delete) + IsActive flag. ## Migration 10: AddMasterCatalogs 3-file rule (gotcha #17). Total DB: 32 → 36 tables. Apply LocalDB OK. ## Seed defaults (idempotent — skip per-table nếu có row) - 20 UnitsOfMeasure: m2, m3, kg, tấn, lít, ngc (ngày công), giờ, gói, ... - 15 MaterialItems demo: xi măng PCB40, cát vàng, đá 1x2, thép D10, gạch 4 lỗ, sơn lót, ống PVC... - 10 ServiceItems demo: vận chuyển, bảo trì, tư vấn, kiểm định, vệ sinh... - 15 WorkItems demo: đào móng, đổ bê tông, xây tường, trát, lát gạch, sơn nước, lắp điện, lắp nước, thấm chống... ## CQRS (Application/Master/Catalogs/CatalogsFeatures.cs ~290 dòng) Mỗi catalog 5 handlers (List filter q+category, Create với unique code guard, Update, Delete soft). FluentValidation max length per spec EF. ## Controller (Api/Controllers/CatalogsController.cs) 13 endpoints: - GET /api/catalogs/{units|materials|services|work-items} - POST /api/catalogs/{kind} (Admin role) - PUT /api/catalogs/{kind}/{id} (Admin role) - DELETE /api/catalogs/{kind}/{id} (Admin role) Read open cho mọi role (FE Details add form autocomplete cần list). ## Menu (5 mới) - Catalogs (group, Master parent, order 24, "Library" icon) - CatalogUnits "Đơn vị tính" (Ruler) - CatalogMaterials "Vật tư / SP" (Package) - CatalogServices "Dịch vụ" (Wrench) - CatalogWorkItems "Hạng mục công việc" (ListChecks) Admin auto-grant tất cả CRUD action (qua SeedAdminPermissionsAsync loop MenuKeys.All). ## Build dotnet build BE pass (0 error) ## Note FE admin page CatalogsPage + datalist autocomplete trong Details form sẽ ở commit kế tiếp. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@ -18,6 +18,13 @@ public static class MenuKeys
|
||||
public const string Permissions = "Permissions";
|
||||
public const string Workflows = "Workflows";
|
||||
|
||||
// 4 master catalogs cho Details add form (autocomplete) — admin CRUD
|
||||
public const string Catalogs = "Catalogs"; // group
|
||||
public const string CatalogUnits = "CatalogUnits";
|
||||
public const string CatalogMaterials = "CatalogMaterials";
|
||||
public const string CatalogServices = "CatalogServices";
|
||||
public const string CatalogWorkItems = "CatalogWorkItems";
|
||||
|
||||
// Per-contract-type menu groups + 3 action leaves each.
|
||||
// Key format: Ct_<TypeCode>[_<Action>] — prefix `Ct_` distinguishes from
|
||||
// top-level. Menu tree endpoint (GetMyMenuTreeQuery) treats descendants of
|
||||
@ -39,6 +46,7 @@ public static class MenuKeys
|
||||
[
|
||||
Dashboard,
|
||||
Master, Suppliers, Projects, Departments,
|
||||
Catalogs, CatalogUnits, CatalogMaterials, CatalogServices, CatalogWorkItems,
|
||||
Contracts, Forms, Reports,
|
||||
System, Users, Roles, Permissions, Workflows,
|
||||
];
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
using SolutionErp.Domain.Common;
|
||||
|
||||
namespace SolutionErp.Domain.Master.Catalogs;
|
||||
|
||||
// Master danh mục vật tư / sản phẩm — dùng cho HĐ NCC, Mua bán, Nguyên tắc NCC.
|
||||
// Khi user nhập Details: autocomplete từ danh mục này để autofill Mã/Tên/ĐVT/Spec.
|
||||
public class MaterialItem : AuditableEntity
|
||||
{
|
||||
public string Code { get; set; } = ""; // Mã SP (unique)
|
||||
public string Name { get; set; } = ""; // Tên SP
|
||||
public string? Category { get; set; } // Nhóm SP (vd "Vật liệu xây dựng", "Sắt thép")
|
||||
public string? DefaultUnit { get; set; } // ĐVT mặc định (autofill khi chọn)
|
||||
public string? Specification { get; set; } // Thông số kỹ thuật mẫu
|
||||
public string? OriginCountry { get; set; } // Xuất xứ
|
||||
public bool IsActive { get; set; } = true;
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
using SolutionErp.Domain.Common;
|
||||
|
||||
namespace SolutionErp.Domain.Master.Catalogs;
|
||||
|
||||
// Master danh mục dịch vụ — dùng cho HĐ Dịch vụ + Nguyên tắc Dịch vụ.
|
||||
public class ServiceItem : AuditableEntity
|
||||
{
|
||||
public string Code { get; set; } = ""; // Mã DV
|
||||
public string Name { get; set; } = ""; // Tên DV
|
||||
public string? Category { get; set; } // Loại DV (vd "Vận chuyển", "Bảo trì", "Tư vấn")
|
||||
public string? DefaultUnit { get; set; } // ĐVT mặc định (giờ, ngày, gói, lần...)
|
||||
public string? Description { get; set; }
|
||||
public bool IsActive { get; set; } = true;
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
using SolutionErp.Domain.Common;
|
||||
|
||||
namespace SolutionErp.Domain.Master.Catalogs;
|
||||
|
||||
// Master danh mục đơn vị tính dùng cho mọi loại HĐ Details (m2, kg, ngày
|
||||
// công, gói, bộ, ...). Code = unique short identifier; Name = label tiếng Việt.
|
||||
public class UnitOfMeasure : AuditableEntity
|
||||
{
|
||||
public string Code { get; set; } = ""; // vd "m2", "kg", "ngc"
|
||||
public string Name { get; set; } = ""; // vd "Mét vuông", "Kilogram", "Ngày công"
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
14
src/Backend/SolutionErp.Domain/Master/Catalogs/WorkItem.cs
Normal file
14
src/Backend/SolutionErp.Domain/Master/Catalogs/WorkItem.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using SolutionErp.Domain.Common;
|
||||
|
||||
namespace SolutionErp.Domain.Master.Catalogs;
|
||||
|
||||
// Master danh mục hạng mục công việc — dùng cho HĐ Thầu phụ + Giao khoán.
|
||||
public class WorkItem : AuditableEntity
|
||||
{
|
||||
public string Code { get; set; } = ""; // Mã hạng mục (vd "DAO_MONG", "DO_BTONG")
|
||||
public string Name { get; set; } = ""; // Tên hạng mục
|
||||
public string? Category { get; set; } // Nhóm (vd "Phần thô", "Hoàn thiện", "Cơ điện")
|
||||
public string? DefaultUnit { get; set; } // ĐVT mặc định
|
||||
public string? Description { get; set; } // Mô tả + spec yêu cầu
|
||||
public bool IsActive { get; set; } = true;
|
||||
}
|
||||
Reference in New Issue
Block a user