商品模块bug修复
This commit is contained in:
parent
e54d866e33
commit
4b1070887d
|
|
@ -37,6 +37,10 @@ public class ConsInfoDTO implements Serializable {
|
|||
*/
|
||||
@NotNull(message = "耗材分组id不能为空", groups = DefaultGroup.class)
|
||||
private Long consGroupId;
|
||||
/**
|
||||
* 耗材分组名称
|
||||
*/
|
||||
private String consGroupName;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -22,14 +22,13 @@ public class ProductBriefDTO implements Serializable {
|
|||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 商品分类
|
||||
* 商品分类id
|
||||
*/
|
||||
private Long categoryId;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 商品封面图
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -9,11 +9,13 @@ import com.czg.enums.YesNoEnum;
|
|||
import com.czg.exception.CzgException;
|
||||
import com.czg.product.dto.ConsInfoDTO;
|
||||
import com.czg.product.dto.ProductBriefDTO;
|
||||
import com.czg.product.entity.ConsGroup;
|
||||
import com.czg.product.entity.ConsGroupRelation;
|
||||
import com.czg.product.entity.ConsInfo;
|
||||
import com.czg.product.param.ConsSubUnitParam;
|
||||
import com.czg.product.service.ConsInfoService;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.product.mapper.ConsGroupMapper;
|
||||
import com.czg.service.product.mapper.ConsGroupRelationMapper;
|
||||
import com.czg.service.product.mapper.ConsInfoMapper;
|
||||
import com.czg.service.product.mapper.ProdConsRelationMapper;
|
||||
|
|
@ -28,6 +30,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 耗材信息
|
||||
|
|
@ -41,6 +45,7 @@ public class ConsInfoServiceImpl extends ServiceImpl<ConsInfoMapper, ConsInfo> i
|
|||
|
||||
private final ConsGroupRelationMapper consGroupRelationMapper;
|
||||
private final ProdConsRelationMapper prodConsRelationMapper;
|
||||
private final ConsGroupMapper consGroupMapper;
|
||||
|
||||
private QueryWrapper buildQueryWrapper(ConsInfoDTO param) {
|
||||
QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper();
|
||||
|
|
@ -66,9 +71,13 @@ public class ConsInfoServiceImpl extends ServiceImpl<ConsInfoMapper, ConsInfo> i
|
|||
public Page<ConsInfoDTO> getConsInfoPage(ConsInfoDTO param) {
|
||||
QueryWrapper queryWrapper = buildQueryWrapper(param);
|
||||
Page<ConsInfoDTO> page = super.pageAs(PageUtil.buildPage(), queryWrapper, ConsInfoDTO.class);
|
||||
List<ConsGroup> consGroupList = consGroupMapper.selectListByQuery(QueryWrapper.create().eq(ConsGroup::getShopId, param.getShopId()));
|
||||
Map<Long, String> collect = consGroupList.stream().collect(Collectors.toMap(ConsGroup::getId, ConsGroup::getName));
|
||||
page.getRecords().parallelStream().forEach(item -> {
|
||||
List<ProductBriefDTO> productList = prodConsRelationMapper.getProductListByConId(item.getId());
|
||||
item.setProductList(productList);
|
||||
String consGroupName = collect.get(item.getConsGroupId());
|
||||
item.setConsGroupName(consGroupName);
|
||||
});
|
||||
return page;
|
||||
}
|
||||
|
|
@ -78,9 +87,13 @@ public class ConsInfoServiceImpl extends ServiceImpl<ConsInfoMapper, ConsInfo> i
|
|||
QueryWrapper queryWrapper = buildQueryWrapper(param);
|
||||
queryWrapper.eq(ConsInfo::getStatus, StatusEnum.ENABLED.value());
|
||||
List<ConsInfoDTO> list = super.listAs(queryWrapper, ConsInfoDTO.class);
|
||||
List<ConsGroup> consGroupList = consGroupMapper.selectListByQuery(QueryWrapper.create().eq(ConsGroup::getShopId, param.getShopId()));
|
||||
Map<Long, String> collect = consGroupList.stream().collect(Collectors.toMap(ConsGroup::getId, ConsGroup::getName));
|
||||
list.parallelStream().forEach(item -> {
|
||||
List<ProductBriefDTO> productList = prodConsRelationMapper.getProductListByConId(item.getId());
|
||||
item.setProductList(productList);
|
||||
String consGroupName = collect.get(item.getConsGroupId());
|
||||
item.setConsGroupName(consGroupName);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
<select id="getProductListByConId" resultType="com.czg.product.dto.ProductBriefDTO">
|
||||
select t2.id,
|
||||
t2.category_id,
|
||||
t2.name,
|
||||
t2.cover_img
|
||||
from tb_prod_cons_relation t1
|
||||
|
|
|
|||
Loading…
Reference in New Issue