{
"category":[
"id":"1",
"isleaf":"0",
"isshow":"1",
"label":"根结点",
"name":"根结点",
"orderby":1,
"parentid":"0",
"children":[
{
"id":"1-1",
"isleaf":"0",
"isshow":"1",
"label":"零基础",
"name":"零基础",
"orderby":1,
"parentid":"1",
"children":[
{
"id":"1-1-1",
"isleaf":"1",
"isshow":"1",
"label":"英语音标",
"name":"英语音标",
"orderby":1,
"parentid":"1-1"
},
],
},
],
}
]
}
自查询
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xuecheng.course.mapper.CategoryMapper">
<resultMap type="com.xuecheng.framework.domain.course.ext.CategoryNode" id="CategoryMap" >
<id property="id" column="one_id"/>
<result property="name" column="one_name"/>
<collection property="children"
ofType="com.xuecheng.framework.domain.course.ext.CategoryNode">
<id property="id" column="two_id"/>
<result property="name" column="two_name"/>
<collection property="children"
ofType="com.xuecheng.framework.domain.course.ext.CategoryNode">
<id property="id" column="three_id"/>
<result property="name" column="three_name"/>
</collection>
</collection>
</resultMap>
<select id="findCategoryList" resultMap="CategoryMap">
SELECT a.id one_id,
a.name one_name ,
b.id two_id,
b.name two_name,
c.id three_id,
c.name three_name
from
category a
LEFT JOIN
category b
on
a.id=b.parentid
LEFT JOIN
category c
on
b.id=c.parentid
where
a.parentid=0
</select>
</mapper>