MObjectInfoMapper.xml
4.6 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
<?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="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>
</mapper>