<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.rightsSetting.dao.impl.RightsCustomRelationDaoImpl">

    <resultMap  id="BaseResultMap" type="com.pcloud.book.rightsSetting.entity.RightsCustomRelation">
        <result property="rightsSettingItemId" column="rights_setting_item_id" jdbcType="BIGINT"/>
        <result property="customPlanId" column="custom_plan_id" jdbcType="BIGINT"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        rights_setting_item_id, custom_plan_id, create_time, update_time
    </sql>

    <!--批量新增-->
    <insert id="batchInsert" useGeneratedKeys="true" parameterType="java.util.List">
        insert into book.rights_custom_relation (
        rights_setting_item_id, custom_plan_id, create_time, update_time
        )
        values
        <foreach collection="list" item="item" index="index" separator="," >
            (
            #{item.rightsSettingItemId},
            #{item.customPlanId},
            NOW(),
            NOW()
            )
        </foreach>
    </insert>

    <select id="getCustomByItemIds" parameterType="java.util.List" resultMap="BaseResultMap">
        select <include refid="Base_Column_List"/> from rights_custom_relation where  1=1 and
        rights_setting_item_id IN
        <foreach collection="list" item="item" separator="," open="(" close=")">
            ${item}
        </foreach>
    </select>
</mapper>