功能迭代

This commit is contained in:
张锐 committed 2026-11-30 21:43:02 +08:00
1 parent 148d1297b2
commit baf555c9b3
5 files changed
+99 -9

No files matched your search

@@ -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<ProductImageSiteRes> images, Boolean inquiryEnabled,
List<ProductAttributeSiteRes> attributes,
List<ProductSpecificationSiteRes> 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<ProductImageSiteRes> images,
/** 是否允许提交产品询盘。 */ Boolean inquiryEnabled,
/** 产品属性列表。 */ List<ProductAttributeSiteRes> attributes,
/** 产品规格列表。 */ List<ProductSpecificationSiteRes> specifications) {
}
@@ -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);
}
+5
View File
@@ -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
+59
View File
@@ -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 = @'
<h2>Nylon Brush Wheel Kit Overview</h2>
<p>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.</p>
<h2>Available Kit Options</h2>
<ul><li><strong>HY-047:</strong> Nylon brush wheel with 8-piece adapter kit.</li><li><strong>HY-048:</strong> Nylon brush wheel with 4-piece fixing kit.</li><li><strong>HY-049:</strong> Nylon brush wheel with Stihl-style 4-piece kit.</li></ul>
<h2>Ordering Information</h2>
<p>Please confirm the required kit option, machine compatibility, mounting dimensions, quantity, packaging and branding requirements before ordering. OEM and wholesale inquiries are welcome.</p>
'@
$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
+14 -3
View File
@@ -681,7 +681,12 @@ function ProductDetailView({ data: d, configuration }: { data: Record<string, an
};
}, [inquiryOpen]);
return <article className="detail product-detail">
<Crumbs current={String(d.productName || "Product")}/>
<Crumbs current={String(d.productName || "Product")} parents={[
{ label: "Products", url: "/products" },
...(d.primaryCategoryCode && d.primaryCategoryName
? [{ label: String(d.primaryCategoryName), url: `/products?category=${encodeURIComponent(String(d.primaryCategoryCode))}` }]
: []),
]}/>
<section className="product-overview">
<div className="product-gallery">
<div className="product-media" onClick={() => 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({
</section>
);
}
function Crumbs({ current }: { current: string }) {
/** 面包屑上级节点。 */
type BreadcrumbParent = { label: string; url: string };
function Crumbs({ current, parents = [] }: { current: string; parents?: BreadcrumbParent[] }) {
return (
<div className="crumbs">
<a href="/">Home</a>
<ChevronRight size={14} />
{parents.map((parent) => <React.Fragment key={`${parent.url}-${parent.label}`}>
<ChevronRight size={14} />
<a href={parent.url}>{parent.label}</a>
</React.Fragment>)}
<ChevronRight size={14}/>
<span>{current}</span>
</div>
);