feat:mock数据
This commit is contained in:
1 parent
4d6608b025
commit
846de6fe0e
6 files changed
+238
-167
No files matched your search
@@ -5,6 +5,7 @@ import com.crrc.crrcmall.vo.crrc.GoodsSearchResultVo;
|
||||
import com.crrc.crrcmall.vo.crrc.GoodsVo;
|
||||
import com.crrc.crrcmall.vo.crrc.BrandVo;
|
||||
import com.crrc.crrcmall.vo.crrc.CatalogVo;
|
||||
import com.crrc.crrcmall.vo.crrc.SupplierVo;
|
||||
import com.crrc.crrcmall.vo.crrc.PurchaserCatalogVo;
|
||||
import com.crrc.crrcmall.vo.crrc.SpecVo;
|
||||
import com.crrc.crrcmall.vo.crrc.SpecValueVo;
|
||||
@@ -16,18 +17,79 @@ import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 搜索模拟数据生成器
|
||||
* 基于真实返回结果构建 Demo 数据,并叠加 AI 增强字段
|
||||
* 基于真实返回结果构建 Demo 数据,支持动态筛选联动,数据量扩充至 15 条
|
||||
*/
|
||||
@Service
|
||||
public class SearchMockDataGenerator {
|
||||
|
||||
// 内置数据池 (模拟数据库)
|
||||
private static final List<GoodsVo> DATA_POOL = new ArrayList<>();
|
||||
|
||||
static {
|
||||
// --- 供应商 ID 定义 ---
|
||||
String SUPPLIER_QIXIN = "759113572558180352"; // 齐心
|
||||
String SUPPLIER_DELI = "759108823876243456"; // 得力
|
||||
String SUPPLIER_KELIPU = "759109024196202496"; // 科力普 (晨光代理)
|
||||
String SUPPLIER_ZHONGCHE = "1035673654182154240"; // 中车智程
|
||||
|
||||
// --- 品牌 ID 定义 ---
|
||||
String BRAND_QIXIN = "258123000988416";
|
||||
String BRAND_DELI = "1222540037137240064";
|
||||
String BRAND_MG = "100657835537516201";
|
||||
String BRAND_ZHENCAI = "1941075794568753154";
|
||||
String BRAND_HERO = "100657835537520276";
|
||||
|
||||
// --- 目录 ID 定义 ---
|
||||
String CAT_ZXNB = "1750717233614614529"; // 中性笔
|
||||
String CAT_BX = "1750717233572671489"; // 笔芯
|
||||
String CAT_BJB = "1750717234243760130"; // 记号笔/其他笔类
|
||||
|
||||
// 1. 齐心中性笔 (供应商:齐心)
|
||||
DATA_POOL.add(buildGoods("250344595341056", "齐心 (Comix) 0.5mm 子弹头中性笔 K3511 黑色", BRAND_QIXIN, "齐心/Comix", CAT_ZXNB, "中性笔", SUPPLIER_QIXIN, "齐心", "12.15", "22", "28705"));
|
||||
// 2. 齐心中性笔 红色
|
||||
DATA_POOL.add(buildGoods("250344597377792", "齐心 (Comix) 0.5mm 子弹头中性笔 K3511 红色", BRAND_QIXIN, "齐心/Comix", CAT_ZXNB, "中性笔", SUPPLIER_QIXIN, "齐心", "12.15", "22", "4667"));
|
||||
// 3. 齐心笔芯
|
||||
DATA_POOL.add(buildGoods("250344598842112", "齐心 (Comix) 0.5mm 子弹头中性笔芯 K3511 配套笔芯", BRAND_QIXIN, "齐心/Comix", CAT_BX, "笔芯", SUPPLIER_QIXIN, "齐心", "8.54", "11.4", "6612"));
|
||||
|
||||
// 4. 得力中性笔 (供应商:得力)
|
||||
DATA_POOL.add(buildGoods("1220406174674522112", "得力 6600ES 中性笔 0.5mm 子弹头 12 支/盒 黑色", BRAND_DELI, "得力/deli", CAT_ZXNB, "中性笔", SUPPLIER_DELI, "得力", "7.31", "24", "6704"));
|
||||
// 5. 得力中性笔 S01
|
||||
DATA_POOL.add(buildGoods("1950796360220282882", "得力 S01 中性笔 0.5mm 弹簧头 12 支/盒 黑色", BRAND_DELI, "得力/deli", CAT_ZXNB, "中性笔", SUPPLIER_DELI, "得力", "15.94", "37.68", "769"));
|
||||
// 6. 得力中性笔 S20
|
||||
DATA_POOL.add(buildGoods("1950796398919880705", "得力 S20 中性笔 0.7mm 子弹头 12 支/盒 黑色", BRAND_DELI, "得力/deli", CAT_ZXNB, "中性笔", SUPPLIER_DELI, "得力", "12.4", "24", "428"));
|
||||
|
||||
// 7. 晨光热可擦 (供应商:科力普)
|
||||
DATA_POOL.add(buildGoods("1210256813113094144", "晨光 M&G 拔帽热可擦中性笔 AKP61115 0.5mm 黑色", BRAND_MG, "晨光/M&G", CAT_BJB, "其他笔类", SUPPLIER_KELIPU, "科力普", "1.79", "3.04", "2445"));
|
||||
// 8. 晨光按动笔
|
||||
DATA_POOL.add(buildGoods("1210256813113094145", "晨光 M&G 优品按动中性笔 AGPJ9001 0.5mm 黑色", BRAND_MG, "晨光/M&G", CAT_ZXNB, "中性笔", SUPPLIER_KELIPU, "科力普", "3.50", "5.00", "1500"));
|
||||
|
||||
// 9. 真彩中性笔 (供应商:中车智程)
|
||||
DATA_POOL.add(buildGoods("2087356946015031298", "真彩 (Truecolor) 金装 009 中性笔 0.5mm 蓝黑", BRAND_ZHENCAI, "真彩/Truecolor", CAT_ZXNB, "中性笔", SUPPLIER_ZHONGCHE, "中车智程", "15.5", "20.68", "373"));
|
||||
// 10. 真彩记号笔
|
||||
DATA_POOL.add(buildGoods("2087356946015031299", "真彩 (Truecolor) 双头记号笔 MK-201 黑色", BRAND_ZHENCAI, "真彩/Truecolor", CAT_BJB, "其他笔类", SUPPLIER_ZHONGCHE, "中车智程", "2.50", "4.00", "800"));
|
||||
|
||||
// 11. 英雄钢笔 (供应商:齐心 - 代理)
|
||||
DATA_POOL.add(buildGoods("100657835537520277", "英雄 (HERO) 359 铱金笔 钢笔 黑色", BRAND_HERO, "英雄 (HERO)", CAT_ZXNB, "中性笔", SUPPLIER_QIXIN, "齐心", "45.00", "68.00", "120"));
|
||||
|
||||
// 12. 得力笔芯
|
||||
DATA_POOL.add(buildGoods("1220406174141845504", "得力 S761 子弹头中性笔芯 0.7mm 黑色 20 支/盒", BRAND_DELI, "得力/deli", CAT_BX, "笔芯", SUPPLIER_DELI, "得力", "6.8", "21", "586"));
|
||||
|
||||
// 13. 齐心按动笔
|
||||
DATA_POOL.add(buildGoods("2088096431429345282", "齐心 (Comix) 0.7mm 黑色 K3507 子弹头按动中性笔", BRAND_QIXIN, "齐心/Comix", CAT_ZXNB, "中性笔", SUPPLIER_QIXIN, "齐心", "13.86", "18.00", "186"));
|
||||
|
||||
// 14. 晨光笔芯
|
||||
DATA_POOL.add(buildGoods("100657835537516202", "晨光 M&G 子弹头中性笔芯 MG-6102 0.5mm 黑色", BRAND_MG, "晨光/M&G", CAT_BX, "笔芯", SUPPLIER_KELIPU, "科力普", "12.00", "15.00", "3200"));
|
||||
|
||||
// 15. 得力白板笔 (新目录测试)
|
||||
DATA_POOL.add(buildGoods("1222540037137240065", "得力 S506 白板笔 12 支/盒 黑色", BRAND_DELI, "得力/deli", CAT_BJB, "其他笔类", SUPPLIER_DELI, "得力", "18.00", "25.00", "900"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成搜索结果
|
||||
* @param request 搜索请求
|
||||
* @return 包含 AI 增强信息的搜索结果
|
||||
* 生成搜索结果 (支持动态筛选)
|
||||
*/
|
||||
public GoodsSearchResultVo generateResult(SearchGoodsRequestDto request) {
|
||||
GoodsSearchResultVo result = new GoodsSearchResultVo();
|
||||
@@ -38,182 +100,161 @@ public class SearchMockDataGenerator {
|
||||
result.setIsSelf(true);
|
||||
result.setIsShowPriceUnlogin("1");
|
||||
|
||||
// 2. AI 搜索解析信息 (叠加在原有结果之上)
|
||||
// 2. AI 搜索解析信息 (matchType 在这里设置)
|
||||
AiSearchInfoVo aiInfo = new AiSearchInfoVo();
|
||||
aiInfo.setOriginalQuery(request.getGoodsName() != null ? request.getGoodsName() : "");
|
||||
aiInfo.setIntent("办公用品 - 书写/修正用品");
|
||||
aiInfo.setSuggestion("您是不是想找:签字笔、圆珠笔?");
|
||||
aiInfo.setExpandedTerms(Arrays.asList("签字笔", "水笔", "书写工具"));
|
||||
aiInfo.setMatchType(MatchTypeEnum.SEMANTIC);
|
||||
// matchType 设置在 AiSearchInfoVo 中
|
||||
aiInfo.setMatchType(MatchTypeEnum.SEMANTIC);
|
||||
result.setAiSearchInfo(aiInfo);
|
||||
|
||||
// 3. 模拟品牌列表 (取真实数据)
|
||||
List<BrandVo> brandList = new ArrayList<>();
|
||||
brandList.add(createBrandVo("258123000988416", "齐心/Comix", "齐"));
|
||||
brandList.add(createBrandVo("100657835537516201", "晨光/M&G", "晨"));
|
||||
brandList.add(createBrandVo("1222540037137240064", "得力/deli", "得"));
|
||||
result.setBrandList(brandList);
|
||||
// 3. 动态筛选商品
|
||||
List<GoodsVo> filteredGoods = new ArrayList<>(DATA_POOL);
|
||||
|
||||
// 4. 模拟目录列表 (取真实数据)
|
||||
List<CatalogVo> catalogList = new ArrayList<>();
|
||||
catalogList.add(createCatalogVo("1750717233614614529", "中性笔"));
|
||||
catalogList.add(createCatalogVo("1750717233572671489", "笔芯"));
|
||||
catalogList.add(createCatalogVo("1750717234243760130", "其他笔类"));
|
||||
result.setCatalogList(catalogList);
|
||||
// 过滤品牌
|
||||
if (request.getBrandIds() != null && !request.getBrandIds().isEmpty()) {
|
||||
List<String> brandIdStrs = request.getBrandIds().stream().map(String::valueOf).collect(Collectors.toList());
|
||||
filteredGoods.removeIf(g -> g.getBrandId() == null || !brandIdStrs.contains(g.getBrandId()));
|
||||
}
|
||||
// 过滤目录
|
||||
if (request.getCatalogIds() != null && !request.getCatalogIds().isEmpty()) {
|
||||
List<String> catalogIdStrs = request.getCatalogIds().stream().map(String::valueOf).collect(Collectors.toList());
|
||||
filteredGoods.removeIf(g -> g.getCatalogId() == null || !catalogIdStrs.contains(String.valueOf(g.getCatalogId())));
|
||||
}
|
||||
// 过滤供应商
|
||||
if (request.getSupplierIds() != null && !request.getSupplierIds().isEmpty()) {
|
||||
List<String> supplierIdStrs = request.getSupplierIds().stream().map(String::valueOf).collect(Collectors.toList());
|
||||
filteredGoods.removeIf(g -> g.getSupplierId() == null || !supplierIdStrs.contains(g.getSupplierId()));
|
||||
}
|
||||
|
||||
// 5. 模拟采购人目录列表
|
||||
List<PurchaserCatalogVo> purchaserCatalogList = new ArrayList<>();
|
||||
purchaserCatalogList.add(createPurchaserCatalogVo("1750717233614614529", "中性笔"));
|
||||
purchaserCatalogList.add(createPurchaserCatalogVo("1750717233572671489", "笔芯"));
|
||||
result.setPurchaserCatalogList(purchaserCatalogList);
|
||||
// 4. 动态聚合侧边栏 (基于筛选后的商品)
|
||||
result.setBrandList(aggregateBrands(filteredGoods));
|
||||
result.setCatalogList(aggregateCatalogs(filteredGoods));
|
||||
result.setSupplierList(aggregateSuppliers(filteredGoods)); // 确保 supplierList 被设置
|
||||
result.setPurchaserCatalogList(aggregatePurchaserCatalogs(filteredGoods));
|
||||
result.setSpecList(aggregateSpecs(filteredGoods));
|
||||
|
||||
// 6. 模拟规格列表 (简化版)
|
||||
List<SpecVo> specList = new ArrayList<>();
|
||||
specList.add(createSpecVo("型号", Arrays.asList("K3511", "6600ES", "S01")));
|
||||
specList.add(createSpecVo("品牌", Arrays.asList("齐心/Comix", "晨光/M&G", "得力/deli")));
|
||||
result.setSpecList(specList);
|
||||
|
||||
// 7. 商品列表 (取真实数据的前 3 个,并添加 AI 字段)
|
||||
List<GoodsVo> goodsList = new ArrayList<>();
|
||||
// 5. 分页处理
|
||||
int page = request.getPage() != null && request.getPage() > 0 ? request.getPage() : 1;
|
||||
int limit = request.getLimit() != null && request.getLimit() > 0 ? request.getLimit() : 20;
|
||||
int fromIndex = (page - 1) * limit;
|
||||
int toIndex = Math.min(fromIndex + limit, filteredGoods.size());
|
||||
|
||||
// 商品 1: 齐心 K3511
|
||||
GoodsVo g1 = new GoodsVo();
|
||||
g1.setGoodsId("250344595341056");
|
||||
g1.setGoodsName("齐心Comix) 0.5mm 子弹头中性笔 12支*1盒 K3511 黑色(单位:盒)");
|
||||
g1.setGoodsCode("XM02040089");
|
||||
g1.setMaterialCode("DB00006298");
|
||||
g1.setGoodsImage("https://mall.crrcgo.cc/common/img.comix.com.cn/product/1001685297/img800/1.jpg");
|
||||
g1.setSkuImage("https://mall.crrcgo.cc/common/img.comix.com.cn/product/1001685297/img800/1.jpg");
|
||||
g1.setGoodsPrice(new BigDecimal("12.15"));
|
||||
g1.setSupplierId("759113572558180352");
|
||||
g1.setSupplierName("齐心");
|
||||
g1.setProtocolType("02");
|
||||
g1.setPurchaserCatalogId("1750717233614614529");
|
||||
g1.setPurchaserCatalogName("中性笔");
|
||||
g1.setPurchaserCatalogFullName("行政办公-文具-书写/修正用品-中性笔");
|
||||
g1.setCatalogId("1750717233614614529");
|
||||
g1.setBrandId("258123000988416");
|
||||
g1.setBrandName("齐心/Comix");
|
||||
g1.setProtocolId("1208779682986946560");
|
||||
g1.setGoodsSourceType(0);
|
||||
g1.setMarketPrice(new BigDecimal("22"));
|
||||
g1.setIsGroup(false);
|
||||
g1.setSales(28705);
|
||||
g1.setSaleStatus(1);
|
||||
g1.setOriginalPrice(new BigDecimal("12.15"));
|
||||
g1.setSpecialAreaCornerLogo("https://mall.crrcgo.cc/fdsimage/group1/M00/02/E0/Eg-DFGacjvWARFNJAAAG-U8Uuuc215.png");
|
||||
g1.setPortalCornerLogo("https://mall.crrcgo.cc/fdsimage/group1/M00/02/E1/Eg-DFGadtP2AUu03AAAFYj9phaw575.png");
|
||||
g1.setHighlightGoodsName("齐心Comix) 0.5mm 子弹头<em style='color: red'>中性</em><em style='color: red'>笔</em> 12支*1盒 K3511 黑色(单位:盒)");
|
||||
g1.setIsPostStation(false);
|
||||
// AI 增强字段
|
||||
g1.setAiRelevanceScore(0.98);
|
||||
goodsList.add(g1);
|
||||
List<GoodsVo> pageGoods = fromIndex < filteredGoods.size() ? filteredGoods.subList(fromIndex, toIndex) : new ArrayList<>();
|
||||
|
||||
// 6. 为商品添加 AI 相关度得分
|
||||
pageGoods.forEach(g -> {
|
||||
g.setAiRelevanceScore(0.85 + Math.random() * 0.15);
|
||||
});
|
||||
|
||||
// 商品 2: kaco中性笔
|
||||
GoodsVo g2 = new GoodsVo();
|
||||
g2.setGoodsId("1162049076309274624");
|
||||
g2.setGoodsName("kaco中性笔145mm");
|
||||
g2.setGoodsCode("sc00220221101000021");
|
||||
g2.setMaterialCode("");
|
||||
g2.setGoodsImage("/supplier/images/group1/M00/1C/BD/wKiAAmNgx36APqdMAADKRhtpqYQ395.jpg");
|
||||
g2.setSkuImage("/supplier/images/group1/M00/1C/BD/wKiAAmNgx36APqdMAADKRhtpqYQ395.jpg");
|
||||
g2.setGoodsPrice(new BigDecimal("2.8"));
|
||||
g2.setSupplierId("1035673654182154240");
|
||||
g2.setSupplierName("中车智程文化科技(北京)有限公司");
|
||||
g2.setProtocolType("02");
|
||||
g2.setPurchaserCatalogId("1712341648069373954");
|
||||
g2.setPurchaserCatalogName("办公定制");
|
||||
g2.setPurchaserCatalogFullName("[选品]办公用品-行政办公-办公定制");
|
||||
g2.setCatalogId("1712341648069373954");
|
||||
g2.setBrandId("0");
|
||||
g2.setProtocolId("1160903739087532032");
|
||||
g2.setGoodsSourceType(0);
|
||||
g2.setMarketPrice(new BigDecimal("2.8"));
|
||||
g2.setIsGroup(false);
|
||||
g2.setSales(22317);
|
||||
g2.setSaleStatus(1);
|
||||
g2.setOriginalPrice(new BigDecimal("2.8"));
|
||||
g2.setSpecialAreaCornerLogo("https://mall.crrcgo.cc/fdsimage/group1/M00/02/E0/Eg-DFGacjvWARFNJAAAG-U8Uuuc215.png");
|
||||
g2.setPortalCornerLogo("https://mall.crrcgo.cc/fdsimage/group1/M00/02/E1/Eg-DFGadtP2AUu03AAAFYj9phaw575.png");
|
||||
g2.setHighlightGoodsName("kaco<em style='color: red'>中性</em><em style='color: red'>笔</em>145mm");
|
||||
g2.setIsPostStation(false);
|
||||
// AI 增强字段
|
||||
g2.setAiRelevanceScore(0.92);
|
||||
goodsList.add(g2);
|
||||
|
||||
// 商品 3: 得力 6600ES
|
||||
GoodsVo g3 = new GoodsVo();
|
||||
g3.setGoodsId("1220406174674522112");
|
||||
g3.setGoodsName("中性笔 得力6600ES中性笔0.5mm子弹头12支/盒 黑(单位:盒)");
|
||||
g3.setGoodsCode("100002862BX1");
|
||||
g3.setMaterialCode("DB00006244");
|
||||
g3.setGoodsImage("https://mall.crrcgo.cc/commons/img.jslink.com/front/fileserver/image/FILEe2f149458e6a49af9d2813b8813e670d.jpg");
|
||||
g3.setSkuImage("https://mall.crrcgo.cc/commons/img.jslink.com/front/fileserver/image/FILEe2f149458e6a49af9d2813b8813e670d.jpg");
|
||||
g3.setGoodsPrice(new BigDecimal("7.31"));
|
||||
g3.setSupplierId("759108823876243456");
|
||||
g3.setSupplierName("得力");
|
||||
g3.setProtocolType("02");
|
||||
g3.setPurchaserCatalogId("1750717233614614529");
|
||||
g3.setPurchaserCatalogName("中性笔");
|
||||
g3.setPurchaserCatalogFullName("行政办公-文具-书写/修正用品-中性笔");
|
||||
g3.setCatalogId("1750717233614614529");
|
||||
g3.setBrandId("1222540037137240064");
|
||||
g3.setBrandName("得力/deli");
|
||||
g3.setProtocolId("1208779682986946560");
|
||||
g3.setGoodsSourceType(0);
|
||||
g3.setMarketPrice(new BigDecimal("24"));
|
||||
g3.setIsGroup(false);
|
||||
g3.setSales(6704);
|
||||
g3.setSaleStatus(1);
|
||||
g3.setOriginalPrice(new BigDecimal("7.31"));
|
||||
g3.setSpecialAreaCornerLogo("https://mall.crrcgo.cc/fdsimage/group1/M00/02/E0/Eg-DFGacjvWARFNJAAAG-U8Uuuc215.png");
|
||||
g3.setPortalCornerLogo("https://mall.crrcgo.cc/fdsimage/group1/M00/02/E1/Eg-DFGadtP2AUu03AAAFYj9phaw575.png");
|
||||
g3.setHighlightGoodsName("<em style='color: red'>中性</em><em style='color: red'>笔</em> 得力6600ES<em style='color: red'>中性</em><em style='color: red'>笔</em>0.5mm子弹头12支/盒 黑(单位:盒)");
|
||||
g3.setIsPostStation(false);
|
||||
// AI 增强字段
|
||||
g3.setAiRelevanceScore(0.89);
|
||||
goodsList.add(g3);
|
||||
|
||||
result.setGoodsList(goodsList);
|
||||
result.setTotal(goodsList.size());
|
||||
result.setGoodsList(pageGoods);
|
||||
result.setTotal((long) filteredGoods.size());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private BrandVo createBrandVo(String id, String name, String letter) {
|
||||
BrandVo vo = new BrandVo();
|
||||
vo.setBrandId(id);
|
||||
vo.setBrandName(name);
|
||||
vo.setFirstLetter(letter);
|
||||
return vo;
|
||||
// ================= 辅助聚合方法 =================
|
||||
|
||||
private List<BrandVo> aggregateBrands(List<GoodsVo> goods) {
|
||||
return goods.stream()
|
||||
.filter(g -> g.getBrandId() != null && !g.getBrandId().isEmpty() && !"0".equals(g.getBrandId()))
|
||||
.collect(Collectors.toMap(GoodsVo::getBrandId, g -> {
|
||||
BrandVo vo = new BrandVo();
|
||||
vo.setBrandId(g.getBrandId());
|
||||
vo.setBrandName(g.getBrandName());
|
||||
vo.setFirstLetter(g.getBrandName().substring(0, 1));
|
||||
return vo;
|
||||
}, (a, b) -> a))
|
||||
.values().stream().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private CatalogVo createCatalogVo(String id, String name) {
|
||||
CatalogVo vo = new CatalogVo();
|
||||
vo.setCatalogId(id);
|
||||
vo.setCatalogName(name);
|
||||
return vo;
|
||||
private List<CatalogVo> aggregateCatalogs(List<GoodsVo> goods) {
|
||||
return goods.stream()
|
||||
.filter(g -> g.getCatalogId() != null)
|
||||
.collect(Collectors.toMap(g -> String.valueOf(g.getCatalogId()), g -> {
|
||||
CatalogVo vo = new CatalogVo();
|
||||
vo.setCatalogId(String.valueOf(g.getCatalogId()));
|
||||
vo.setCatalogName(g.getPurchaserCatalogName());
|
||||
return vo;
|
||||
}, (a, b) -> a))
|
||||
.values().stream().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private PurchaserCatalogVo createPurchaserCatalogVo(String id, String name) {
|
||||
PurchaserCatalogVo vo = new PurchaserCatalogVo();
|
||||
vo.setPurchaserCatalogId(id);
|
||||
vo.setPurchaserCatalogName(name);
|
||||
return vo;
|
||||
private List<SupplierVo> aggregateSuppliers(List<GoodsVo> goods) {
|
||||
// 提取唯一的供应商列表
|
||||
return goods.stream()
|
||||
.filter(g -> g.getSupplierId() != null && !g.getSupplierId().isEmpty())
|
||||
.collect(Collectors.toMap(GoodsVo::getSupplierId, g -> {
|
||||
SupplierVo vo = new SupplierVo();
|
||||
vo.setSupplierId(g.getSupplierId());
|
||||
vo.setSupplierName(g.getSupplierName());
|
||||
return vo;
|
||||
}, (a, b) -> a))
|
||||
.values().stream().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private SpecVo createSpecVo(String name, List<String> values) {
|
||||
SpecVo vo = new SpecVo();
|
||||
vo.setSpecId(name);
|
||||
vo.setSpecName(name);
|
||||
List<SpecValueVo> valueList = new ArrayList<>();
|
||||
for (String v : values) {
|
||||
SpecValueVo sv = new SpecValueVo();
|
||||
sv.setValueId(v);
|
||||
sv.setValueName(v);
|
||||
valueList.add(sv);
|
||||
}
|
||||
vo.setSpecValueList(valueList);
|
||||
return vo;
|
||||
private List<PurchaserCatalogVo> aggregatePurchaserCatalogs(List<GoodsVo> goods) {
|
||||
return goods.stream()
|
||||
.filter(g -> g.getPurchaserCatalogId() != null)
|
||||
.collect(Collectors.toMap(g -> String.valueOf(g.getPurchaserCatalogId()), g -> {
|
||||
PurchaserCatalogVo vo = new PurchaserCatalogVo();
|
||||
vo.setPurchaserCatalogId(String.valueOf(g.getPurchaserCatalogId()));
|
||||
vo.setPurchaserCatalogName(g.getPurchaserCatalogName());
|
||||
return vo;
|
||||
}, (a, b) -> a))
|
||||
.values().stream().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<SpecVo> aggregateSpecs(List<GoodsVo> goods) {
|
||||
SpecVo spec = new SpecVo();
|
||||
spec.setSpecId("型号");
|
||||
spec.setSpecName("型号");
|
||||
List<SpecValueVo> values = goods.stream()
|
||||
.map(GoodsVo::getGoodsCode)
|
||||
.filter(java.util.Objects::nonNull)
|
||||
.distinct()
|
||||
.map(v -> {
|
||||
SpecValueVo sv = new SpecValueVo();
|
||||
sv.setValueId(v);
|
||||
sv.setValueName(v);
|
||||
return sv;
|
||||
}).collect(Collectors.toList());
|
||||
spec.setSpecValueList(values);
|
||||
return Arrays.asList(spec);
|
||||
}
|
||||
|
||||
// ================= 构建 Mock 商品 =================
|
||||
private static GoodsVo buildGoods(String id, String name, String brandId, String brandName, String catId, String catName, String supId, String supName, String price, String marketPrice, String sales) {
|
||||
GoodsVo g = new GoodsVo();
|
||||
g.setGoodsId(id);
|
||||
g.setGoodsName(name);
|
||||
g.setGoodsTip(name);
|
||||
g.setGoodsCode("CODE-" + id.substring(id.length() - 6)); // 模拟商品编码
|
||||
g.setGoodsImage("https://example.com/img/" + id + ".jpg");
|
||||
g.setSkuImage("https://example.com/img/" + id + ".jpg");
|
||||
g.setGoodsPrice(new BigDecimal(price));
|
||||
g.setMarketPrice(new BigDecimal(marketPrice));
|
||||
g.setOriginalPrice(new BigDecimal(price));
|
||||
|
||||
g.setSupplierId(supId);
|
||||
g.setSupplierName(supName); // 正确设置供应商名称
|
||||
|
||||
g.setBrandId(brandId);
|
||||
g.setBrandName(brandName);
|
||||
|
||||
g.setCatalogId(catId);
|
||||
g.setPurchaserCatalogId(catId);
|
||||
g.setPurchaserCatalogName(catName);
|
||||
g.setPurchaserCatalogFullName("行政办公-文具-" + catName);
|
||||
|
||||
g.setProtocolType("02");
|
||||
g.setSales(Integer.parseInt(sales));
|
||||
g.setSaleStatus(1);
|
||||
g.setSpecialAreaCornerLogo("https://example.com/logo1.png");
|
||||
g.setPortalCornerLogo("https://example.com/logo2.png");
|
||||
g.setHighlightGoodsName(name.replace("中性笔", "<em style='color:red'>中性笔</em>"));
|
||||
return g;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 商品搜索控制器
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.crrc.crrcmall.dto.crrc;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -19,6 +20,9 @@ public class SearchGoodsRequestDto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "图片")
|
||||
private File file;
|
||||
|
||||
@Schema(description = "是否标准商品:0-非标品 1-标准商品 -1-全部", required = true)
|
||||
private Integer isStandard;
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品搜索结果根对象 VO
|
||||
* 请根据实际项目包路径修改 package 声明
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "商品搜索结果根对象")
|
||||
@@ -17,7 +16,7 @@ public class GoodsSearchResultVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "地区ID")
|
||||
@Schema(description = "地区 ID")
|
||||
private String areaId;
|
||||
|
||||
@Schema(description = "地区名称")
|
||||
@@ -29,6 +28,9 @@ public class GoodsSearchResultVo implements Serializable {
|
||||
@Schema(description = "标准目录列表")
|
||||
private List<CatalogVo> catalogList;
|
||||
|
||||
@Schema(description = "供应商列表")
|
||||
private List<SupplierVo> supplierList;
|
||||
|
||||
@Schema(description = "商品列表")
|
||||
private List<GoodsVo> goodsList;
|
||||
|
||||
@@ -44,9 +46,9 @@ public class GoodsSearchResultVo implements Serializable {
|
||||
@Schema(description = "规格筛选列表")
|
||||
private List<SpecVo> specList;
|
||||
|
||||
@Schema(description = "ai规则说明")
|
||||
@Schema(description = "AI 搜索解析信息")
|
||||
private AiSearchInfoVo aiSearchInfo;
|
||||
|
||||
@Schema(description = "条数")
|
||||
private int total;
|
||||
@Schema(description = "结果总数")
|
||||
private Long total;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.crrc.crrcmall.vo.crrc;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 供应商信息 VO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "供应商信息")
|
||||
public class SupplierVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "供应商 ID")
|
||||
private String supplierId;
|
||||
|
||||
@Schema(description = "供应商名称")
|
||||
private String supplierName;
|
||||
}
|
||||
@@ -9,9 +9,9 @@ spring:
|
||||
password: prod_password
|
||||
|
||||
datasource:
|
||||
url: jdbc:mysql://prod-db-server:3306/crrc_mall?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||
username: prod_user
|
||||
password: prod_password
|
||||
url: jdbc:mysql://18.15.131.225:3306/crrc_mall?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||
username: entpur_select
|
||||
password: EtEdgf@zc2024
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
|
||||
jpa:
|
||||
|
||||
Reference in new issue
Block a user