<?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.mall.mapper.MallHotWordMapper">
    
    <resultMap type="MallHotWord" id="MallHotWordResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="sort"    column="sort"    />
    </resultMap>

    <sql id="selectMallHotWordVo">
        select id, name, sort from mall_hot_word
    </sql>

    <select id="selectMallHotWordList" parameterType="MallHotWord" resultMap="MallHotWordResult">
        <include refid="selectMallHotWordVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
        </where>
    </select>
    
    <select id="selectMallHotWordById" parameterType="Long" resultMap="MallHotWordResult">
        <include refid="selectMallHotWordVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertMallHotWord" parameterType="MallHotWord" useGeneratedKeys="true" keyProperty="id">
        insert into mall_hot_word
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="sort != null">sort,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="sort != null">#{sort},</if>
         </trim>
    </insert>

    <update id="updateMallHotWord" parameterType="MallHotWord">
        update mall_hot_word
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="sort != null">sort = #{sort},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMallHotWordById" parameterType="Long">
        delete from mall_hot_word where id = #{id}
    </delete>

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