Giao diện
Danh mục & Sản phẩm
Trang sinh tự động
Phần nghiệp vụ viết tay; API, dữ liệu, quyền, đường dẫn và file nguồn do bộ sinh điền từ source tại ad83b0aea.
Làm gì
Cây ngành hàng (tối đa 5 cấp, sản phẩm chỉ gắn vào lá), thương hiệu, đơn vị tính có quy đổi, và sản phẩm — loại thường hoặc combo. Thông số sản phẩm là một catalog riêng theo ngành hàng, thừa kế xuống cây. Có nhập và xuất Excel, giới hạn 1.000 dòng mỗi lần nhập.
Quy mô
| Domain API | catalog, product, product-attribute, product-file |
| Query / Mutation | 25 / 29 |
| Nguồn dữ liệu | catalog |
| Bảng | 16 |
| Luật phân quyền | 3 |
| Đường dẫn Web Admin | 12 |
Thao tác (mutation)
| Mutation | Domain | Mô tả |
|---|---|---|
addProductAttributeOption | product-attribute | Add an option (drawer, or quick add on the product form, Q4). Requires catalog.write. |
bulkRestoreProducts | product | Restore 1..500 deleted products in ONE transaction, all or nothing: one |
bulkSetProductStatus | product | Discontinue, reactivate or delete the selected products in ONE |
createProductAttribute | product-attribute | Create an attribute (drawer, or the product form popup: saved at once). Requires catalog.write. |
deleteBrand | catalog | Soft-delete a brand; always allowed, its live products lose the link. Requires catalog.write. |
deleteBrands | catalog | Soft-delete several brands at once, all or none (TH-US-04 AC03). Brands |
deleteCategories | catalog | Soft-delete several categories at once, all or none. Refused, deleting |
deleteCategory | catalog | Soft-delete a category without live children. Requires catalog.write. |
deleteProductAttribute | product-attribute | Soft-delete an attribute no product uses (Xoá hẳn; else conflict attribute_in_use). Requires catalog.write. |
deleteProductAttributeOption | product-attribute | Remove an option no product uses. Requires catalog.write. |
deleteProductUnit | catalog | Soft-delete an unused unit; conflict{reason: unit_in_use, productCount, usedBy, usage} while anything uses it (usedBy: PRODUCTS, BASE_OF_UNITS, ACCESSORIES, ATTRIBUTES, ATTRIBUTE_VALUES). Requires catalog.write. |
exportProductHistory | product | Export the change history of one product (the page filters, newest first, last 24 months) as a private .xlsx. |
exportProducts | product-file | Export every product matching the list filters to .xlsx in one step (no |
importProducts | product-file | Validate or import products from an Excel file (<= 1,000 rows): every |
mergeProductAttribute | product-attribute | Merge source into target in one transaction (design §4): values move (or convert), the source is soft-deleted |
moveProductAttribute | product-attribute | Chuyển vào ngành hàng / Chuyển thành Chung (name taken: conflict duplicate_name). Requires catalog.write. |
reorderProductAttributeOptions | product-attribute | Order the options. Requires catalog.write. |
reorderProductAttributes | product-attribute | Order the attributes of one category (drag and drop). Requires catalog.write. |
restoreProduct | product | Restore one soft-deleted product as Ngừng bán. Requires catalog.write |
saveBrand | catalog | Create or edit a brand. Requires catalog.write. |
saveCategory | catalog | Create or edit a category. Requires catalog.write. |
saveProduct | product | Create (Save draft / Save product) or edit a product. Requires catalog.write. |
saveProductColumnPreference | product | Save the calling Admin's product-list columns ("Áp dụng"; "Đặt lại mặc |
saveProductUnit | catalog | Create or edit a product unit. Requires catalog.write. |
setProductAttributeOptionStatus | product-attribute | Deactivate or reactivate an option. Requires catalog.write. |
setProductStatus | product | Discontinue, reactivate or delete a product. Requires catalog.write. |
setProductUnitStatus | catalog | Deactivate or reactivate a unit; allowed while products use it (they keep it). Requires catalog.write. |
updateProductAttribute | product-attribute | Edit an attribute. Requires catalog.write. |
updateProductAttributeOption | product-attribute | Rename an option. Requires catalog.write. |
Phép đọc (query)
| Query | Domain | Mô tả |
|---|---|---|
brands | catalog | Flat list of live brands (WEB_ADMIN); a deleted brand never appears. |
catalogKeyAvailability | catalog | Is a category or brand code / name free among live rows (soft-deleted rows |
categories | catalog | Category tree in tree order, siblings by name A to Z (Vietnamese order). Search is case-insensitive and |
categoryDeletePreview | catalog | The delete popup line 'N thông số sẽ chuyển sang Lưu trữ, M sản phẩm giữ giá trị' (single and batch). Requires catalog.write. |
categoryTree | catalog | The whole category tree, not paged (WEB_ADMIN). search: case-insensitive, |
deletedProducts | product | Soft-deleted products only (WEB_ADMIN, ADD-SP-03); never a live row. Search |
previewProductAttributeMerge | product-attribute | Compatibility, counts, conflicts and the unit / option mapping of a merge (wizard step 3). Requires catalog.write. |
product | product | One product for the detail/edit screen (SP-US-03): every field, creator and |
productAttribute | product-attribute | One live attribute (drawer). A deleted or merged one is not_found. Requires catalog.read. |
productAttributeNameSuggestions | product-attribute | Near-identical names while typing (unaccented, spaces folded, pg_trgm when available), in the scope of |
productAttributes | product-attribute | Product attributes (WEB_ADMIN), deleted and merged ones never included, with the chip counts. Without forProduct: |
productBulkPreview | product | The SP-US-04 popup before confirming (also for one product, ids: [id]): |
productCodeAvailability | product | Duplicate check while typing / on blur (SP-US-02 AC01, SP-US-03 AC05): |
productColumnPreference | product | The calling Admin's product-list columns, or the default when none are saved. Requires catalog.read. |
productComponentSearch | product | Products that may be added to a combo (SP-US-02 AC04-AC06): standard, |
productHistory | product | Change events of one product, newest first (occurredAt, ties by sequence), |
productHistoryActors | product | Admins who changed the product (unfiltered, for the actor filter). Requires catalog.read. |
productHistoryRecent | product | The latest events of a product (detail card, default 4, at most 20). Requires catalog.read. |
productImportPreflight | product-file | Checks a chosen file before 'Kiểm tra dữ liệu': not an .xlsx template or |
productImportTemplate | product-file | The .xlsx import template: sheet 1 'Sản phẩm' (the only sheet the import |
products | product | Products (WEB_ADMIN, SP-US-01), deleted ones never included. Search is |
productUnitNameAvailability | catalog | Is a unit name free among live units (excludeId leaves out the unit being |
productUnitOptions | catalog | ACTIVE units only, A to Z (Vietnamese order), for the product form. |
productUnits | catalog | Live units (WEB_ADMIN); a deleted unit never appears. search: case-insensitive, |
productUnitUnmatched | catalog | Old product unit labels without a unit, most affected live products first. |
Dữ liệu
- Domain
catalog— 16 bảng, 2 nhóm con: product (13) · bảng đơn lẻ (3) (3)
Bảng được tham chiếu nhiều nhất trong module:
| Bảng | Cột | Được trỏ tới | RLS |
|---|---|---|---|
products | 32 | 9 | ✓ |
product_units | 15 | 6 | ✓ |
product_attributes | 21 | 4 | ✓ |
categories | 16 | 3 | ✓ |
product_attribute_options | 13 | 2 | ✓ |
brands | 14 | 1 | ✓ |
product_attribute_values | 18 | 1 | ✓ |
product_import_runs | 14 | 1 | ✓ |
combo_components | 6 | 0 | ✓ |
product_accessories | 14 | 0 | ✓ |
Quyền
| Mã | Quyền | Ứng dụng | Vai trò | Phạm vi | Trạng thái |
|---|---|---|---|---|---|
CAT-01 | catalog.read | WEB_ADMIN | operations admin | ALL | PROPOSED |
CAT-02 | catalog.write | WEB_ADMIN | operations admin | ALL | PROPOSED |
CAT-03 | catalog.read | WEB_ADMIN | super_admin | ALL | PROPOSED |
Danh sách đầy đủ và cách đọc các cờ: Ma trận quyền.
Giao diện Web Admin
| Đường dẫn | Hằng số |
|---|---|
/products | PRODUCTS |
/products/:id | PRODUCT_DETAIL |
/products/:id/edit | PRODUCT_EDIT |
/products/:id/history | PRODUCT_HISTORY |
/products/attributes | PRODUCT_ATTRIBUTES |
/products/brands | PRODUCT_BRANDS |
/products/categories | PRODUCT_CATEGORIES |
/products/categories/:id | PRODUCT_CATEGORY_DETAIL |
/products/deleted | PRODUCT_DELETED |
/products/import | PRODUCT_IMPORT |
/products/new | PRODUCT_NEW |
/products/units | PRODUCT_UNITS |
File nguồn
Backend:
code/apps/api/supabase/functions/graphql/domains/catalog/code/apps/api/supabase/functions/graphql/domains/product/code/apps/api/supabase/functions/graphql/domains/product-attribute/code/apps/api/supabase/functions/graphql/domains/product-file/
Dữ liệu: bảng thuộc domain catalog — xem Cơ sở dữ liệu.