<?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.tmerclub.cloud.platform.mapper.SysAccessMenuPermissionMapper">

    <resultMap id="sysAccessMenuMap" type="com.tmerclub.cloud.platform.model.SysAccessMenuPermission">
        <id column="id" property="id" />
        <result column="sys_access_key_id" property="sysAccessKeyId"/>
        <result column="menu_permission_id" property="menuPermissionId"/>
    </resultMap>

    <select id="queryMenuPermsBySysAccessKeyId" resultType="java.lang.Long">
        select menu_permission_id from sys_access_menu_permission where sys_access_key_id = #{sysAccessKeyId}
    </select>

    <insert id="saveSysAccessMenuPerms">
        insert into sys_access_menu_permission(sys_access_key_id, menu_permission_id) values
            <foreach collection="menuPermsIdList" item="menuPermsId" separator=",">
               (#{sysAccessKeyId}, #{menuPermsId})
            </foreach>
    </insert>

    <delete id="deletSysAccessMenuPermsBySysAccessKeyId" parameterType="java.lang.Long">
        delete from sys_access_menu_permission where sys_access_key_id = #{sysAccessKeyId}
    </delete>
</mapper>