<?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.zhiqiyun.open.core.mapper.RoleInfoMapper">

    <insert id="insertAuthority">
        insert into role_authority (authority_id, role_id)
        values
        <foreach collection="listAuthorities" item="item" index="index" separator=",">
            (#{item,jdbcType=BIGINT}, #{roleId,jdbcType=BIGINT})
        </foreach>
    </insert>

    <select id="findAuthorities" resultType="java.lang.Long">
        select authority_id
        from role_authority
        WHERE role_id = #{roleId,jdbcType=BIGINT}
    </select>
    <delete id="deleteAuthorities" parameterType="java.lang.Long">
        delete FROM role_authority
        <where>
            role_id in
            <foreach collection="roleIds" item="roleId" separator="," open="(" close=")">
                #{roleId,jdbcType=BIGINT}
            </foreach>
        </where>
    </delete>

    <delete id="deleteBatchIds">
        delete FROM role_info
        <where>
            id in
            <foreach collection="roleIds" item="roleId" separator="," open="(" close=")">
                #{roleId,jdbcType=BIGINT}
            </foreach>
        </where>
    </delete>
</mapper>
