From cf2da3b2a63840888815c6a81cbd7948faf93533 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期一, 08 六月 2026 17:41:15 +0800
Subject: [PATCH] aaa
---
server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java | 47 +++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java
index b714aac..e79a1df 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java
@@ -354,9 +354,9 @@
goods.setCreateDate(new Date());
goods.setCreator(user.getId());
goods.setIsdeleted(Constants.ZERO);
- //澶勭悊鎷奸煶闂
goods.setPinyin(PinYinUtil.getFullSpell(goods.getName()));
goods.setShortPinyin(PinYinUtil.getFirstSpell(goods.getName()));
+ this.validateSubCategory(goods);
goodsMapper.insert(goods);
List<Multifile> multifileList = goods.getMultifileList();
@@ -484,9 +484,9 @@
goods.setEditDate(new Date());
goods.setEditor(user.getId());
goods.setIsdeleted(Constants.ZERO);
- //澶勭悊鎷奸煶闂
goods.setPinyin(PinYinUtil.getFullSpell(goods.getName()));
goods.setShortPinyin(PinYinUtil.getFirstSpell(goods.getName()));
+ this.validateSubCategory(goods);
goodsMapper.updateById(goods);
multifileMapper.delete(new QueryWrapper<Multifile>().eq("OBJ_ID",goods.getId())
@@ -628,6 +628,12 @@
if(!Objects.isNull(category)){
goods.setCategoryName(category.getName());
}
+ if (goods.getSubCategoryId() != null) {
+ Category subCategory = categoryMapper.selectById(goods.getSubCategoryId());
+ if (subCategory != null) {
+ goods.setSubCategoryName(subCategory.getName());
+ }
+ }
goods.setMultifileList(multifileMapper.selectList(new QueryWrapper<Multifile>().eq("OBJ_TYPE",Constants.ZERO).eq("OBJ_ID",id)));
return goods;
}
@@ -714,6 +720,7 @@
IPage<Goods> goodsIPage = goodsJoinMapper.selectJoinPage(page, Goods.class, queryWrapper);
String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
+ systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode();
+ fillSubCategoryNames(goodsIPage.getRecords());
goodsIPage.getRecords().forEach(i->{
i.setPrefixUrl(prefixUrl);
if(i.getType().equals(Constants.ONE)){
@@ -1255,6 +1262,7 @@
queryWrapper.eq(Goods::getIsdeleted,Constants.ZERO);
queryWrapper.eq(!Objects.isNull(pageWrap.getModel()) && !Objects.isNull(pageWrap.getModel().getCategoryId()), Goods::getCategoryId, pageWrap.getModel().getCategoryId())
+ .eq(!Objects.isNull(pageWrap.getModel()) && !Objects.isNull(pageWrap.getModel().getSubCategoryId()), Goods::getSubCategoryId, pageWrap.getModel().getSubCategoryId())
.eq(!Objects.isNull(pageWrap.getModel()) && !Objects.isNull(pageWrap.getModel().getBrandId()), Goods::getBrandId, pageWrap.getModel().getBrandId())
.and(!Objects.isNull(pageWrap.getModel()) && StringUtils.isNotBlank(pageWrap.getModel().getKeyword()),
i->i.like(Goods::getPinyin,pageWrap.getModel().getKeyword())
@@ -1275,6 +1283,40 @@
this.dealGoodsMsg(goodsIPage.getRecords());
}
return PageData.from(goodsIPage);
+ }
+
+ private void validateSubCategory(Goods goods) {
+ if (goods.getSubCategoryId() == null) {
+ return;
+ }
+ Category sub = categoryMapper.selectById(goods.getSubCategoryId());
+ if (sub == null || sub.getParentId() == null || !sub.getParentId().equals(goods.getCategoryId())) {
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "浜岀骇绫诲埆蹇呴』灞炰簬鎵�閫変竴绾у搧绫�");
+ }
+ }
+
+ private void fillSubCategoryNames(List<Goods> goodsList) {
+ if (goodsList == null || goodsList.isEmpty()) {
+ return;
+ }
+ List<Integer> subCategoryIds = goodsList.stream()
+ .map(Goods::getSubCategoryId)
+ .filter(Objects::nonNull)
+ .distinct()
+ .collect(Collectors.toList());
+ if (subCategoryIds.isEmpty()) {
+ return;
+ }
+ List<Category> subCategories = categoryMapper.selectList(new QueryWrapper<Category>()
+ .in("ID", subCategoryIds)
+ .eq("ISDELETED", Constants.ZERO));
+ Map<Integer, String> nameMap = subCategories.stream()
+ .collect(Collectors.toMap(Category::getId, Category::getName, (a, b) -> a));
+ goodsList.forEach(goods -> {
+ if (goods.getSubCategoryId() != null) {
+ goods.setSubCategoryName(nameMap.get(goods.getSubCategoryId()));
+ }
+ });
}
@@ -1321,6 +1363,7 @@
queryWrapper.eq(Goods::getIsdeleted,Constants.ZERO);
queryWrapper.eq(Goods::getCompanyId,loginUserInfo.getCompanyId());
queryWrapper.eq(!Objects.isNull(goodsRequest) && !Objects.isNull(goodsRequest.getCategoryId()), Goods::getCategoryId, goodsRequest.getCategoryId())
+ .eq(!Objects.isNull(goodsRequest) && !Objects.isNull(goodsRequest.getSubCategoryId()), Goods::getSubCategoryId, goodsRequest.getSubCategoryId())
.eq(!Objects.isNull(goodsRequest) && !Objects.isNull(goodsRequest.getBrandId()), Goods::getBrandId, goodsRequest.getBrandId())
.and(!Objects.isNull(goodsRequest) && StringUtils.isNotBlank(goodsRequest.getKeyword()),
i->i.like(Goods::getPinyin,goodsRequest.getKeyword())
--
Gitblit v1.9.3