mybatis返回树形结构数据
https://blog.csdn.net/BushQiang/article/details/100707245
<resultMap id="orgTreeMap" type="com.ylz.api.vo.OrgVO">
<result column="org_id" jdbcType="VARCHAR" property="orgId"/>
<result column="org_name" jdbcType="VARCHAR" property="orgName"/>
<result column="parent_id" jdbcType="VARCHAR" property="parentId"/>
<collection column="org_id" property="children" ofType="com.ylz.api.vo.OrgVO" select="getOrgByParentId" >
</collection>
</resultMap>
<select id="getOrgTree" parameterType="java.lang.String" resultMap="orgTreeMap">
select o.org_id, o.org_name, o.parent_id
from org_table@allcenter_db o
where o.org_id = #{orgId}
</select>
<select id="getOrgByParentId" parameterType="java.lang.String" resultMap="orgTreeMap">
select o.org_id, o.org_name, o.parent_id
from org_table@allcenter_db o
where o.parent_id = #{orgId}
</select>