ApiMonitorController.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
75
76
77
78
79
80
81
82
package com.ecar.apm.controller;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ecar.apm.service.HttpRequestService;
import com.ecar.apm.service.HttpSequenceService;
@Controller
public class ApiMonitorController {
@Autowired
private HttpSequenceService httpSequenceService;
@Autowired
private HttpRequestService httpRequestService;
@RequestMapping("/")
public String main(ModelMap map) {
List<Map<String,Object>> list = httpSequenceService.getMonitorList();
map.addAttribute("monitorList", list);
return "monitor_list";
}
@RequestMapping("/monitorList")
public String monitorList(ModelMap map) {
List<Map<String,Object>> list = httpSequenceService.getMonitorList();
map.addAttribute("monitorList", list);
return "monitor_list";
}
@RequestMapping("/monitorLog")
public String monitorLog(ModelMap map, HttpServletRequest request) {
String guid = request.getParameter("guid");
String name = request.getParameter("name");
List<Map<String,Object>> list = httpSequenceService.getLogByGuid(guid);
map.addAttribute("sequencelogs", list);
map.addAttribute("sequenceName", name);
return "monitor_log";
}
@ResponseBody
@RequestMapping(value="/apiLog",method=RequestMethod.GET)
public List<Map<String, Object>> apiLog(HttpServletRequest request, HttpServletResponse response){
String id = request.getParameter("id");
List<Map<String, Object>> list = httpRequestService.getHttpRequestLogByPid(id);
return list;
}
@ResponseBody
@RequestMapping(value="/enableMonitor",method=RequestMethod.GET)
public boolean enableMonitor(HttpServletRequest request, HttpServletResponse response){
String guid = request.getParameter("guid");
String enabled = request.getParameter("enabled");
boolean b;
if("true".equals(enabled)){
b = httpRequestService.disableMonitor(guid);
}else{
b = httpRequestService.enableMonitor(guid);
}
return b;
}
@ResponseBody
@RequestMapping(value="/deleteMonitor",method=RequestMethod.GET)
public boolean deleteMonitor(HttpServletRequest request, HttpServletResponse response){
String guid = request.getParameter("guid");
boolean b = httpRequestService.deleteMonitor(guid);
return b;
}
}