OperLogMapper.xml
3.42 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
<?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.huaheng.pc.monitor.operlog.mapper.OperLogMapper">
<resultMap type="com.huaheng.pc.monitor.operlog.domain.OperLog" id="OperLogResult">
<id property="id" column="id" />
<result property="title" column="title" />
<result property="operating" column="operating" />
<result property="action" column="action" />
<result property="method" column="method" />
<result property="channel" column="channel" />
<result property="operName" column="operName" />
<result property="deptName" column="deptName" />
<result property="operUrl" column="operUrl" />
<result property="operIp" column="operIp" />
<result property="operLocation" column="operLocation" />
<result property="operParam" column="operParam" />
<result property="status" column="status" />
<result property="errorMsg" column="errorMsg" />
<result property="operTime" column="operTime" />
<result property="warehouseCode" column="warehouseCode" />
</resultMap>
<sql id="selectOperLogVo">
select
id, title, operating, action, method, channel, operName, deptName, operUrl, operIp,operLocation,operParam,status,errorMsg,operTime,warehouseCode
from
sys_oper_log
</sql>
<insert id="insertOperlog">
insert into sys_oper_log(title, operating, action, method, channel, operName, deptName, operUrl, operIp, operLocation, operParam, status, errorMsg, operTime,warehouseCode)
values (#{title}, #{operating}, #{action}, #{method}, #{channel}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{status}, #{errorMsg}, sysdate(),#{warehouseCode})
</insert>
<select id="selectOperLogList" resultMap="OperLogResult">
<include refid="selectOperLogVo"/>
<where>
<if test="title != null and title != ''">
AND title like concat('%', #{title}, '%')
</if>
<if test="operating != null and operating != ''">
AND operating like concat('%', #{operating}, '%')
</if>
<if test="action != null and action != ''">
AND action = #{action}
</if>
<if test="operName != null and operName != ''">
AND operName like concat('%', #{operName}, '%')
</if>
<if test="warehouseCode != null and warehouseCode != ''">
AND warehouseCode =#{warehouseCode}
</if>
<if test="params != null and params.beginTime != null and params.beginTime !='' "><!-- 开始时间检索 -->
and date_format(operTime,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params != null and params.endTime != null and params.endTime !='' "><!-- 结束时间检索 -->
and date_format(operTime,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
</if>
</where>
</select>
<delete id="deleteOperLogByIds">
delete from sys_oper_log where id in
<foreach collection="array" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectOperLogById" resultMap="OperLogResult">
<include refid="selectOperLogVo"/>
where id = #{id}
</select>
<update id="truncateTable">
DELETE
FROM sys_oper_log
WHERE operTime < DATE_SUB(CURDATE(), INTERVAL 15 DAY)
</update>
</mapper>