InstanceInfoMapper.xml
1.74 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
<?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.InstanceInfoMapper" >
<resultMap id="BaseResultMap" type="com.monitor.model.domain.InstanceInfo" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="code" property="code" jdbcType="VARCHAR" />
<result column="ip" property="ip" jdbcType="VARCHAR" />
<result column="tag" property="tag" jdbcType="VARCHAR" />
<result column="cloudtype" property="cloudType" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, code, ip, tag, cloudtype, DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') AS createTime
</sql>
<insert id="insert" parameterType="com.monitor.model.domain.InstanceInfo" useGeneratedKeys="true" keyProperty="id">
insert into
instance_info
(
code, ip, tag, cloudtype, create_time
)
values
(
#{code,jdbcType=VARCHAR}, #{ip,jdbcType=VARCHAR}, #{tag,jdbcType=VARCHAR},
#{cloudType,jdbcType=INTEGER}, now()
)
</insert>
<select id="selectById" resultMap="BaseResultMap">
select
t.id as id, t.code as code, t.ip as ip, t.tag as tag, t.cloudtype as cloudtype,
DATE_FORMAT(t.create_time,'%Y-%m-%d %H:%i:%S') AS createTime
from
instance_info t, elb_link_instance t1
where
t1.elb_id = #{id,jdbcType=INTEGER} and t1.instance_id=t.id
</select>
<select id="selectByIp" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from
instance_info
where
ip = #{ip,jdbcType=VARCHAR}
</select>
</mapper>