一、商品类型表
二、java实现查询出商品类别的所有子节点
1.1 递归(效率太低)
/**
* 通过递归获取分类树(数据量大时,效率低)
*
* @param pid
* @return
*/
public List<ProductType> getAllProductTypesByRes(Long id) {
List<ProductType> children = mapper.getChildren(id);//通过商品类型id查询商品类型的子节点
for (ProductType productType : children) {
List<ProductType> afterChildren = getAllProductTypesByRes(productType.getId());//递归查孙节点
productType.setChildren(afterChildren);
}
return children;
}
前台响应时间: