<?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.party.mapper.ClickNumberMapper">
    
    <resultMap type="ClickNumber" id="ClickNumberResult">
        <result property="id"    column="id"    />
        <result property="type"    column="type"    />
        <result property="businessKey"    column="business_key"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectClickNumberVo">
        select id, type, business_key, create_by, create_time from click_number
    </sql>

    <select id="selectClickNumberList" parameterType="ClickNumber" resultMap="ClickNumberResult">
        <include refid="selectClickNumberVo"/>
        <where>  
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="businessKey != null  and businessKey != ''"> and business_key = #{businessKey}</if>
        </where>
    </select>
    
    <select id="selectClickNumberById" parameterType="Long" resultMap="ClickNumberResult">
        <include refid="selectClickNumberVo"/>
        where id = #{id}
    </select>

    <insert id="insertClickNumber" parameterType="ClickNumber">
        insert into click_number
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="type != null">type,</if>
            <if test="businessKey != null">business_key,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="type != null">#{type},</if>
            <if test="businessKey != null">#{businessKey},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateClickNumber" parameterType="ClickNumber">
        update click_number
        <trim prefix="SET" suffixOverrides=",">
            <if test="type != null">type = #{type},</if>
            <if test="businessKey != null">business_key = #{businessKey},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteClickNumberById" parameterType="Long">
        delete from click_number where id = #{id}
    </delete>

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

    <select id="selectClickNumberStatisticsByTypeBusinessKey" resultType="java.lang.Long">
        select count(*) from click_number where type = #{type} and business_key = #{businessKey}
    </select>
</mapper>