From 6dc77b417d600b20009cf39d085285b42ed9b5a4 Mon Sep 17 00:00:00 2001 From: quyixiao <2621048238@qq.com> Date: Wed, 22 Oct 2025 09:29:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/dao/vv/VvCategoryPropertyDao.java | 15 ++++++++ .../dto/vv/VvAdminCategoryCategoryDTO.java | 8 +++++ .../mm/AdminCategoryController.java | 35 +++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/api-mapper/src/main/java/com/heyu/api/data/dao/vv/VvCategoryPropertyDao.java b/api-mapper/src/main/java/com/heyu/api/data/dao/vv/VvCategoryPropertyDao.java index 260b54c..f1320af 100644 --- a/api-mapper/src/main/java/com/heyu/api/data/dao/vv/VvCategoryPropertyDao.java +++ b/api-mapper/src/main/java/com/heyu/api/data/dao/vv/VvCategoryPropertyDao.java @@ -52,4 +52,19 @@ public interface VvCategoryPropertyDao extends BaseMapper selectVvPropertyByIds(@IN List id); + + + + + + @OrderBy(value={VvCategoryPropertyEntity.default_sort}, type={OrderType.ASC}) + List selectVvPropertyByCategoryId(Long categoryId); + + + + + + + + } \ No newline at end of file diff --git a/api-mapper/src/main/java/com/heyu/api/data/dto/vv/VvAdminCategoryCategoryDTO.java b/api-mapper/src/main/java/com/heyu/api/data/dto/vv/VvAdminCategoryCategoryDTO.java index 7e34b40..1fe19e9 100644 --- a/api-mapper/src/main/java/com/heyu/api/data/dto/vv/VvAdminCategoryCategoryDTO.java +++ b/api-mapper/src/main/java/com/heyu/api/data/dto/vv/VvAdminCategoryCategoryDTO.java @@ -3,6 +3,8 @@ package com.heyu.api.data.dto.vv; import com.heyu.api.data.entity.vv.VvAdminCategoryEntity; import lombok.Data; +import java.util.List; + @Data public class VvAdminCategoryCategoryDTO extends VvAdminCategoryEntity { @@ -11,4 +13,10 @@ VvAdminCategoryCategoryDTO extends VvAdminCategoryEntity { */ private Integer hasChild; + + /*** + * 如果是叶子节点,则关联相关的属性 + */ + private List vvCategoryPropertyDTOList; + } diff --git a/api-web/api-interface/src/main/java/com/heyu/api/controller/mm/AdminCategoryController.java b/api-web/api-interface/src/main/java/com/heyu/api/controller/mm/AdminCategoryController.java index fd4f97a..83ac4d5 100644 --- a/api-web/api-interface/src/main/java/com/heyu/api/controller/mm/AdminCategoryController.java +++ b/api-web/api-interface/src/main/java/com/heyu/api/controller/mm/AdminCategoryController.java @@ -5,12 +5,18 @@ import com.heyu.api.alibaba.request.mm.VvAdminCategoryIndexSortRequest; import com.heyu.api.alibaba.request.mm.VvAdminCategoryRequest; import com.heyu.api.alibaba.request.mm.VvAdminCategorySortRequest; import com.heyu.api.data.dao.vv.VvAdminCategoryDao; +import com.heyu.api.data.dao.vv.VvCategoryPropertyDao; +import com.heyu.api.data.dao.vv.VvCategoryPropertyValueDao; import com.heyu.api.data.dto.vv.VvAdminCategoryCategoryDTO; +import com.heyu.api.data.dto.vv.VvCategoryPropertyDTO; import com.heyu.api.data.entity.vv.VvAdminCategoryEntity; +import com.heyu.api.data.entity.vv.VvCategoryPropertyEntity; +import com.heyu.api.data.entity.vv.VvCategoryPropertyValueEntity; import com.heyu.api.data.utils.R; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -26,6 +32,14 @@ public class AdminCategoryController { @Autowired private VvAdminCategoryDao vvAdminCategoryDao; + + @Autowired + private VvCategoryPropertyValueDao vvCategoryPropertyValueDao; + + + + @Autowired + private VvCategoryPropertyDao vvCategoryPropertyDao; /*** * 列表 * @@ -44,6 +58,27 @@ public class AdminCategoryController { BeanUtils.copyProperties(vvCategoryEntity, vvCategoryDTO); boolean has = hasChild(vvCategoryEntity, vvCategoryEntities); vvCategoryDTO.setHasChild(has ? 1 : 0); + + // 如果没有子节点 + if (!has) { + List vvCategoryPropertyEntities = vvCategoryPropertyDao.selectVvPropertyByCategoryId(vvCategoryEntity.getId()); + + if (!CollectionUtils.isEmpty(vvCategoryPropertyEntities)) { + + List vvCategoryPropertyDTOS = new ArrayList<>(); + for (VvCategoryPropertyEntity vvCategoryPropertyEntity : vvCategoryPropertyEntities) { + VvCategoryPropertyDTO vvCategoryPropertyDTO = new VvCategoryPropertyDTO(); + BeanUtils.copyProperties(vvCategoryPropertyEntity, vvCategoryPropertyDTO); + + + List vvCategoryPropertyValueEntities = vvCategoryPropertyValueDao.selectVvPropertyValueByPropertyId(vvCategoryPropertyEntity.getId()); + vvCategoryPropertyDTO.setVvPropertyValueList(vvCategoryPropertyValueEntities); + + vvCategoryPropertyDTOS.add(vvCategoryPropertyDTO); + } + vvCategoryDTO.setVvCategoryPropertyDTOList(vvCategoryPropertyDTOS); + } + } vvCategoryDTOS.add(vvCategoryDTO); } return R.ok().setData(vvCategoryDTOS);