SystemLogMapper.java
3.77 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package com.uccc.log.mapper;
import com.uccc.pretty.common.SystemLog;
import com.uccc.pretty.common.SystemLogEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* Created by bert on 2021-09-15 13:20
*/
public interface SystemLogMapper {
static final String TABLE_NAME = "system_log";
@Insert({
"<script>",
"insert into " + TABLE_NAME,
"(",
"cts",
"<when test='systemLog.operatorId!=null'>",
",operator_id",
"</when>",
"<when test='systemLog.action!=null'>",
",action",
"</when>",
"<when test='systemLog.remark!=null'>",
",remark",
"</when>",
"<when test='systemLog.extra!=null'>",
",extra",
"</when>",
"<when test='systemLog.ip!=null'>",
",ip",
"</when>",
")",
"values",
"(",
"#{systemLog.cts}",
"<when test='systemLog.operatorId!=null'>",
",#{systemLog.operatorId}",
"</when>",
"<when test='systemLog.action!=null'>",
",#{systemLog.action}",
"</when>",
"<when test='systemLog.remark!=null'>",
",#{systemLog.remark}",
"</when>",
"<when test='systemLog.extra!=null'>",
",#{systemLog.extra}",
"</when>",
"<when test='systemLog.ip!=null'>",
",#{systemLog.ip}",
"</when>",
")",
"</script>"
})
int insertLog(@Param("systemLog") SystemLog systemLog);
@Select({
"<script>",
"SELECT s.operator_id as operator_id, s.action as action, s.cts as cts,s.remark as remark,s.ip as ip, s.extra as extra, u.name as name,u.phone as phone, u.admin_level as admin_level from system_log s left JOIN users u on s.operator_id = u.id",
"where 1=1",
"<when test='endTime!=null'>",
"and cts between #{startTime} and #{endTime}",
"</when>",
"<when test='ip!=null'>",
"and ip = #{ip}",
"</when>",
"<when test='action!=null'>",
"and action = #{action}",
"</when>",
"<when test='operator!=null'>",
"and operator_id = #{operator}",
"</when>",
"order by cts desc",
"limit #{limit}",
"offset #{page}-1",
"</script>"
})
List<SystemLogEntity> selectSysLogByCondition(@Param("limit") Integer limit, @Param("page")Integer page,
@Param("operator")Long operator, @Param("action")String action, @Param("ip")String ip,
@Param("startTime")String startTime, @Param("endTime")String endTime);
@Select({
"<script>",
"SELECT count(*) from system_log s left JOIN users u on s.operator_id = u.id",
"where 1=1",
"<when test='endTime!=null'>",
"and cts between #{startTime} and #{endTime}",
"</when>",
"<when test='ip!=null'>",
"and ip = #{ip}",
"</when>",
"<when test='action!=null'>",
"and action = #{action}",
"</when>",
"<when test='operator!=null'>",
"and operator_id = #{operator}",
"</when>",
"</script>"
})
int selectSysLogCountByCondition(@Param("operator")Long operator, @Param("action")String action, @Param("ip")String ip,
@Param("startTime")String startTime, @Param("endTime")String endTime);
}