JavaRestartCtrl.java
2.66 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
package com.ui.ctrl;
import com.ui.contants.HttpUriContants;
import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;
import com.ui.model.domain.RestartModel;
import com.ui.model.req.PageRequest;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
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 zhengyouwei on 2016/10/18.
*/
@RestController
@RequestMapping(value = "/javaRestart")
public class JavaRestartCtrl {
Logger log = LoggerFactory.getLogger(JavaRestartCtrl.class);
@Autowired
private HttpRestClient httpClient;
@RequestMapping("/toJavaRestart")
public ModelAndView toJavaRestart() {
return new ModelAndView("/switch/java_restart");
}
@RequestMapping("/toStopOrRestart")
public ModelAndView toStopOrRestart(String project,String cloud, String exe,String ip,Model model) {
model.addAttribute("project",project);
model.addAttribute("cloud",cloud);
model.addAttribute("exe",exe);
model.addAttribute("ip",ip);
return new ModelAndView("/switch/java_restart_process");
}
@RequestMapping("/query")
@ResponseBody
public BaseResponse query(PageRequest req) {
BaseResponse rep = httpClient.defaultPost(HttpUriContants.JAVA_RESTART_GET, req, BaseResponse.class);
return rep;
}
@RequestMapping("/getProjectStatus")
@ResponseBody
public BaseResponse getProjectStatus(String project) {
BaseResponse rep = httpClient.defaultPost(HttpUriContants.JAVA_RESTART_STATAUS + "?project=" + project, null, BaseResponse.class);
return rep;
}
@RequestMapping("/stopOrRestart")
@ResponseBody
public BaseResponse stopOrRestart( RestartModel restartModel) {
if(StringUtils.isBlank(restartModel.getExe()) || StringUtils.isBlank(restartModel.getCloud()) || StringUtils.isBlank(restartModel.getProject())){
return null;
}
BaseResponse rep = httpClient.defaultPost(HttpUriContants.JAVA_STOP_RESTART, restartModel, BaseResponse.class);
return rep;
}
@RequestMapping("/getMessage")
@ResponseBody
public BaseResponse getMessage(Integer id) {
BaseResponse rep = httpClient.defaultPost(HttpUriContants.JAVA_GET_MESSAGE+ "?id=" + id, null, BaseResponse.class);
return rep;
}
}