<?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.personalstage.dao.impl.PersonalStageJumpEmailDaoImpl">

    <resultMap  id="BaseResultMap" type="com.pcloud.book.personalstage.entity.PersonalStageJumpEmail">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="personalStageJumpId" column="personal_stage_jump_id" jdbcType="BIGINT"/>
        <result property="email" column="email" jdbcType="VARCHAR"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        id, personal_stage_jump_id, email, create_time
    </sql>

    <select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List"/>
        from personal_stage_jump_email
        where id = #{id,jdbcType=BIGINT}
    </select>

    <select id="listBy" resultMap="BaseResultMap" parameterType="map">
        select
        <include refid="Base_Column_List"/>
        from personal_stage_jump_email
        where personal_stage_jump_id IN
        <foreach collection="jumpIds" item="jumpId" separator="," open="(" close=")">
            ${jumpId}
        </foreach>
    </select>

    <select id="getByJumpId" resultMap="BaseResultMap" parameterType="java.lang.Long">
        select
            <include refid="Base_Column_List"/>
        from personal_stage_jump_email
        where personal_stage_jump_id = #{jumpId,jdbcType=BIGINT}
    </select>

    <delete id="deleteById" parameterType="long">
        delete from personal_stage_jump_email
        where id = #{id,jdbcType=BIGINT}
    </delete>

    <delete id="deleteByJumpId" parameterType="long">
        delete from personal_stage_jump_email
        where personal_stage_jump_id = #{jumpId,jdbcType=BIGINT}
    </delete>

    <insert id="insert" parameterType="com.pcloud.book.personalstage.entity.PersonalStageJumpEmail" useGeneratedKeys="true" keyProperty="id">
        insert into personal_stage_jump_email
        <trim prefix="(" suffix=")" suffixOverrides=",">
            personal_stage_jump_id,
            email,
            create_time
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            #{personalStageJumpId,jdbcType=BIGINT},
            #{email,jdbcType=VARCHAR},
            NOW()
        </trim>
    </insert>

    <insert id="batchInsert" parameterType="list" useGeneratedKeys="true" keyProperty="id">
        insert into personal_stage_jump_email
        <trim prefix="(" suffix=")" suffixOverrides=",">
            personal_stage_jump_id,
            email,
            create_time
        </trim>
        values
        <foreach collection="list" item="item" separator=",">
            <trim prefix="(" suffix=")" suffixOverrides=",">
                #{item.personalStageJumpId,jdbcType=BIGINT},
                #{item.email,jdbcType=VARCHAR},
                NOW()
            </trim>
        </foreach>
    </insert>
</mapper>