SqlOperateLogsMapper.xml
3.29 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.monitor.mysql.mapper.SqlOperateLogsMapper" >
<resultMap id="BaseResultMap" type="com.model.SqlOperateLogs" >
<id column="id" property="id" jdbcType="INTEGER" />
<id column="user_id" property="userId" jdbcType="INTEGER" />
<result column="user_name" property="userName" jdbcType="VARCHAR" />
<result column="datasource_info" property="dataSourceInfo" jdbcType="VARCHAR" />
<result column="db_info" property="dbInfo" jdbcType="VARCHAR" />
<result column="datasource_user" property="dataSourceUser" jdbcType="VARCHAR" />
<result column="datasource_pwd" property="dataSourcePwd" jdbcType="VARCHAR" />
<result column="query_content" property="queryContent" jdbcType="VARCHAR" />
<result column="query_result" property="queryResult" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, user_id,user_name,datasource_info,datasource_user, datasource_pwd, query_content,query_result ,create_time
</sql>
<insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="com.model.SqlOperateLogs" >
insert into sql_operate_logs
(
user_id,user_name,datasource_info,db_info,datasource_user, datasource_pwd, query_content,query_result ,create_time
)
values
(#{userId,jdbcType=INTEGER},
#{userName,jdbcType=VARCHAR},
#{dataSourceInfo,jdbcType=VARCHAR},
#{dbInfo,jdbcType=VARCHAR},
#{dataSourceUser,jdbcType=VARCHAR},
#{dataSourcePwd,jdbcType=VARCHAR},
#{queryContent,jdbcType=VARCHAR},
#{queryResult,jdbcType=VARCHAR},
now())
</insert>
<select id="selectCount" resultType="java.lang.Integer">
select count(*) from sql_operate_logs
where 1=1
<if test="params.userName != null && params.userName != ''">
and user_name like CONCAT('%',#{params.userName,jdbcType=VARCHAR},'%')
</if>
<if test="params.beginTime !=null && params.beginTime !=''">
and create_time >= CONCAT(#{params.beginTime,jdbcType=TIMESTAMP},' 00:00:00')
</if>
<if test="params.endTime !=null && params.endTime !=''">
and create_time <= CONCAT(#{params.endTime,jdbcType=TIMESTAMP},' 23:59:59')
</if>
order by create_time desc
</select>
<select id="selectPageByParams" resultMap="BaseResultMap">
select * from sql_operate_logs
where 1=1
<if test="params.userName != null && params.userName != ''">
and user_name like CONCAT('%',#{params.userName,jdbcType=VARCHAR},'%')
</if>
<if test="params.beginTime !=null && params.beginTime !=''">
and create_time >= CONCAT(#{params.beginTime,jdbcType=TIMESTAMP},' 00:00:00')
</if>
<if test="params.endTime !=null && params.endTime !=''">
and create_time <= CONCAT(#{params.endTime,jdbcType=TIMESTAMP},' 23:59:59')
</if>
order by create_time desc
limit #{startIndex},#{pageSize}
</select>
</mapper>