Authored by qinchao

cmdb添加依赖服务

package com.monitor.cmdb.ctrl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.fasterxml.jackson.databind.deser.Deserializers;
import com.model.HostGroup;
import com.model.HostInfo;
... ... @@ -18,6 +19,7 @@ import com.monitor.model.request.HostInfoReq;
import com.monitor.model.request.MObjectHostInfoReq;
import com.monitor.model.request.MObjectInfoReq;
import com.monitor.model.response.BaseResponse;
import com.monitor.model.response.DependencyRep;
import com.monitor.mysql.mapper.HostInfoMapper;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
... ... @@ -575,9 +577,27 @@ public class MObjectInfoCtrl {
*/
@RequestMapping(value = "/queryDependency")
public BaseResponse queryDependency(@RequestBody DependencyRequest request) {
BaseResponse response = new BaseResponse();
DependencyRep rep=mobjectService.queryDependency(request.getSelectGroup());
List<Map<String,String>> selectGroupsMapList=new ArrayList<>();
for(String str:rep.getSelectGroups()){
Map<String,String> tmp=new HashMap<>();
tmp.put("id",str);
tmp.put("text",str);
selectGroupsMapList.add(tmp);
}
rep.setSelectGroupsJsonArray(JSONArray.parseArray(JSON.toJSONString(selectGroupsMapList)));
List<Map<String,String>> selectDependenciesMapList=new ArrayList<>();
for(String str:rep.getSelectDependencies()){
Map<String,String> tmp=new HashMap<>();
tmp.put("id",str);
tmp.put("text",str);
selectDependenciesMapList.add(tmp);
}
rep.setSelectDependenciesJsonArray(JSONArray.parseArray(JSON.toJSONString(selectDependenciesMapList)));
response.setData(mobjectService.queryDependency(request.getSelectGroup()));
BaseResponse response = new BaseResponse();
response.setData(rep);
return response;
}
... ...
package com.monitor.model.response;
import com.alibaba.fastjson.JSONArray;
import lombok.Data;
import java.util.List;
... ... @@ -12,4 +13,7 @@ public class DependencyRep {
List<String> selectGroups;
List<String> selectDependencies;
JSONArray selectGroupsJsonArray;
JSONArray selectDependenciesJsonArray;
}
... ...