Authored by mlge

缩减主机--则删除Host_info

@@ -123,14 +123,14 @@ public class HostInfoCtrl { @@ -123,14 +123,14 @@ public class HostInfoCtrl {
123 123
124 /** 124 /**
125 * 更新主机tag信息为空 125 * 更新主机tag信息为空
126 - * @param hostInfos 126 + * @param removeIps
127 * @return 127 * @return
128 */ 128 */
129 - @RequestMapping("/updateHostInfoByIps") 129 + @RequestMapping("/removeHostInfoByIps")
130 @ResponseBody 130 @ResponseBody
131 - public BaseResponse updateHostInfoByIps(@RequestBody List<HostInfo> hostInfos){ 131 + public BaseResponse removeHostInfoByIps(@RequestBody List<String> removeIps){
132 // List<HostInfo> hostInfoList = JSON.parseArray(hosts,HostInfo.class); 132 // List<HostInfo> hostInfoList = JSON.parseArray(hosts,HostInfo.class);
133 - return hostInfoService.updateTagByIps(hostInfos); 133 + return hostInfoService.removeByIps(removeIps);
134 } 134 }
135 135
136 @RequestMapping("/saveHostListInfos") 136 @RequestMapping("/saveHostListInfos")
@@ -28,4 +28,6 @@ public interface IHostInfoService { @@ -28,4 +28,6 @@ public interface IHostInfoService {
28 BaseResponse updateTagByIps(List<HostInfo> hostInfoList); 28 BaseResponse updateTagByIps(List<HostInfo> hostInfoList);
29 29
30 BaseResponse saveHostListInfo(List<HostInfo> hostInfos); 30 BaseResponse saveHostListInfo(List<HostInfo> hostInfos);
  31 +
  32 + BaseResponse removeByIps(List<String> removeIps);
31 } 33 }
@@ -173,4 +173,26 @@ public class HostInfoServiceImpl implements IHostInfoService { @@ -173,4 +173,26 @@ public class HostInfoServiceImpl implements IHostInfoService {
173 return new BaseResponse(); 173 return new BaseResponse();
174 } 174 }
175 175
  176 + @Override
  177 + public BaseResponse removeByIps(List<String> removeIps) {
  178 + BaseResponse resp = new BaseResponse();
  179 + String message = "";
  180 + if(removeIps != null && removeIps.size() > 0){
  181 + for(String ip : removeIps){
  182 + try{
  183 + hostInfoMapper.deleteByIp(ip);
  184 + }catch(Exception e){
  185 + logger.error("removeByIps error: ",e);
  186 + message = message + "removeByIps error --ip:" +ip + ";";
  187 + }
  188 + }
  189 + }
  190 + if(!"".equals(message)){
  191 + resp.setCode(201);
  192 + resp.setMessage(message);
  193 + }
  194 + return resp;
  195 +
  196 + }
  197 +
176 } 198 }
@@ -34,4 +34,6 @@ public interface HostInfoMapper { @@ -34,4 +34,6 @@ public interface HostInfoMapper {
34 int updateTagByIps(HostInfo record); 34 int updateTagByIps(HostInfo record);
35 35
36 int updateHostInfoByIp(HostInfo record); 36 int updateHostInfoByIp(HostInfo record);
  37 +
  38 + int deleteByIp(String ip);
37 } 39 }
@@ -219,4 +219,10 @@ @@ -219,4 +219,10 @@
219 update_time = now() 219 update_time = now()
220 where host_ip = #{hostIp,jdbcType=INTEGER} 220 where host_ip = #{hostIp,jdbcType=INTEGER}
221 </update> 221 </update>
  222 +
  223 +
  224 + <delete id="deleteByIp" parameterType="java.lang.String" >
  225 + delete from host_info
  226 + where host_ip = #{ip,jdbcType=VARCHAR}
  227 + </delete>
222 </mapper> 228 </mapper>