AlarmGroupMapper.xml
3.34 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
111
112
113
114
115
116
117
118
119
<?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.AlarmGroupMapper" >
<resultMap id="BaseResultMap" type="com.model.AlarmGroup" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="group_name" property="groupName" jdbcType="VARCHAR" />
<result column="users_name" property="usersName" jdbcType="VARCHAR" />
<result column="remark" property="remark" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="All_Column_List" >
id, group_name, users_name, remark, create_time, update_time
</sql>
<sql id="Base_Column_List" >
group_name, users_name, remark, create_time, update_time
</sql>
<insert id="insert" parameterType="com.model.AlarmGroup" >
insert into
alarm_group
(<include refid="Base_Column_List" />)
values
(#{groupName,jdbcType=VARCHAR},#{usersName,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},now(),now())
</insert>
<update id="update" parameterType="com.model.AlarmGroup" >
update
alarm_group
set
group_name = #{groupName,jdbcType=VARCHAR},
users_name = #{usersName,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR},
update_time = now()
where
id = #{id,jdbcType=INTEGER}
</update>
<delete id="deleteById" parameterType="java.lang.Integer" >
delete from
alarm_group
where
id = #{id,jdbcType=INTEGER}
</delete>
<select id="queryAll" resultMap="BaseResultMap">
select
id,group_name
from
alarm_group
order by
id desc
</select>
<select id="queryByGroupName" resultMap="BaseResultMap">
select
<include refid="All_Column_List" />
from
alarm_group
where
id != #{id}
AND
group_name = #{groupName}
</select>
<select id="queryByInfo" resultMap="BaseResultMap">
select
<include refid="All_Column_List" />
from
alarm_group
where
1=1
<if test="groupName != null and groupName != '' " >
AND group_name like CONCAT('%',#{groupName,jdbcType=VARCHAR},'%' )
</if>
<if test="usersName != null and usersName != '' " >
AND users_name like CONCAT('%',#{usersName,jdbcType=VARCHAR},'%' )
</if>
order by
id desc
limit
#{startIndex},#{pageSize}
</select>
<select id="queryById" resultMap="BaseResultMap">
select
<include refid="All_Column_List" />
from
alarm_group
where
id = #{id}
</select>
<select id="queryByContantsName" resultMap="BaseResultMap">
select
<include refid="All_Column_List" />
from
alarm_group
where
group_name = #{groupName}
</select>
<select id="queryCount" resultType="java.lang.Integer">
select
count(1)
from
alarm_group
where
1=1
<if test="groupName != null and groupName != '' " >
AND group_name like CONCAT('%',#{groupName,jdbcType=VARCHAR},'%' )
</if>
<if test="usersName != null and usersName != '' " >
AND users_name like CONCAT('%',#{usersName,jdbcType=VARCHAR},'%' )
</if>
</select>
</mapper>