<?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.zjt.mapper.TmenuMapper">
  <resultMap id="BaseResultMap" type="com.zjt.entity.Tmenu">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="icon" jdbcType="VARCHAR" property="icon" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="state" jdbcType="INTEGER" property="state" />
    <result column="url" jdbcType="VARCHAR" property="url" />
    <result column="p_id" jdbcType="INTEGER" property="pId" />
  </resultMap>



  <!--根据角色id查询所有资源-->
  <select id="selectMenusByRoleId" resultMap="BaseResultMap" parameterType="java.lang.Integer">
    <![CDATA[
    SELECT tm.*
    from T_MENU tm
    inner join
    T_ROLE_MENU trm
    on tm.id=trm.menu_id
    where
    trm.role_id=]]>#{roleid}
  </select>


  <select id="selectByParentIdAndRoleId" resultMap="BaseResultMap" parameterType="java.util.HashMap">
    <![CDATA[
    select tm.*
    from t_menu tm
      inner join t_role_menu trm
        on trm.menu_id=tm.id
    where trm.role_id=]]>#{roleid}
    <![CDATA[and tm.p_id=]]>#{pid}
    order by tm.id ASC
  </select>



</mapper>