Authored by qinchao

可用区hostinfo

@@ -33,8 +33,6 @@ public interface IHostInfoService { @@ -33,8 +33,6 @@ public interface IHostInfoService {
33 33
34 List<HostInfo> getHostInfoByIps(List<String> ips); 34 List<HostInfo> getHostInfoByIps(List<String> ips);
35 35
36 - BaseResponse updateTagByIps(List<HostInfo> hostInfoList);  
37 -  
38 BaseResponse saveHostListInfo(List<HostInfo> hostInfos); 36 BaseResponse saveHostListInfo(List<HostInfo> hostInfos);
39 37
40 BaseResponse removeByIps(List<String> removeIps); 38 BaseResponse removeByIps(List<String> removeIps);
@@ -187,13 +187,6 @@ public class HostInfoServiceImpl implements IHostInfoService { @@ -187,13 +187,6 @@ public class HostInfoServiceImpl implements IHostInfoService {
187 req.setTags(newTags); 187 req.setTags(newTags);
188 } 188 }
189 189
190 - //暂时无法确定腾讯云的可用区  
191 - if(1==req.getCloudType()){  
192 - req.setCloudDetailType(1);  
193 - }else if(2==req.getCloudType()){  
194 - req.setCloudDetailType(2);  
195 - }  
196 -  
197 190
198 if(req.getId()>0){ 191 if(req.getId()>0){
199 result=hostInfoMapper.updateByPrimaryKey(req); 192 result=hostInfoMapper.updateByPrimaryKey(req);
@@ -215,13 +208,6 @@ public class HostInfoServiceImpl implements IHostInfoService { @@ -215,13 +208,6 @@ public class HostInfoServiceImpl implements IHostInfoService {
215 for(HostInfo host : hostInfos){ 208 for(HostInfo host : hostInfos){
216 HostInfo h = hostInfoMapper.selectByHostIp(host.getHostIp()); 209 HostInfo h = hostInfoMapper.selectByHostIp(host.getHostIp());
217 210
218 - //暂时无法确定腾讯云的可用区  
219 - if(1==h.getCloudType()){  
220 - h.setCloudDetailType(1);  
221 - }else if(2==h.getCloudType()){  
222 - h.setCloudDetailType(2);  
223 - }  
224 -  
225 try{ 211 try{
226 if(h != null){//存在则更新 212 if(h != null){//存在则更新
227 hostInfoMapper.updateHostInfoByIp(host); 213 hostInfoMapper.updateHostInfoByIp(host);
@@ -306,33 +292,6 @@ public class HostInfoServiceImpl implements IHostInfoService { @@ -306,33 +292,6 @@ public class HostInfoServiceImpl implements IHostInfoService {
306 return hostInfoMapper.selectHostInfosByIps(ips); 292 return hostInfoMapper.selectHostInfosByIps(ips);
307 } 293 }
308 294
309 - /**  
310 - * 将tag更新为空  
311 - * @param  
312 - */  
313 - @Override  
314 - public BaseResponse updateTagByIps(List<HostInfo> hostInfoList){  
315 - BaseResponse resp = new BaseResponse();  
316 - String message = "";  
317 - if(hostInfoList != null && hostInfoList.size() > 0){  
318 - for(HostInfo host : hostInfoList){  
319 - try{  
320 - hostInfoMapper.updateHostInfoByIp(host);  
321 - }catch(Exception e){  
322 - logger.error("updateTagByIps error: ",e);  
323 - message = message + "updateTagByIps error --ip:" + host.getHostIp() + ";";  
324 - }  
325 - }  
326 - }  
327 - if(!"".equals(message)){  
328 - resp.setCode(201);  
329 - resp.setMessage(message);  
330 - }  
331 - return resp;  
332 -  
333 - }  
334 -  
335 -  
336 295
337 @Override 296 @Override
338 public BaseResponse removeByIps(List<String> removeIps) { 297 public BaseResponse removeByIps(List<String> removeIps) {
@@ -21,6 +21,8 @@ public class HostInfoReq extends PageRequest { @@ -21,6 +21,8 @@ public class HostInfoReq extends PageRequest {
21 21
22 private int cloudType; 22 private int cloudType;
23 23
  24 + private int cloudDetailType;
  25 +
24 private int groupId; 26 private int groupId;
25 27
26 private String tags; 28 private String tags;
@@ -11,8 +11,6 @@ public interface HostInfoMapper { @@ -11,8 +11,6 @@ public interface HostInfoMapper {
11 11
12 int insert(HostInfo record); 12 int insert(HostInfo record);
13 13
14 - int insertSelective(HostInfo record);  
15 -  
16 HostInfo selectByPrimaryKey(Integer id); 14 HostInfo selectByPrimaryKey(Integer id);
17 15
18 int updateByPrimaryKeySelective(HostInfo record); 16 int updateByPrimaryKeySelective(HostInfo record);
@@ -35,8 +33,6 @@ public interface HostInfoMapper { @@ -35,8 +33,6 @@ public interface HostInfoMapper {
35 33
36 List<HostInfo> selectHostInfosByIps(@Param("hostIps") List<String> ips); 34 List<HostInfo> selectHostInfosByIps(@Param("hostIps") List<String> ips);
37 35
38 - int updateTagByIps(HostInfo record);  
39 -  
40 int updateHostInfoByIp(HostInfo record); 36 int updateHostInfoByIp(HostInfo record);
41 37
42 int deleteByIp(String ip); 38 int deleteByIp(String ip);
@@ -6,14 +6,15 @@ @@ -6,14 +6,15 @@
6 <result column="alias" property="alias" jdbcType="VARCHAR" /> 6 <result column="alias" property="alias" jdbcType="VARCHAR" />
7 <result column="host_ip" property="hostIp" jdbcType="VARCHAR" /> 7 <result column="host_ip" property="hostIp" jdbcType="VARCHAR" />
8 <result column="group_id" property="groupId" jdbcType="INTEGER" /> 8 <result column="group_id" property="groupId" jdbcType="INTEGER" />
9 - <result column="cloud_type" property="cloudType" jdbcType="BIT" /> 9 + <result column="cloud_type" property="cloudType" jdbcType="INTEGER" />
  10 + <result column="cloud_detail_type" property="cloudDetailType" jdbcType="INTEGER" />
10 <result column="tags" property="tags" jdbcType="VARCHAR" /> 11 <result column="tags" property="tags" jdbcType="VARCHAR" />
11 <result column="create_time" property="createTime" jdbcType="TIMESTAMP" /> 12 <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
12 <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" /> 13 <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
13 <result column="group_name" property="groupName" jdbcType="VARCHAR" /> 14 <result column="group_name" property="groupName" jdbcType="VARCHAR" />
14 </resultMap> 15 </resultMap>
15 <sql id="Base_Column_List" > 16 <sql id="Base_Column_List" >
16 - id, alias, host_ip, group_id, cloud_type, tags, create_time, update_time 17 + id, alias, host_ip, group_id, cloud_type, tags, create_time, update_time,cloud_detail_type
17 </sql> 18 </sql>
18 <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > 19 <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
19 select 20 select
@@ -28,66 +29,12 @@ @@ -28,66 +29,12 @@
28 <insert id="insert" parameterType="com.model.HostInfo" > 29 <insert id="insert" parameterType="com.model.HostInfo" >
29 insert into host_info (id, alias, host_ip, 30 insert into host_info (id, alias, host_ip,
30 group_id, cloud_type, tags, 31 group_id, cloud_type, tags,
31 - create_time, update_time) 32 + create_time, update_time,cloud_detail_type)
32 values (#{id,jdbcType=INTEGER}, #{alias,jdbcType=VARCHAR}, #{hostIp,jdbcType=VARCHAR}, 33 values (#{id,jdbcType=INTEGER}, #{alias,jdbcType=VARCHAR}, #{hostIp,jdbcType=VARCHAR},
33 - #{groupId,jdbcType=INTEGER}, #{cloudType,jdbcType=BIT}, #{tags,jdbcType=VARCHAR},  
34 - now(), now())  
35 - </insert>  
36 - <insert id="insertSelective" parameterType="com.model.HostInfo" >  
37 - insert into host_info  
38 - <trim prefix="(" suffix=")" suffixOverrides="," >  
39 - <if test="id != null" >  
40 - id,  
41 - </if>  
42 - <if test="alias != null" >  
43 - alias,  
44 - </if>  
45 - <if test="hostIp != null" >  
46 - host_ip,  
47 - </if>  
48 - <if test="groupId != null" >  
49 - group_id,  
50 - </if>  
51 - <if test="cloudType != null" >  
52 - cloud_type,  
53 - </if>  
54 - <if test="tags != null" >  
55 - tags,  
56 - </if>  
57 - <if test="createTime != null" >  
58 - create_time,  
59 - </if>  
60 - <if test="updateTime != null" >  
61 - update_time,  
62 - </if>  
63 - </trim>  
64 - <trim prefix="values (" suffix=")" suffixOverrides="," >  
65 - <if test="id != null" >  
66 - #{id,jdbcType=INTEGER},  
67 - </if>  
68 - <if test="alias != null" >  
69 - #{alias,jdbcType=VARCHAR},  
70 - </if>  
71 - <if test="hostIp != null" >  
72 - #{hostIp,jdbcType=VARCHAR},  
73 - </if>  
74 - <if test="groupId != null" >  
75 - #{groupId,jdbcType=INTEGER},  
76 - </if>  
77 - <if test="cloudType != null" >  
78 - #{cloudType,jdbcType=BIT},  
79 - </if>  
80 - <if test="tags != null" >  
81 - #{tags,jdbcType=VARCHAR},  
82 - </if>  
83 - <if test="createTime != null" >  
84 - #{createTime,jdbcType=TIMESTAMP},  
85 - </if>  
86 - <if test="updateTime != null" >  
87 - #{updateTime,jdbcType=TIMESTAMP},  
88 - </if>  
89 - </trim> 34 + #{groupId,jdbcType=INTEGER}, #{cloudType,jdbcType=INTEGER}, #{tags,jdbcType=VARCHAR},
  35 + now(), now(), #{cloudDetailType,jdbcType=INTEGER})
90 </insert> 36 </insert>
  37 +
91 <update id="updateByPrimaryKeySelective" parameterType="com.model.HostInfo" > 38 <update id="updateByPrimaryKeySelective" parameterType="com.model.HostInfo" >
92 update host_info 39 update host_info
93 <set > 40 <set >
@@ -101,7 +48,10 @@ @@ -101,7 +48,10 @@
101 group_id = #{groupId,jdbcType=INTEGER}, 48 group_id = #{groupId,jdbcType=INTEGER},
102 </if> 49 </if>
103 <if test="cloudType != null &amp;&amp; cloudType != 0" > 50 <if test="cloudType != null &amp;&amp; cloudType != 0" >
104 - cloud_type = #{cloudType,jdbcType=BIT}, 51 + cloud_type = #{cloudType,jdbcType=INTEGER},
  52 + </if>
  53 + <if test="cloudDetailType != null &amp;&amp; cloudDetailType != 0" >
  54 + cloud_detail_type = #{cloudDetailType,jdbcType=INTEGER},
105 </if> 55 </if>
106 <if test="tags != null" > 56 <if test="tags != null" >
107 tags = #{tags,jdbcType=VARCHAR}, 57 tags = #{tags,jdbcType=VARCHAR},
@@ -120,7 +70,8 @@ @@ -120,7 +70,8 @@
120 set alias = #{alias,jdbcType=VARCHAR}, 70 set alias = #{alias,jdbcType=VARCHAR},
121 host_ip = #{hostIp,jdbcType=VARCHAR}, 71 host_ip = #{hostIp,jdbcType=VARCHAR},
122 group_id = #{groupId,jdbcType=INTEGER}, 72 group_id = #{groupId,jdbcType=INTEGER},
123 - cloud_type = #{cloudType,jdbcType=BIT}, 73 + cloud_type = #{cloudType,jdbcType=INTEGER},
  74 + cloud_detail_type = #{cloudDetailType,jdbcType=INTEGER},
124 tags = #{tags,jdbcType=VARCHAR}, 75 tags = #{tags,jdbcType=VARCHAR},
125 update_time = now() 76 update_time = now()
126 where id = #{id,jdbcType=INTEGER} 77 where id = #{id,jdbcType=INTEGER}
@@ -138,6 +89,9 @@ @@ -138,6 +89,9 @@
138 <if test="params.cloudType != null &amp;&amp; params.cloudType != 0" > 89 <if test="params.cloudType != null &amp;&amp; params.cloudType != 0" >
139 and a.cloud_type = #{params.cloudType} 90 and a.cloud_type = #{params.cloudType}
140 </if> 91 </if>
  92 + <if test="params.cloudDetailType != null &amp;&amp; params.cloudDetailType != 0" >
  93 + and a.cloud_detail_type = #{params.cloudDetailType}
  94 + </if>
141 <if test="params.hostIp != null &amp;&amp; params.hostIp != ''" > 95 <if test="params.hostIp != null &amp;&amp; params.hostIp != ''" >
142 and a.host_ip like concat(#{params.hostIp},'%') 96 and a.host_ip like concat(#{params.hostIp},'%')
143 </if> 97 </if>
@@ -169,7 +123,7 @@ @@ -169,7 +123,7 @@
169 123
170 <select id="selectHostInfosByCodition" resultMap="BaseResultMap"> 124 <select id="selectHostInfosByCodition" resultMap="BaseResultMap">
171 select 125 select
172 - a.id, a.alias, a.host_ip, a.group_id, a.cloud_type, a.tags, a.create_time, a.update_time,b.group_name 126 + a.id, a.alias, a.host_ip, a.group_id, a.cloud_type,a.cloud_detail_type, a.tags, a.create_time, a.update_time,b.group_name
173 from host_info a left join host_group b on a.group_id=b.id 127 from host_info a left join host_group b on a.group_id=b.id
174 where 128 where
175 1=1 129 1=1
@@ -179,6 +133,9 @@ @@ -179,6 +133,9 @@
179 <if test="params.cloudType != null &amp;&amp; params.cloudType != 0" > 133 <if test="params.cloudType != null &amp;&amp; params.cloudType != 0" >
180 and a.cloud_type = #{params.cloudType} 134 and a.cloud_type = #{params.cloudType}
181 </if> 135 </if>
  136 + <if test="params.cloudDetailType != null &amp;&amp; params.cloudDetailType != 0" >
  137 + and a.cloud_detail_type = #{params.cloudDetailType}
  138 + </if>
182 <if test="params.hostIp != null &amp;&amp; params.hostIp != ''" > 139 <if test="params.hostIp != null &amp;&amp; params.hostIp != ''" >
183 and a.host_ip like concat(#{params.hostIp},'%') 140 and a.host_ip like concat(#{params.hostIp},'%')
184 </if> 141 </if>
@@ -277,24 +234,15 @@ @@ -277,24 +234,15 @@
277 </foreach> 234 </foreach>
278 </select> 235 </select>
279 236
280 - <update id="updateTagByIps" >  
281 - update host_info  
282 - set tags = ""  
283 - where host_ip in  
284 - <foreach item="hostIp" index="index" collection="hostIps" open="("  
285 - separator="," close=")">  
286 - #{hostIp}  
287 - </foreach>  
288 - </update>  
289 -  
290 237
291 <update id="updateHostInfoByIp" parameterType="com.model.HostInfo" > 238 <update id="updateHostInfoByIp" parameterType="com.model.HostInfo" >
292 update host_info 239 update host_info
293 set alias = #{alias,jdbcType=VARCHAR}, 240 set alias = #{alias,jdbcType=VARCHAR},
294 - cloud_type = #{cloudType,jdbcType=BIT}, 241 + cloud_type = #{cloudType,jdbcType=INTEGER},
  242 + cloud_detail_type = #{cloudType,jdbcType=INTEGER},
295 tags = #{tags,jdbcType=VARCHAR}, 243 tags = #{tags,jdbcType=VARCHAR},
296 update_time = now() 244 update_time = now()
297 - where host_ip = #{hostIp,jdbcType=INTEGER} 245 + where host_ip = #{hostIp,jdbcType=VARCHAR}
298 </update> 246 </update>
299 247
300 248