Authored by FengRuwei

获取所有java app服务

... ... @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.deser.Deserializers;
import com.model.HostGroup;
import com.model.HostInfo;
import com.model.MObjectInfo;
import com.model.TypeInfo;
import com.monitor.cmdb.service.IHostGroupService;
import com.monitor.cmdb.service.IHostInfoService;
import com.monitor.cmdb.service.IMObjectInfoService;
... ... @@ -419,4 +420,53 @@ public class MObjectInfoCtrl {
return true;
}
/**
* 获取所有java app服务
* @return
*/
@RequestMapping(value = "/javaapi")
@ResponseBody
public BaseResponse queryJavaApiMobject() {
List<TypeInfo> allTypeInfo = null;
BaseResponse response = new BaseResponse();
try {
TypeInfo typeInfo = typeInfoService.queryTypeInfoByName(TypeInfoCtrl.TYPE_JAVA_APP);
if (typeInfo == null) {
return response;
}
allTypeInfo = typeInfoService.queryChildTypesInfo(typeInfo.getTypeId());
if (null == allTypeInfo) {
return response;
}
String ids="";
for(TypeInfo type:allTypeInfo){
if(ids.equals(""))
ids+=type.getTypeId();
else
ids+=","+type.getTypeId();
}
MObjectInfoReq req=new MObjectInfoReq();
req.setIsType(1);
req.setTypeIds(ids);
return queryMObjectByType(req);
} catch (Exception e) {
DEBUG.error("Failed to query all typeInfo, error: {}", e);
response.setCode(400);
response.setMessage(e.getMessage());
}
return response;
}
}
... ...
... ... @@ -22,7 +22,7 @@ import java.util.List;
public class TypeInfoCtrl {
public static final Logger DEBUG = LoggerFactory.getLogger(TypeInfoCtrl.class);
public static final String TYPE_JAVA_APP="java_app";
public static final String TYPE_JAVA_APP = "java_app";
@Autowired
ITypeInfoService typeInfoService;
... ... @@ -255,9 +255,7 @@ public class TypeInfoCtrl {
DEBUG.debug("Query all java api info...");
List<TypeInfo> allTypeInfo = null;
BaseResponse response = new BaseResponse();
try {
TypeInfo typeInfo = typeInfoService.queryTypeInfoByName(TYPE_JAVA_APP);
... ... @@ -273,7 +271,6 @@ public class TypeInfoCtrl {
response.setCode(400);
response.setMessage(e.getMessage());
}
return response;
}
... ...