diff --git a/site/src/main/java/com/shoplix/site/modules/product/res/ProductDetailSiteRes.java b/site/src/main/java/com/shoplix/site/modules/product/res/ProductDetailSiteRes.java index c18ce41..afef942 100644 --- a/site/src/main/java/com/shoplix/site/modules/product/res/ProductDetailSiteRes.java +++ b/site/src/main/java/com/shoplix/site/modules/product/res/ProductDetailSiteRes.java @@ -3,10 +3,21 @@ package com.shoplix.site.modules.product.res; import java.util.List; /** 前台站产品详情响应。 */ -public record ProductDetailSiteRes(String productCode, String productName, String slug, String model, - String summary, String content, String coverMediaCode, - String coverMediaUrl, List images, Boolean inquiryEnabled, - List attributes, - List specifications) { +public record ProductDetailSiteRes( + /** 产品业务编号。 */ String productCode, + /** 英文产品名称。 */ String productName, + /** 产品英文路径。 */ String slug, + /** 产品型号。 */ String model, + /** 主分类业务编号。 */ String primaryCategoryCode, + /** 主分类英文名称。 */ String primaryCategoryName, + /** 主分类英文路径。 */ String primaryCategorySlug, + /** 产品摘要。 */ String summary, + /** 产品详情内容。 */ String content, + /** 封面媒体业务编号。 */ String coverMediaCode, + /** 封面媒体访问地址。 */ String coverMediaUrl, + /** 产品图片列表。 */ List images, + /** 是否允许提交产品询盘。 */ Boolean inquiryEnabled, + /** 产品属性列表。 */ List attributes, + /** 产品规格列表。 */ List specifications) { } diff --git a/site/src/main/java/com/shoplix/site/service/SiteProductService.java b/site/src/main/java/com/shoplix/site/service/SiteProductService.java index 155dfb3..886ff2e 100644 --- a/site/src/main/java/com/shoplix/site/service/SiteProductService.java +++ b/site/src/main/java/com/shoplix/site/service/SiteProductService.java @@ -112,8 +112,12 @@ public class SiteProductService { .map(relation -> new ProductImageSiteRes(relation.getMediaCode(), mediaRepository.find(siteCode, relation.getMediaCode()).map(value -> value.getRelativeUrl()).orElse(null), relation.getSortNo())) .filter(image -> image.url() != null).toList(); if (images.isEmpty() && item.getCoverMediaCode() != null && mediaUrl != null) images = List.of(new ProductImageSiteRes(item.getCoverMediaCode(), mediaUrl, 0)); + var primaryCategory = item.getPrimaryCategoryCode() == null ? null + : categoryRepository.findByCode(siteCode, item.getPrimaryCategoryCode()).orElse(null); return new ProductDetailSiteRes(item.getProductCode(), item.getProductName(), item.getSlug(), item.getModel(), - item.getSummary(), resolveProductContent(item), item.getCoverMediaCode(), mediaUrl, images, + item.getPrimaryCategoryCode(), primaryCategory == null ? null : primaryCategory.getCategoryName(), + primaryCategory == null ? null : primaryCategory.getSlug(), item.getSummary(), resolveProductContent(item), + item.getCoverMediaCode(), mediaUrl, images, item.getInquiryEnabled() == 1, attributes, specifications); } diff --git a/tmp/admin-cookie-merge.txt b/tmp/admin-cookie-merge.txt new file mode 100644 index 0000000..f2af4a5 --- /dev/null +++ b/tmp/admin-cookie-merge.txt @@ -0,0 +1,5 @@ +# Netscape HTTP Cookie File +# https://curl.se/docs/http-cookies.html +# This file was generated by libcurl! Edit at your own risk. + +#HttpOnly_localhost FALSE / FALSE 1798637756 JSESSIONID BC5A5CE6FA39A57BF6703B6FDF64BA53 diff --git a/tmp/merge-nylon-brush-wheel.ps1 b/tmp/merge-nylon-brush-wheel.ps1 new file mode 100644 index 0000000..20d1756 --- /dev/null +++ b/tmp/merge-nylon-brush-wheel.ps1 @@ -0,0 +1,59 @@ +# 合并尼龙刷轮的三个套件型号,并删除重复产品记录。 +$login = @{ username = 'admin'; password = 'Shoplix@2026' } | ConvertTo-Json +Invoke-RestMethod -Method Post -Uri 'http://localhost:8081/api/admin/v1/auth/login' -ContentType 'application/json' -Body $login -SessionVariable adminSession | Out-Null + +$productContent = @' +

Nylon Brush Wheel Kit Overview

+

This nylon brush wheel kit is available with three adapter and fixing kit options: HY-047, HY-048 and HY-049. It is designed for garden maintenance, brush cutter accessory sourcing and replacement-part distribution.

+

Available Kit Options

+
  • HY-047: Nylon brush wheel with 8-piece adapter kit.
  • HY-048: Nylon brush wheel with 4-piece fixing kit.
  • HY-049: Nylon brush wheel with Stihl-style 4-piece kit.
+

Ordering Information

+

Please confirm the required kit option, machine compatibility, mounting dimensions, quantity, packaging and branding requirements before ordering. OEM and wholesale inquiries are welcome.

+'@ + +$saveBody = @{ + productCode = 'PRD0089E12MHRYF4' + siteCode = 'SIT0000000000001' + primaryCategoryCode = 'PCT0089DGXVJZDVK' + productName = 'Nylon Brush Wheel Kit' + slug = 'nylon-brush-wheel-kit' + model = 'HY-047 / HY-048 / HY-049' + summary = 'Nylon brush wheel supplied with three adapter and fixing kit options for garden maintenance and brush cutter accessory sourcing.' + productContent = $productContent + contentTemplateCode = '' + templatePosition = 'AFTER' + coverMediaCode = 'MED0089DZO2RZW1S' + images = @( + @{ mediaCode = 'MED0089DZO2RZW1S'; sortNo = 0 }, + @{ mediaCode = 'MED0089DZO5MDQ80'; sortNo = 1 }, + @{ mediaCode = 'MED0089DZO8EW54W'; sortNo = 2 } + ) + featured = $false + inquiryEnabled = $true + sortNo = 47 + status = 'PUBLISHED' + attributes = @( + @{ attributeCode = 'PAT0083ZKZ1VM3UO'; attributeName = 'Model'; value = 'HY-047 / HY-048 / HY-049'; unit = ''; sortNo = 1 }, + @{ attributeCode = 'PAT0089C84SCSJY8'; attributeName = 'Product Type'; value = 'Nylon Brush Wheel Kit'; unit = ''; sortNo = 2 }, + @{ attributeCode = 'PAT0089C84W1RNCW'; attributeName = 'Color'; value = 'Orange'; unit = ''; sortNo = 3 }, + @{ attributeCode = 'PAT0083ZKZ1XHJ40'; attributeName = 'Material'; value = 'Nylon / Metal'; unit = ''; sortNo = 4 }, + @{ attributeCode = $null; attributeName = 'Kit Options'; value = '8-Piece Adapter Kit; 4-Piece Fixing Kit; Stihl-Style 4-Piece Kit'; unit = ''; sortNo = 5 } + ) + specifications = @( + @{ groupName = 'Kit Options'; name = 'HY-047'; value = '8-Piece Adapter Kit'; unit = ''; sortNo = 1 }, + @{ groupName = 'Kit Options'; name = 'HY-048'; value = '4-Piece Fixing Kit'; unit = ''; sortNo = 2 }, + @{ groupName = 'Kit Options'; name = 'HY-049'; value = 'Stihl-Style 4-Piece Kit'; unit = ''; sortNo = 3 }, + @{ groupName = 'Material'; name = 'Primary Material'; value = 'Nylon / Metal'; unit = ''; sortNo = 4 }, + @{ groupName = 'Appearance'; name = 'Color'; value = 'Orange'; unit = ''; sortNo = 5 } + ) +} | ConvertTo-Json -Depth 10 + +$saved = Invoke-RestMethod -Method Post -Uri 'http://localhost:8081/api/admin/v1/products/save' -ContentType 'application/json' -Body $saveBody -WebSession $adminSession +if ($saved.productCode -ne 'PRD0089E12MHRYF4') { + throw '合并后的产品保存失败,未删除原产品。' +} +foreach ($productCode in @('PRD0089E13JUANLS', 'PRD0089E14JAZ9C0')) { + $deleteBody = @{ siteCode = 'SIT0000000000001'; productCode = $productCode } | ConvertTo-Json + Invoke-RestMethod -Method Post -Uri 'http://localhost:8081/api/admin/v1/products/delete' -ContentType 'application/json' -Body $deleteBody -WebSession $adminSession | Out-Null +} +Write-Output $saved.productCode diff --git a/web-site/src/main.tsx b/web-site/src/main.tsx index ef9baea..4ffc5b1 100644 --- a/web-site/src/main.tsx +++ b/web-site/src/main.tsx @@ -681,7 +681,12 @@ function ProductDetailView({ data: d, configuration }: { data: Record - +
productImages.length > 0 && setImageZoomOpen(true)} onTouchStart={(event) => setTouchStartX(event.touches[0].clientX)} onTouchEnd={(event) => { if (touchStartX === null) return; const delta = event.changedTouches[0].clientX - touchStartX; if (Math.abs(delta) > 40) selectAdjacentImage(delta < 0 ? 1 : -1); setTouchStartX(null); }}> @@ -984,11 +989,17 @@ function InquiryForm({
); } -function Crumbs({ current }: { current: string }) { +/** 面包屑上级节点。 */ +type BreadcrumbParent = { label: string; url: string }; +function Crumbs({ current, parents = [] }: { current: string; parents?: BreadcrumbParent[] }) { return (
Home - + {parents.map((parent) => + + {parent.label} + )} + {current}
);