<?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.RoleOperatorMapper">

    <resultMap id="BaseResultMap" type="im.zhaojun.system.model.RoleOperator">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <result column="role_id" jdbcType="INTEGER" property="roleId"/>
        <result column="operator_id" jdbcType="INTEGER" property="operatorId"/>
    </resultMap>

    <insert id="insert" parameterType="im.zhaojun.system.model.RoleOperator">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        insert into role_operator (role_id, operator_id)
        values (#{roleId,jdbcType=INTEGER}, #{operatorId,jdbcType=INTEGER})
    </insert>
    <select id="getOperatorsByRoleId" resultType="java.lang.Integer">
        select operator_id
        from role_operator
        where role_id = #{roleId}
    </select>

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

    <insert id="insertRoleVideoerecordtype">
        insert into role_videoerecordtype (
        roleid, videorecordtypeid
        )values
        <foreach collection="videorecordIds" item="rid" index="index" separator=",">

            (
            #{roleId}
            ,#{rid}
            )
        </foreach>
    </insert>

    <delete id="deleteByOperatorId">
        delete
        from operator
        where operator_id = #{operatorId}
    </delete>

    <insert id="insertRoleOperators">
        insert into role_operator(
        role_id, operator_id
        )values
        <foreach collection="operatorIds" item="operatorId" index="index" separator=",">

            (
            #{roleId}
            ,#{operatorId}
            )
        </foreach>
    </insert>

    <delete id="deleterecordtypeByRoleId">
        delete
        from role_videoerecordtype
        where roleid = #{roleId}

    </delete>

</mapper>