SearchLogMapper.xml
2.62 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?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.web.controller.business.mapper.SearchLogMapper">
<resultMap type="SearchLog" id="SearchLogResult">
<result property="id" column="id" />
<result property="searchParams" column="search_params" />
<result property="type" column="type" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
</resultMap>
<sql id="selectSearchLogVo">
select id, search_params, type, create_by, create_time from search_log
</sql>
<select id="selectSearchLogList" parameterType="SearchLog" resultMap="SearchLogResult">
<include refid="selectSearchLogVo"/>
<where>
<if test="searchParams != null and searchParams != ''"> and search_params = #{searchParams}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
</where>
</select>
<select id="getSearchLogs" parameterType="SearchLog" resultType="SearchLog" >
select
a.createTime,
a.searchParams ,
a.jsonProperty
from
(
select
distinct on(search_params ->> ${jsonProperty}) search_params AS searchParams,
search_params ->> ${jsonProperty} as jsonProperty,
create_time AS createTime
from
credit_nx.search_log
where
`type` = #{type}
and create_by = #{createBy}
order by search_params ->> ${jsonProperty} desc ) as a
order by
a.createTime desc
</select>
<insert id="insertSearchLog" parameterType="SearchLog">
insert into search_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="searchParams != null">search_params,</if>
<if test="type != null">type,</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="searchParams != null">#{searchParams},</if>
<if test="type != null">#{type},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
</mapper>