例子一
1. 查询 100001下的子节点
2. mapper
select
from category
where id = #{id,jdbcType=INTEGER}
select
from category
where parent_id= #{parent_id}
//Category实体类equals和hashCode方法进行重写 只需比较id即可
//递归算法,算出子节点
public Set findChildCatgory(Set categorySet,Integer categoryId){
Category category = categoryMapper.selectByPrimaryKey(categoryId);
if (category != null){
categorySet.add(category);
}
//查找子节点 eg: 100001 ------ 100006 100007 100008 100009 100010
List categoryList = categoryMapper.selectCategoryChildrenByParentId(categoryId);
for (Category categoryitem : categoryList){
findChildCatgory