<?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.ruoyi.system.mapper.ZxBonusMapper">
    
    <resultMap type="ZxBonus" id="ZxBonusResult">
        <result property="bonusId"    column="bonus_id"    />
        <result property="userId"    column="user_id"    />
        <result property="boundary"    column="boundary"    />
        <result property="checkType"    column="check_type"    />
        <result property="bonusType"    column="bonus_type"    />
        <result property="bonusReason"    column="bonus_reason"    />
        <result property="bonusTime"    column="bonus_time"    />
        <result property="score"    column="score"    />
        <result property="type"    column="type"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectZxBonusVo">
        select bonus_id, user_id, boundary, check_type, bonus_type, bonus_reason, bonus_time, score,type, create_by, create_time, update_by, update_time, remark from zx_bonus
    </sql>

    <select id="selectZxBonusList" parameterType="ZxBonus" resultMap="ZxBonusResult">
        <include refid="selectZxBonusVo"/>
        <where>  
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="boundary != null  and boundary != ''"> and boundary = #{boundary}</if>
            <if test="checkType != null  and checkType != ''"> and check_type = #{checkType}</if>
            <if test="bonusType != null  and bonusType != ''"> and bonus_type = #{bonusType}</if>
            <if test="bonusReason != null  and bonusReason != ''"> and bonus_reason = #{bonusReason}</if>
            <if test="bonusTime != null "> and bonus_time = #{bonusTime}</if>
            <if test="score != null  and score != ''"> and score = #{score}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
        </where>
    </select>
    
    <select id="selectZxBonusByBonusId" parameterType="Long" resultMap="ZxBonusResult">
        <include refid="selectZxBonusVo"/>
        where bonus_id = #{bonusId}
    </select>
        
    <insert id="insertZxBonus" parameterType="ZxBonus" useGeneratedKeys="true" keyProperty="bonusId">
        insert into zx_bonus
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="boundary != null">boundary,</if>
            <if test="checkType != null">check_type,</if>
            <if test="bonusType != null">bonus_type,</if>
            <if test="bonusReason != null">bonus_reason,</if>
            <if test="bonusTime != null">bonus_time,</if>
            <if test="score != null">score,</if>
            <if test="type != null">type,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="boundary != null">#{boundary},</if>
            <if test="checkType != null">#{checkType},</if>
            <if test="bonusType != null">#{bonusType},</if>
            <if test="bonusReason != null">#{bonusReason},</if>
            <if test="bonusTime != null">#{bonusTime},</if>
            <if test="score != null">#{score},</if>
            <if test="type != null">#{type},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateZxBonus" parameterType="ZxBonus">
        update zx_bonus
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="boundary != null">boundary = #{boundary},</if>
            <if test="checkType != null">check_type = #{checkType},</if>
            <if test="bonusType != null">bonus_type = #{bonusType},</if>
            <if test="bonusReason != null">bonus_reason = #{bonusReason},</if>
            <if test="bonusTime != null">bonus_time = #{bonusTime},</if>
            <if test="score != null">score = #{score},</if>
            <if test="type != null">type = #{type},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where bonus_id = #{bonusId}
    </update>

    <delete id="deleteZxBonusByBonusId" parameterType="Long">
        delete from zx_bonus where bonus_id = #{bonusId}
    </delete>

    <delete id="deleteZxBonusByBonusIds" parameterType="String">
        delete from zx_bonus where bonus_id in 
        <foreach item="bonusId" collection="array" open="(" separator="," close=")">
            #{bonusId}
        </foreach>
    </delete>
</mapper>