SearchHistoryMapper.xml
1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?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>