<?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.bonus.zlpt.equip.mapper.HotSearchMapper">
    
    <resultMap type="com.bonus.zlpt.common.core.domain.equip.HotSearch" id="HotSearchResult">
        <result property="id"    column="id"    />
        <result property="maId"    column="ma_id"    />
        <result property="searchNum"    column="search_num"    />
    </resultMap>

    <sql id="selectHotSearchVo">
        select id, ma_id, search_num from ma_hot_search
    </sql>

    <select id="selectHotSearchList" parameterType="com.bonus.zlpt.common.core.domain.equip.HotSearch" resultMap="HotSearchResult">
        <include refid="selectHotSearchVo"/>
        <where>  
            <if test="maId != null "> and ma_id = #{maId}</if>
            <if test="searchNum != null "> and search_num = #{searchNum}</if>
        </where>
    </select>
    
    <select id="selectHotSearchById" parameterType="Long" resultMap="HotSearchResult">
        <include refid="selectHotSearchVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertHotSearch" parameterType="com.bonus.zlpt.common.core.domain.equip.HotSearch">
        insert into ma_hot_search
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="maId != null">ma_id,</if>
            <if test="searchNum != null">search_num,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="maId != null">#{maId},</if>
            <if test="searchNum != null">#{searchNum},</if>
         </trim>
    </insert>

    <update id="updateHotSearch" parameterType="com.bonus.zlpt.common.core.domain.equip.HotSearch">
        update ma_hot_search
        <trim prefix="SET" suffixOverrides=",">
            <if test="maId != null">ma_id = #{maId},</if>
            <if test="searchNum != null">search_num = #{searchNum},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteHotSearchById" parameterType="Long">
        delete from ma_hot_search where id = #{id}
    </delete>

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