<?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="im.zhaojun.system.mapper.RoleMenuMapper">

    <sql id="Base_Column_List">
            role_id,
            menu_id
    </sql>
    <resultMap id="BaseResultMap" type="im.zhaojun.system.model.RoleMenu">
        <result column="role_id" jdbcType="INTEGER" property="roleId"/>
        <result column="menu_id" jdbcType="INTEGER" property="menuId"/>
    </resultMap>
    <insert id="insert" parameterType="im.zhaojun.system.model.RoleMenu">
        insert into role_menu (role_id, menu_id)
        values (#{roleId,jdbcType=INTEGER}, #{menuId,jdbcType=INTEGER})
    </insert>

    <delete id="deleteByRoleId">
        delete
        from role_menu
        where role_id = #{roleId}
    </delete>

    <insert id="insertRoleMenus">
        insert into role_menu( role_id, menu_id        )values
        <foreach collection="menuIds" item="menuId" index="index" separator=",">
       (   #{roleId}  ,#{menuId})
        </foreach>
    </insert>

    <delete id="deleteByMenuId">
        delete
        from role_menu
        where menu_id = #{menuId}
    </delete>

    <select id="getMenusByRoleId" resultType="java.lang.Integer">
        select menu_id
        from role_menu
        where role_id = #{roleId}
    </select>

</mapper>