提交修改

This commit is contained in:
quyixiao 2025-10-22 09:29:34 +08:00
parent fe8c61b9e4
commit 6dc77b417d
3 changed files with 58 additions and 0 deletions

View File

@ -52,4 +52,19 @@ public interface VvCategoryPropertyDao extends BaseMapper<VvCategoryPropertyEnti
@OrderBy(value={VvCategoryPropertyEntity.default_sort}, type={OrderType.ASC})
List<VvCategoryPropertyEntity> selectVvPropertyByIds(@IN List<Long> id);
@OrderBy(value={VvCategoryPropertyEntity.default_sort}, type={OrderType.ASC})
List<VvCategoryPropertyEntity> selectVvPropertyByCategoryId(Long categoryId);
}

View File

@ -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<VvCategoryPropertyDTO> vvCategoryPropertyDTOList;
}

View File

@ -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<VvCategoryPropertyEntity> vvCategoryPropertyEntities = vvCategoryPropertyDao.selectVvPropertyByCategoryId(vvCategoryEntity.getId());
if (!CollectionUtils.isEmpty(vvCategoryPropertyEntities)) {
List<VvCategoryPropertyDTO> vvCategoryPropertyDTOS = new ArrayList<>();
for (VvCategoryPropertyEntity vvCategoryPropertyEntity : vvCategoryPropertyEntities) {
VvCategoryPropertyDTO vvCategoryPropertyDTO = new VvCategoryPropertyDTO();
BeanUtils.copyProperties(vvCategoryPropertyEntity, vvCategoryPropertyDTO);
List<VvCategoryPropertyValueEntity> vvCategoryPropertyValueEntities = vvCategoryPropertyValueDao.selectVvPropertyValueByPropertyId(vvCategoryPropertyEntity.getId());
vvCategoryPropertyDTO.setVvPropertyValueList(vvCategoryPropertyValueEntities);
vvCategoryPropertyDTOS.add(vvCategoryPropertyDTO);
}
vvCategoryDTO.setVvCategoryPropertyDTOList(vvCategoryPropertyDTOS);
}
}
vvCategoryDTOS.add(vvCategoryDTO);
}
return R.ok().setData(vvCategoryDTOS);