xml代码。
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.wellcloud.scriptmakerserver.mapper.FunctionMapper"><resultMap id="FunctionTreeMap" type="com.wellcloud.scriptmakerserver.model.vo.FunctionVo"><id property="id" column="id"/><result property="modules" column="modules"/><result property="optionalFunction" column="optional_function"/><result property="seqFunction" column="seq_function"/><result property="repFunction" column="rep_function"/><result property="routeFunction" column="route_function"/><result property="variables" column="variables"/><result property="name" column="name"/><result property="priority" column="priority"/><result property="description" column="description"/><result property="parentId" column="parent_id"/><collection property="children" column="id" select="queryChildren"/></resultMap><select id="queryAllFunctions" resultMap="FunctionTreeMap">select*from functions where parent_id=0</select><select id="queryChildren" resultMap="FunctionTreeMap">SELECT*from functions where parent_id = #{id}</select></mapper>
代码逻辑非常清晰简单,就不放model类的代码了,如有需要可以参考原例。
