分组列表增加 商品列表字段
This commit is contained in:
@@ -68,7 +68,20 @@ public class ProdGroupServiceImpl extends ServiceImpl<ProdGroupMapper, ProdGroup
|
||||
public List<ProdGroupDTO> getProdGroupList(ProdGroupDTO param) {
|
||||
QueryWrapper queryWrapper = buildQueryWrapper(param);
|
||||
queryWrapper.eq(ProdGroup::getStatus, SystemConstants.OneZero.ONE);
|
||||
return super.listAs(queryWrapper, ProdGroupDTO.class);
|
||||
List<ProdGroupDTO> groups = listAs(queryWrapper, ProdGroupDTO.class);
|
||||
groups.forEach(group -> {
|
||||
List<Long> productIdList = prodGroupRelationMapper.selectObjectListByQueryAs(query()
|
||||
.select(ProdGroupRelation::getProductId).eq(ProdGroupRelation::getProdGroupId, group.getId()), Long.class);
|
||||
if (CollUtil.isNotEmpty(productIdList)) {
|
||||
List<ProductBriefDTO> productList = productMapper.selectListByQueryAs(query()
|
||||
.select(Product::getId, Product::getCategoryId, Product::getName, Product::getCoverImg)
|
||||
.in(Product::getId, productIdList), ProductBriefDTO.class);
|
||||
group.setProductList(productList);
|
||||
} else {
|
||||
group.setProductList(new ArrayList<>());
|
||||
}
|
||||
});
|
||||
return groups;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,7 +90,9 @@ public class ProdGroupServiceImpl extends ServiceImpl<ProdGroupMapper, ProdGroup
|
||||
ProdGroupDTO dto = super.getOneAs(query().eq(ProdGroup::getId, id).eq(ProdGroup::getShopId, shopId), ProdGroupDTO.class);
|
||||
List<Long> productIdList = prodGroupRelationMapper.selectObjectListByQueryAs(query().select(ProdGroupRelation::getProductId).eq(ProdGroupRelation::getProdGroupId, id), Long.class);
|
||||
if (CollUtil.isNotEmpty(productIdList)) {
|
||||
List<ProductBriefDTO> productList = productMapper.selectListByQueryAs(query().select(Product::getId, Product::getCategoryId, Product::getName, Product::getCoverImg).in(Product::getId, productIdList), ProductBriefDTO.class);
|
||||
List<ProductBriefDTO> productList = productMapper.selectListByQueryAs(query()
|
||||
.select(Product::getId, Product::getCategoryId, Product::getName, Product::getCoverImg)
|
||||
.in(Product::getId, productIdList), ProductBriefDTO.class);
|
||||
dto.setProductList(productList);
|
||||
} else {
|
||||
dto.setProductList(new ArrayList<>());
|
||||
@@ -171,7 +186,7 @@ public class ProdGroupServiceImpl extends ServiceImpl<ProdGroupMapper, ProdGroup
|
||||
@CacheEvict(value = {CacheConstant.USER_CLIENT_HOTS_PRODUCT, CacheConstant.USER_CLIENT_GROUPS_PRODUCT}, key = "#shopId", allEntries = true)
|
||||
public void enableProdGroup(Long shopId, Long id) {
|
||||
UpdateChain.of(ProdGroup.class)
|
||||
.set(ProdGroup::getStatus,SystemConstants.OneZero.ONE)
|
||||
.set(ProdGroup::getStatus, SystemConstants.OneZero.ONE)
|
||||
.eq(ProdGroup::getId, id)
|
||||
.eq(ProdGroup::getShopId, shopId)
|
||||
.update();
|
||||
|
||||
Reference in New Issue
Block a user