mybatis 父子关系递归查询,父子菜单


<!--级联查询返回模型-->
    <resultMap type="Map" id="fatherMap">
        <id column="id" property="id"/>
        <collection property="list" ofType="com.jmxf.entity.zdbwManage.ZdbwIndoor" column="id" select="findMenuByPid"/>
    </resultMap>
 
    <!--级联查询父菜单-->
    <select id="selectAllMenu" resultMap="fatherMap" >
         select * from zdbw_indoor where fip = '0'
    </select>
 
    <!--级联查询子菜单-->
    <select id="findMenuByPid" resultMap="fatherMap" >
         select * from zdbw_indoor where fid = #{id} 
    </select>
<!--级联查询返回模型-->

 参数需要多个/参数需要传到子节点

<!-- 室内设备列表 -->
    <resultMap type="Map" id="indoorMap">
        <id column="dm" property="dm" />
        <id column="sncsid" property="sncsid"  />
        <collection property="list" ofType="java.util.Map"     column="{dm=dm,sncsid=sncsid}" select="findCustomDev" />
    </resultMap>

    <!--级联查询父菜单 -->
    <select id="queryIndoorDevWork" resultMap="indoorMap">
        select dm,mc,icon,IFNULL(#{sncsid},'') sncsid from code_indoor_dev_type where zt='1'
    </select>

    <!--级联查询子菜单 -->
    <select id="findCustomDev" resultType="java.util.Map">
        select * from zdbw_custom_dev where sbzl = #{dm} and jmsnbz = '2' 
        <if test ='""!= sncsid'> and sncsid = #{sncsid}</if>
    </select>
<!-- 室内设备列表 -->

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM