-
Notifications
You must be signed in to change notification settings - Fork 266
Expand file tree
/
Copy pathLogMapper.xml
More file actions
56 lines (51 loc) · 2.18 KB
/
LogMapper.xml
File metadata and controls
56 lines (51 loc) · 2.18 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
<?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="io.github.talelin.latticy.mapper.LogMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="io.github.talelin.latticy.model.LogDO">
<id column="id" property="id"/>
<result column="message" property="message"/>
<result column="user_id" property="userId"/>
<result column="username" property="username"/>
<result column="status_code" property="statusCode"/>
<result column="method" property="method"/>
<result column="path" property="path"/>
<result column="permission" property="permission"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="delete_time" property="deleteTime"/>
<result column="is_deleted" property="isDeleted"/>
</resultMap>
<select id="findLogsByUsernameAndRange" resultType="io.github.talelin.latticy.model.LogDO">
SELECT l.* FROM lin_log l
WHERE l.is_deleted = 0
<if test="name != null">
AND l.username=#{name}
</if>
<if test="start !=null and end !=null">
AND l.create_time BETWEEN #{start} AND #{end}
</if>
ORDER BY l.create_time DESC
</select>
<select id="searchLogsByUsernameAndKeywordAndRange" resultType="io.github.talelin.latticy.model.LogDO">
SELECT l.* FROM lin_log l
WHERE l.is_deleted = 0
<if test="name != ''">
AND l.username=#{name}
</if>
<if test="start !=null and end !=null">
AND l.create_time BETWEEN #{start} AND #{end}
</if>
<if test="keyword != null">
AND l.message LIKE #{keyword}
</if>
ORDER BY l.create_time DESC
</select>
<select id="getUserNames" resultType="java.lang.String">
SELECT l.username
FROM lin_log l
WHERE l.is_deleted = 0
GROUP BY l.username
HAVING COUNT(l.username) > 0
</select>
</mapper>