SearchHistoryMapper.xml 1.36 KB
<?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.lhcredit.project.business.search.mapper.SearchHistoryMapper">
    <insert id="add">
        insert
        into
        b_search_history
        (user_id,
         history_name,
         country,
         now_time)
        values (#{userId}, #{searchName},#{country}, #{nowTime})
    </insert>
    <update id="updateRecently">
        update b_search_history SET local_time = #{nowTime}
        where history_name = #{searchName}
    </update>
    <delete id="delHistoryName">
        DELETE FROM b_search_history WHERE user_id = #{userId} AND history_name = #{historyName}
    </delete>

    <select id="findByHistoryname" resultType="com.lhcredit.project.business.search.domain.SearchHistory">
        SELECT
        user_id as userId,
        history_name as historyName,
        country as country,
        now_time as nowTime
        FROM
        b_search_history
        <where>
            <if test=" userId !=null and userId !='' ">
                user_id = #{userId}
            </if>
            <if test=" searchName !=null and searchName !='' ">
                and history_name = #{searchName}
            </if>
        </where>
        order BY now_time desc  limit 5;
    </select>
</mapper>