<?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.example.hotel.mapper.RolePermissionRefMapper">

  <delete id="deleteByRoleId">
      DELETE
      FROM
          role_permission_ref
      WHERE
          role_id = #{value}
          AND del_flag = 0
  </delete>

    <delete id="deleteByPermissionId">
      DELETE
      FROM
          role_permission_ref
      WHERE
          permission_id = #{value}
          AND del_flag = 0
  </delete>


    <insert id="batchInsert">
    <foreach collection="list" item="item">
        INSERT INTO
        role_permission_ref
        ( role_id, permission_id )
        VALUES
        (
            #{item.roleId}, #{item.permissionId}
        );
    </foreach>
  </insert>

</mapper>