Authored by skinny.wu

edit 修改查询主机号下的主机列表bug

package com.monitor.cmdb.ctrl;
import com.fasterxml.jackson.databind.deser.Deserializers;
import com.model.HostGroup;
import com.model.HostInfo;
import com.model.MObjectInfo;
... ... @@ -47,10 +48,21 @@ public class MObjectInfoCtrl {
ITypeInfoService typeInfoService;
@RequestMapping(value = "/queryHost", method = RequestMethod.POST)
public BaseResponse queryMObject(@RequestBody MObjectHostInfoReq request) {
public BaseResponse queryMObjectHost(@RequestBody MObjectHostInfoReq request) {
DEBUG.debug("Query mobject host info by request: {}", request.getSelectIp());
DEBUG.debug("Query mobject host info by request: {}", request);
BaseResponse response = null;
if (0 == request.getIsGroup()) {
response = queryMHostInfoByIp(request);
} else {
response = queryMHostInfoByGroup(request);
}
return response;
}
private BaseResponse queryMHostInfoByIp(MObjectHostInfoReq request) {
BaseResponse response = new BaseResponse();
MObjectHostInfoModel model = new MObjectHostInfoModel();
... ... @@ -72,10 +84,11 @@ public class MObjectInfoCtrl {
selectIp = info.getHostIp();
selectGroup = info.getGroupName();
selectGroupId = info.getGroupId();
selectGroup = groupService.getHostGroupById(selectGroupId).getData().getGroupName();
} else {
if (sourceGroupList.size() > 0) {
selectGroup = sourceGroupList.get(0).getGroupName();
... ... @@ -111,6 +124,50 @@ public class MObjectInfoCtrl {
}
private BaseResponse queryMHostInfoByGroup(MObjectHostInfoReq request) {
BaseResponse response = new BaseResponse();
MObjectHostInfoModel model = new MObjectHostInfoModel();
List<String> groupList = new ArrayList<>();
List<String> ipList = new ArrayList<>();
String selectIp = "";
String selectGroup = "";
int selectGroupId = 0;
List<HostGroup> sourceGroupList = groupService.getListGroups();
for (HostGroup group : sourceGroupList) {
if (StringUtils.equals(group.getGroupName(), request.getSelectGroup())) {
selectGroupId = group.getId();
selectGroup = group.getGroupName();
}
}
for (HostGroup group : sourceGroupList) {
groupList.add(group.getGroupName());
}
if (StringUtils.isNotBlank(selectGroup)) {
for (HostInfo info : hostInfoService.getHostInfosByGroupId(selectGroupId)) {
ipList.add(info.getHostIp());
}
}
selectIp = ipList.get(0);
model.setSelectIp(selectIp);
model.setSelectGroup(selectGroup);
model.setIpList(ipList);
model.setGroupList(groupList);
response.setData(model);
return response;
}
@RequestMapping(value = "/query", method = RequestMethod.POST)
public BaseResponse queryMObject(@RequestBody MObjectInfoReq request) {
... ...
... ... @@ -8,4 +8,8 @@ import lombok.Data;
@Data
public class MObjectHostInfoReq {
String selectIp;
String selectGroup;
int isGroup = 0;
}
... ...
#---------jdbc config----------
local.jdbc.url=jdbc:mysql://localhost:3306/ops?characterEncoding=utf-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull
local.jdbc.url=jdbc:mysql://172.16.6.234:3306/yh_ops?characterEncoding=utf-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull
local.jdbc.user=root
local.jdbc.password=root
local.jdbc.password=123456
#---------jdbc config----------
\ No newline at end of file
... ...