MObjectInfoMapper.xml
6.55 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?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.MObjectInfoMapper">
<cache></cache>
<resultMap id="mobjectInfoMapper" type="com.model.MObjectInfo">
<id property="moId" column="id"></id>
<id property="moName" column="alias"></id>
<id property="moHostIp" column="host_ip"></id>
<id property="moTypeId" column="type_id"></id>
<id property="moTags" column="tags"></id>
<id property="moUrl" column="url"></id>
</resultMap>
<resultMap id="dependencyInfoMapper" type="com.model.DependencyInfo">
<id property="typeId" column="typeId"></id>
<id property="dependencyTypeId" column="dTypeId"></id>
</resultMap>
<select id="getAllMosInfo" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper">
SELECT * FROM mobject_info ORDER BY id asc
</select>
<select id="getTypeMosInfo" parameterType="int" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper">
SELECT * FROM mobject_info WHERE type_id = #{moTypeId} order by host_ip DESC
</select>
<!-- <select id="getHostMosInfo" parameterType="int" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper">
SELECT * FROM mobject_info WHERE mo_hostId = #{moHostId}
</select>-->
<insert id="insertMoInfo" useGeneratedKeys="true" keyProperty="id" parameterType="com.model.MObjectInfo">
INSERT INTO mobject_info(alias,host_ip,type_id,tags,url) VALUES (#{moName},#{moHostIp},#{moTypeId},#{moTags},#{moUrl})
</insert>
<delete id="deleteMoInfo" parameterType="int">
DELETE FROM mobject_info WHERE id = #{moId}
</delete>
<delete id="deleteMoInfoList">
DELETE FROM mobject_info WHERE id in
<foreach collection="list" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</delete>
<update id="updateMoInfo" parameterType="com.model.MObjectInfo">
UPDATE mobject_info SET alias=#{moName},host_ip=#{moHostIp},type_id=#{moTypeId},tags=#{moTags},url=#{moUrl} WHERE id = #{moId}
</update>
<select id="selectMObjectsInfoByTypes" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper">
SELECT * FROM mobject_info
where type_id in
<foreach collection="list" open="(" close=")" separator="," item="item">
#{item}
</foreach>
ORDER BY id asc
</select>
<select id="selectMObjectsInfoByTypeId" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper">
SELECT * FROM mobject_info where type_id = #{typeId,jdbcType=INTEGER}
</select>
<select id="getMoInfosByAlias" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper"
parameterType="java.lang.String">
SELECT * FROM mobject_info where instr(alias, LOWER(#{alias})) > 0 ORDER BY id asc
</select>
<select id="selectDistinctHostIPByTypes" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper">
SELECT distinct host_ip FROM mobject_info
where type_id in
<foreach collection="list" open="(" close=")" separator="," item="item">
#{item}
</foreach>
order by host_ip DESC
</select>
<select id="selectJavaDistinctHostIP" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper">
SELECT b.`host_ip`,GROUP_CONCAT(a.`alias`) alias FROM `type_info` a,`mobject_info` b
WHERE a.`id` = b.`type_id` AND a.`alias` IN ('gateway','order','promotion','product','message','sns','users','resources','brower')
AND a.`parent_id` = (SELECT id FROM `type_info` t WHERE t.`alias` = 'java_app') GROUP BY b.`host_ip`
</select>
<select id="selectAllDistinctHostIP" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper">
SELECT distinct host_ip FROM mobject_info
</select>
<select id="selectByFuzzyName" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper">
SELECT * FROM mobject_info where alias like CONCAT(#{name,jdbcType=VARCHAR},'%' ) limit 1
</select>
<select id="queryBindDependencyList" parameterType="java.lang.Integer" resultType="com.model.DependencyInfo" resultMap="dependencyInfoMapper">
select * from type_dependency_info WHERE typeId = #{typeId}
</select>
<delete id="deleteBindDependencyList" parameterType="java.lang.Integer">
DELETE from type_dependency_info WHERE typeId = #{typeId}
</delete>
<insert id="addBindDependencyList" parameterType="java.util.List">
INSERT INTO type_dependency_info (typeId, dTypeId) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.typeId},#{item.dependencyTypeId})
</foreach>
</insert>
<select id="selectAllMobjectIps" resultType="java.lang.String">
select distinct(host_ip) from mobject_info
</select>
<delete id="deleteMobjectByHostIps">
delete from mobject_info where host_ip in (
<foreach collection="deleteHostIpList" item="hostIp" separator="," >
#{hostIp}
</foreach>
)
</delete>
<select id="countByCondition" resultType="java.lang.Integer">
select count(1) from mobject_info where 1=1
<if test="params.typeIdList != null and params.typeIdList.size() > 0" >
AND type_id in (
<foreach collection="params.typeIdList" separator="," item="typeId" >
#{typeId}
</foreach>
)
</if>
<if test="params.hostIpList != null and params.hostIpList.size() > 0">
AND host_ip in (
<foreach collection="params.hostIpList" separator="," item="hostIp">
#{hostIp}
</foreach>
)
</if>
</select>
<select id="selectPageByCondition" resultMap="mobjectInfoMapper">
select * from mobject_info where 1=1
<if test="params.typeIdList != null and params.typeIdList.size() > 0" >
AND type_id in
<foreach collection="params.typeIdList" separator="," item="typeId" open="(" close=")">
#{typeId}
</foreach>
</if>
<if test="params.hostIpList != null and params.hostIpList.size() > 0">
AND host_ip in
<foreach collection="params.hostIpList" separator="," item="hostIp" open="(" close=")">
#{hostIp}
</foreach>
</if>
order by type_id, host_ip
limit #{startIndex},#{pageSize}
</select>
</mapper>