MObjectInfoCtrl.java
4.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package com.ui.ctrl;
import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;
import com.ui.model.req.DependencyRequest;
import com.ui.model.req.MObjectHostInfoReq;
import com.ui.model.req.MObjectInfoReq;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
/**
* Created by yoho on 2016/6/16.
*/
@RestController
@RequestMapping(value = "/mobject")
public class MObjectInfoCtrl {
@Autowired
HttpRestClient httpRestClient;
@RequestMapping("/toMobject")
public ModelAndView toMobject() {
return new ModelAndView("mobject/mobjectInfo");
}
//前台提供currentpage,pagesize,isType,typeIds,hostIps
@RequestMapping(value = "/query")
public BaseResponse queryAllMObjectInfo(MObjectInfoReq request) {
BaseResponse response = httpRestClient.defaultPost("/mobject/query", request, BaseResponse.class);
return response;
}
//前台提供mo_id
@RequestMapping(value = "/delete")
public BaseResponse deleteMObjectInfo(MObjectInfoReq request) {
BaseResponse response = httpRestClient.defaultPost("/mobject/delete", request, BaseResponse.class);
return response;
}
//前台提供 mo_id,mo_name,mo_typeId,mo_hostIP,mo_tags,mo_url
@RequestMapping(value = "/update")
public BaseResponse updateMObjectInfo(MObjectInfoReq request) {
BaseResponse response = httpRestClient.defaultPost("/mobject/update", request, BaseResponse.class);
return response;
}
//前台提供 mo_name,mo_typeId,mo_hostIp,mo_tags,mo_url
@RequestMapping(value = "/add")
public BaseResponse addMObjectInfo(MObjectInfoReq request) {
BaseResponse response = httpRestClient.defaultPost("/mobject/add", request, BaseResponse.class);
return response;
}
@RequestMapping(value = "/asyMobjectHost")
public BaseResponse asyMobjectHost(int moTypeId) {
BaseResponse response = httpRestClient.defaultGet("/mobject/asyMobjectHost?moTypeId=" + moTypeId, BaseResponse.class);
return response;
}
@RequestMapping(value = "/asyAllJavaInstances")
public BaseResponse asyAllJavaInstances() {
BaseResponse response = httpRestClient.defaultGet("/mobject/asyAllJavaInstances", BaseResponse.class);
return response;
}
@RequestMapping(value = "/queryHost")
public BaseResponse queryMHostInfo(MObjectHostInfoReq request) {
BaseResponse response = httpRestClient.defaultPost("/mobject/queryHost", request, BaseResponse.class);
return response;
}
@RequestMapping(value = "/queryJavaApp")
public BaseResponse queryMHostInfo() {
BaseResponse response = httpRestClient.defaultGet("/mobject/javaapi", BaseResponse.class);
return response;
}
//新增依赖服务 与 依赖服务类型 查询
@RequestMapping(value = "/queryDependency")
public BaseResponse queryDependency(DependencyRequest request) {
BaseResponse response = httpRestClient.defaultPost("/mobject/queryDependency", request, BaseResponse.class);
return response;
}
//查询已绑定的服务
@RequestMapping(value = "/queryBindDependency")
public BaseResponse queryBindDependency(DependencyRequest request) {
BaseResponse response = httpRestClient.defaultPost("/mobject/queryBindDependency", request, BaseResponse.class);
return response;
}
//更新绑定服务
@RequestMapping(value = "/updateBindDependency")
public BaseResponse updateBindDependency(DependencyRequest request, String dependenciesString) {
if (StringUtils.isNotBlank(dependenciesString)) {
for (String str : dependenciesString.split(",")) {
request.getDependencies().add(str);
}
}
BaseResponse response = httpRestClient.defaultPost("/mobject/updateBindDependency", request, BaseResponse.class);
return response;
}
/**
* 查询 当前 typeId 是否可以修改类型(叶子,非叶子)
* 1)是否存在主机
* 2)是否包括子节点
*
* @param typeIdStr "node_id"
* @return true or false(不能更改类型)
*/
@GetMapping("/queryTypeInfoById")
public BaseResponse queryTypeInfoById(String typeIdStr) {
String typeId = StringUtils.split(typeIdStr, "_")[1];
BaseResponse response = httpRestClient.defaultGet("/mobject/queryTypeInfoById?typeId=" + typeId, BaseResponse.class);
return response;
}
}