Authored by mlge

缩减主机--则删除Host_info

... ... @@ -123,14 +123,14 @@ public class HostInfoCtrl {
/**
* 更新主机tag信息为空
* @param hostInfos
* @param removeIps
* @return
*/
@RequestMapping("/updateHostInfoByIps")
@RequestMapping("/removeHostInfoByIps")
@ResponseBody
public BaseResponse updateHostInfoByIps(@RequestBody List<HostInfo> hostInfos){
public BaseResponse removeHostInfoByIps(@RequestBody List<String> removeIps){
// List<HostInfo> hostInfoList = JSON.parseArray(hosts,HostInfo.class);
return hostInfoService.updateTagByIps(hostInfos);
return hostInfoService.removeByIps(removeIps);
}
@RequestMapping("/saveHostListInfos")
... ...
... ... @@ -28,4 +28,6 @@ public interface IHostInfoService {
BaseResponse updateTagByIps(List<HostInfo> hostInfoList);
BaseResponse saveHostListInfo(List<HostInfo> hostInfos);
BaseResponse removeByIps(List<String> removeIps);
}
... ...
... ... @@ -173,4 +173,26 @@ public class HostInfoServiceImpl implements IHostInfoService {
return new BaseResponse();
}
@Override
public BaseResponse removeByIps(List<String> removeIps) {
BaseResponse resp = new BaseResponse();
String message = "";
if(removeIps != null && removeIps.size() > 0){
for(String ip : removeIps){
try{
hostInfoMapper.deleteByIp(ip);
}catch(Exception e){
logger.error("removeByIps error: ",e);
message = message + "removeByIps error --ip:" +ip + ";";
}
}
}
if(!"".equals(message)){
resp.setCode(201);
resp.setMessage(message);
}
return resp;
}
}
... ...
... ... @@ -34,4 +34,6 @@ public interface HostInfoMapper {
int updateTagByIps(HostInfo record);
int updateHostInfoByIp(HostInfo record);
int deleteByIp(String ip);
}
\ No newline at end of file
... ...
... ... @@ -219,4 +219,10 @@
update_time = now()
where host_ip = #{hostIp,jdbcType=INTEGER}
</update>
<delete id="deleteByIp" parameterType="java.lang.String" >
delete from host_info
where host_ip = #{ip,jdbcType=VARCHAR}
</delete>
</mapper>
\ No newline at end of file
... ...