Files
ruoyi-vue-pro/docs/education/migration/issues/EDU-025-native-mall-product.md

5.4 KiB
Raw Blame History

EDU-025 — Activate native Mall Product

  • Status: done — tenant-owned native Product persistence, existing Product APIs/UI, RBAC, and PostgreSQL evidence delivered
  • Type: native module takeover / product catalog / tenant isolation
  • Phase: 5 / commercialization foundation
  • Blockers: EDU-013, PostgreSQL Flyway

Problem

RuoYi Vue Pro already provides Product controllers, services, mappers, permissions, and Vben pages for brands, categories, properties, SPUs, SKUs, comments, favorites, and browse history. The Mall reactor and Product server dependency were disabled, however, and the Product data objects were not tenant-aware. Rebuilding those capabilities inside Education would create a second product catalog.

The legacy public.products object is only a tenant/region presentation projection with title, a display price_label, links, tags, cover/iframe/detail images, ordering, and lifecycle status. It has no authoritative SKU, integer price, stock, brand, property, delivery, commission, or sales model. An automatic conversion would invent commercial facts.

Delivered contract

  • The root build now includes yudao-module-mall, while yudao-server activates only yudao-module-product. Promotion, Trade, and Statistics runtime dependencies remain off until their own tenant-ledger slices are verified.
  • Existing native /product/brand, /product/category, /product/property, /product/property/value, /product/spu, /product/comment, /product/favorite, and /product/browse-history controllers remain authoritative. No Education product controller or duplicate catalog service was added.
  • ProductBrandDO, ProductCategoryDO, ProductPropertyDO, ProductPropertyValueDO, ProductSpuDO, ProductSkuDO, ProductCommentDO, ProductFavoriteDO, and ProductBrowseHistoryDO now extend TenantBaseDO, so normal MyBatis access participates in framework tenant injection.
  • Existing Vben pages are reused for SPU/SKU authoring, category trees, brands, property/value management, and comment moderation. V4370 seeds their original permissions below an Education 商品中心 route with unique component names.
  • The Product Vben scope passes typecheck, oxlint, and oxfmt. The formatter normalized one pre-existing multiline expression in the SPU form without changing behavior.

Database contract

V4370 creates tenant-scoped PostgreSQL tables:

  • product_brand
  • product_category
  • product_property
  • product_property_value
  • product_spu
  • product_sku
  • product_comment
  • product_favorite
  • product_browse_history

Every table uses (tenant_id,id) as its primary ownership key, allowing an explicit native identifier to be reused in another tenant while keeping every reference tenant-qualified. Composite foreign keys enforce Property Value → Property, SPU → Category/Brand, SKU → SPU, Comment → SPU/SKU, and Favorite/Browse History → SPU. Category root parent_id=0 remains a sentinel; a trigger requires non-root parents to exist in the same tenant and limits the native category model to two levels.

Database checks reject negative prices, stock, sales, integral, commission, weight, volume, and browse counts, and restrict comment scores to 15. Partial unique indexes protect active brand/property/value names, one active favorite per member/SPU, one active browse-history row per member/SPU, and one active comment per member/order item. Existing global Product tables fail closed instead of being silently assigned to a tenant.

V4370 seeds menu IDs 69206944 for the Product root, five native pages, and the exact SPU, Category, Brand, Property, and Comment controller permissions.

Legacy data decision

V4370 creates an empty native catalog and does not read or transform legacy public.products. A later import, if required, must provide an explicit reviewed mapping for tenant UUIDs, region semantics, integer prices, SPU/SKU structure, stock authority, brand/category/property ownership, delivery mode, media admission, and Education resource bindings. A display price label or URL is not sufficient evidence for any of those fields.

Verification

  • The focused Product tenant contract passes and proves all nine native Product records inherit TenantBaseDO.
  • The Product reactor test run succeeds; the repository's 33 pre-existing Product service tests remain disabled by their existing test configuration, while the new tenant contract executes successfully.
  • All 45 PostgreSQL Flyway integration tests pass through V4380. V4370 coverage proves cross-tenant ID reuse, same-tenant uniqueness, composite foreign-key rejection, category parent isolation/two-level enforcement, amount/stock and score checks, exact menu shape, migration history, and fail-closed global-table adoption.
  • mvn -pl yudao-server -am -DskipTests compile succeeds with Product enabled.
  • @vben/web-antd typecheck and scoped Product oxlint/oxfmt checks pass.

Explicitly open

  • Native Product pages require target-environment role grants, browser/API smoke evidence, media/file configuration, and deliberate catalog population.
  • Promotion coupons are delivered by EDU-026; Promotion discounts and other activity families, Trade cart/order/after-sale/delivery, Statistics, automatic purchase fulfillment, refund-driven entitlement revocation, and Education product-binding workflows remain separate slices.
  • Legacy products import remains blocked on an explicit semantic mapping and reconciled source artifact; no SKU, stock, price, or category is inferred.