Authored by mlge

no message

package com.monitor.cmdb.ctrl;
import com.alibaba.fastjson.JSON;
import com.model.HostInfo;
import com.monitor.cmdb.service.IHostInfoService;
import com.monitor.compare.model.HostIpsRequest;
import com.monitor.model.request.HostInfoReq;
import com.monitor.model.response.PageResponse;
import com.monitor.model.response.BaseResponse;
... ... @@ -15,6 +17,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Set;
/**
* Created by yoho on 2016/6/14.
... ... @@ -82,5 +87,16 @@ public class HostInfoCtrl {
return resp;
}
@RequestMapping("/getHostInfoByIps")
@ResponseBody
public BaseResponse<List<HostInfo>> getHostInfoByIps(String ips) throws Exception {
List<String> hostIps = JSON.parseArray(ips,String.class);
log.info("getHostInfoByIps with param is {}", ips);
List<HostInfo> hostInfos = hostInfoService.getHostInfoByIps(hostIps);
BaseResponse<List<HostInfo>> response = new BaseResponse<List<HostInfo>>(hostInfos);
return response;
}
}
... ...
... ... @@ -6,6 +6,7 @@ import com.monitor.model.response.BaseResponse;
import com.monitor.model.response.PageResponse;
import java.util.List;
import java.util.Set;
/**
* Created by yoho on 2016/6/14.
... ... @@ -23,4 +24,5 @@ public interface IHostInfoService {
List<HostInfo> getHostInfosByTag(String tag);
List<HostInfo> getHostInfoByIps(List<String> ids);
}
... ...
... ... @@ -118,4 +118,9 @@ public class HostInfoServiceImpl implements IHostInfoService {
return hostInfoMapper.selectHostInfosByTag(tag);
}
@Override
public List<HostInfo> getHostInfoByIps(List<String> ips){
return hostInfoMapper.selectHostInfosByIps(ips);
}
}
... ...
... ... @@ -29,4 +29,5 @@ public interface HostInfoMapper {
HostInfo selectByHostIp(@Param("hostIp") String hostIp);
List<HostInfo> selectHostInfosByIps(@Param("hostIps") List<String> ips);
}
\ No newline at end of file
... ...
... ... @@ -189,4 +189,14 @@
where instr(tags, LOWER(#{tag})) &gt; 0
AND cloud_type = #{cloudType}
</select>
<select id="selectHostInfosByIps" resultMap="BaseResultMap">
select host_ip, tags
from host_info
where host_ip in
<foreach item="hostIp" index="index" collection="hostIps" open="("
separator="," close=")">
#{hostIp}
</foreach>
</select>
</mapper>
\ No newline at end of file
... ...