当前位置: 代码迷 >> SQL >> ibatis+ext 动态菜单//sql一部分
  详细解决方案

ibatis+ext 动态菜单//sql一部分

热度:51   发布时间:2016-05-05 13:51:59.0
ibatis+ext 动态菜单//sql部分
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">



<sqlMap namespace="Menu">



    <typeAlias alias="TreePanel" type="com.wenwu.entity.TreePanel" />

    <typeAlias alias="TreeNode" type="com.wenwu.entity.TreeNode" />

    <typeAlias alias="MenuFilter" type="com.wenwu.entity.filter.MenuFilter" />

   

    <resultMap id="get-treepanel-result" class="TreePanel">

        <result property="icollapsible" column="ICOLLAPSIBLE"/>

        <result property="split" column="split" />

        <result property="rootVisible" column="rootVisible"/>

        <result property="title" column="title"/>

        <result property="lines" column="lines"/>

        <result property="autoScroll" column="autoScroll"/>

        <result property="xtype" column="xtype"/>

        <result property="treePanelId" column="treepanel_id"/>

        <result property="root" column="root" select="Menu.getTreeRootNode"/>

    </resultMap>

   

   

    <select id="getTreePanel" parameterClass="MenuFilter" resultMap="get-treepanel-result">

    <![CDATA[

        SELECT T.TREEPANEL_ID,

               T.ICOLLAPSIBLE, T.SPLIT, T.ROOTVISIBLE,

               'SUBSTR(''' || #authStr# || ''', AUTH_INDEX, 1) = 1 AND ' || T.ROOT  as root,

               T.TITLE,

               T.LINES, T.AUTOSCROLL, T.XTYPE

          FROM T_MENU_TREEPANEL T

          WHERE SUBSTR(#authStr#, T.AUTH_INDEX, 1) = 1

        

    ]]>

    </select>

   

   <resultMap id="get-treerootnode-result" class="TreeNode">

        <result property="nodeId" column="node_id" />

        <result property="parentNodeId" column="parentnode_id" />

        <result property="expanded" column="expanded" />

        <result property="xtype" column="xtype" />

        <result property="text" column="text" />

        <result property="panelName" column="panelName" />

        <result property="iconCls" column="iconCls" />

        <result property="nodeType" column="nodeType" />

        <result property="leaf" column="leaf" />

        <result property="children" column="dynamic_sql" select="Menu.getTreeNode" />

    </resultMap>

   

    <!-- 获取菜单根节点 -->

    <select id="getTreeRootNode" parameterClass="java.lang.String" resultMap="get-treerootnode-result">

    <![CDATA[

        SELECT T.NODE_ID,

               #id# as dynamic_sql,

               T.PARENTNODE_ID, T.TEXT, T.PANELNAME, T.XTYPE, T.EXPANDED, T.ICONCLS,

               T.NODETYPE,

               T.LEAF

          FROM T_MENU_TREENODE T

         WHERE $id$ = T.NODE_ID

    ]]>

    </select>

   

    <resultMap id="get-treenode-result" class="TreeNode">

        <result property="nodeId" column="node_id" />

        <result property="parentNodeId" column="parentnode_id" />

        <result property="expanded" column="expanded" />

        <result property="xtype" column="xtype" />

        <result property="text" column="text" />

        <result property="panelName" column="panelName" />

        <result property="iconCls" column="iconCls" />

        <result property="nodeType" column="nodeType" />

        <result property="leaf" column="leaf" />

        <!-- 递归获取所有下级菜单 -->

        <result property="children" column="dynamic_sql" select="Menu.getTreeNode"/>

    </resultMap>

    <!-- 获取菜单 -->

    <select id="getTreeNode" parameterClass="java.lang.String" resultMap="get-treenode-result">

    <![CDATA[

        SELECT T.NODE_ID,

               #id# || '=' || T.PARENTNODE_ID || ' AND ' || T.NODE_ID as dynamic_sql,

               T.PARENTNODE_ID, T.TEXT, T.PANELNAME, T.XTYPE, T.EXPANDED, T.ICONCLS,

               T.NODETYPE,

               T.LEAF

          FROM T_MENU_TREENODE T

         WHERE $id$ = T.PARENTNODE_ID

    ]]>

    </select>

   

</sqlMap>
  相关解决方案