<?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.ylx.point.mapper.PointSignRewardMapper">
    
    <resultMap type="PointSignReward" id="PointSignRewardResult">
        <result property="id"    column="id"    />
        <result property="signTaskId"    column="sign_task_id"    />
        <result property="continueDays"    column="continue_days"    />
        <result property="rewardPoints"    column="reward_points"    />
        <result property="sortOrder"    column="sort_order"    />
        <result property="isDeleted"    column="is_deleted"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectPointSignRewardVo">
        select id, sign_task_id, continue_days, reward_points, sort_order, is_deleted, create_time, update_time from point_sign_reward
    </sql>

    <select id="selectPointSignRewardList" parameterType="PointSignReward" resultMap="PointSignRewardResult">
        <include refid="selectPointSignRewardVo"/>
        <where>  
            <if test="signTaskId != null  and signTaskId != ''"> and sign_task_id = #{signTaskId}</if>
            <if test="continueDays != null "> and continue_days = #{continueDays}</if>
            <if test="rewardPoints != null "> and reward_points = #{rewardPoints}</if>
            <if test="sortOrder != null "> and sort_order = #{sortOrder}</if>
            <if test="isDeleted != null "> and is_deleted = #{isDeleted}</if>
        </where>
    </select>
    
    <select id="selectPointSignRewardById" parameterType="String" resultMap="PointSignRewardResult">
        <include refid="selectPointSignRewardVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertPointSignReward" parameterType="PointSignReward" useGeneratedKeys="true" keyProperty="id">
        insert into point_sign_reward
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="signTaskId != null and signTaskId != ''">sign_task_id,</if>
            <if test="continueDays != null">continue_days,</if>
            <if test="rewardPoints != null">reward_points,</if>
            <if test="sortOrder != null">sort_order,</if>
            <if test="isDeleted != null">is_deleted,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="signTaskId != null and signTaskId != ''">#{signTaskId},</if>
            <if test="continueDays != null">#{continueDays},</if>
            <if test="rewardPoints != null">#{rewardPoints},</if>
            <if test="sortOrder != null">#{sortOrder},</if>
            <if test="isDeleted != null">#{isDeleted},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updatePointSignReward" parameterType="PointSignReward">
        update point_sign_reward
        <trim prefix="SET" suffixOverrides=",">
            <if test="signTaskId != null and signTaskId != ''">sign_task_id = #{signTaskId},</if>
            <if test="continueDays != null">continue_days = #{continueDays},</if>
            <if test="rewardPoints != null">reward_points = #{rewardPoints},</if>
            <if test="sortOrder != null">sort_order = #{sortOrder},</if>
            <if test="isDeleted != null">is_deleted = #{isDeleted},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePointSignRewardById" parameterType="String">
        delete from point_sign_reward where id = #{id}
    </delete>

    <delete id="deletePointSignRewardByIds" parameterType="String">
        delete from point_sign_reward where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <insert id="batchInsertPointSignReward" parameterType="java.util.List">
        insert into point_sign_reward (sign_task_id, continue_days, reward_points, sort_order, is_deleted, create_time, update_time)
        values
        <foreach collection="list" item="item" separator=",">
            (#{item.signTaskId}, #{item.continueDays}, #{item.rewardPoints}, #{item.sortOrder}, #{item.isDeleted}, #{item.createTime}, #{item.updateTime})
        </foreach>
    </insert>
</mapper>