OpsSmsOnOffCtrl.java
4.02 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
package com.ui.ctrl;
import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
/**
* Created by craig.qin on 2017/10/20.
* 运维平台的短信开关
*/
@Controller
@RequestMapping("/OpsSmsOnOff")
public class OpsSmsOnOffCtrl {
@Autowired
private HttpRestClient httpRestClient;
/**
* 跳转到 告警开关页面
* @return
*/
@RequestMapping("/toAlarmSwitch")
public ModelAndView toAlarmSwitch(){
ModelAndView mv = new ModelAndView("alarmgroup/alarmSwitch");
BaseResponse<String> resp = httpRestClient.defaultGet("/OpsSmsOnOff/getSmsSwitchValue", BaseResponse.class, null);
mv.addObject("smsSwitchValue",resp.getMessage());
resp = httpRestClient.defaultGet("/OpsSmsOnOff/getVoiceSmsSwitchValue", BaseResponse.class, null);
mv.addObject("voiceSwitchValue",resp.getMessage());
resp = httpRestClient.defaultGet("/OpsSmsOnOff/getDevSmsSwitchValue", BaseResponse.class, null);
mv.addObject("devSmsSwitchValue",resp.getMessage());
return mv;
}
/**
*
* @param switchName--开关名称
* @param value--切换操作(off:关闭;on:打开)
* @return
*/
@RequestMapping("/switchAlarm")//切换告警状态
@ResponseBody
public BaseResponse switchAlarm(String switchName,String value){
BaseResponse resp = null;
if("smsSwitchValue".equals(switchName) ){
resp = httpRestClient.defaultGet("/OpsSmsOnOff/turn?key=" + value, BaseResponse.class, null);
}else if("voiceSwitchValue".equals(switchName)){
resp = httpRestClient.defaultGet("/OpsSmsOnOff/turnVoice?key=" + value, BaseResponse.class, null);
}else if("devSmsSwitchValue".equals(switchName)){
resp = httpRestClient.defaultGet("/OpsSmsOnOff/turnDev?key=" + value, BaseResponse.class, null);
}
return resp;
}
//短信报警
@RequestMapping("/turnOn")
@ResponseBody
public BaseResponse turnOn() {
return httpRestClient.defaultGet("/OpsSmsOnOff/turn?key=on", BaseResponse.class, null);
}
@RequestMapping("/turnOff")
@ResponseBody
public BaseResponse turnOff() {
return httpRestClient.defaultGet("/OpsSmsOnOff/turn?key=off", BaseResponse.class, null);
}
@RequestMapping("/getSmsSwitchValue")
@ResponseBody
public BaseResponse getSmsSwitchValue() {
return httpRestClient.defaultGet("/OpsSmsOnOff/getSmsSwitchValue", BaseResponse.class, null);
}
///语音报警
@RequestMapping("/turnVoiceOn")
@ResponseBody
public BaseResponse turnVoiceOn() {
return httpRestClient.defaultGet("/OpsSmsOnOff/turnVoice?key=on", BaseResponse.class, null);
}
@RequestMapping("/turnVoiceOff")
@ResponseBody
public BaseResponse turnVoiceOff() {
return httpRestClient.defaultGet("/OpsSmsOnOff/turnVoice?key=off", BaseResponse.class, null);
}
@RequestMapping("/getVoiceSmsSwitchValue")
@ResponseBody
public BaseResponse getVoiceSmsSwitchValue() {
return httpRestClient.defaultGet("/OpsSmsOnOff/getVoiceSmsSwitchValue", BaseResponse.class, null);
}
//短信报警:dev.ops
@RequestMapping("/turnDevOn")
@ResponseBody
public BaseResponse turnDevOn() {
return httpRestClient.defaultGet("/OpsSmsOnOff/turnDev?key=on", BaseResponse.class, null);
}
@RequestMapping("/turnDevOff")
@ResponseBody
public BaseResponse turnDevOff() {
return httpRestClient.defaultGet("/OpsSmsOnOff/turnDev?key=off", BaseResponse.class, null);
}
@RequestMapping("/getDevSmsSwitchValue")
@ResponseBody
public BaseResponse getDevSmsSwitchValue() {
return httpRestClient.defaultGet("/OpsSmsOnOff/getDevSmsSwitchValue", BaseResponse.class, null);
}
}