Authored by zhengyouwei

nginx 切换修改

... ... @@ -66,55 +66,14 @@ public class NginxSwitchCtrl {
}
/**
* 发送验证码
*
* @return 2016年5月23日下午13:39:48
*/
@RequestMapping(value = "switchbefore")
@ResponseBody
public BaseResponse switchbefore(String cloudName, String target) {
String token = RandomUtil.getToken();
String ticket = RandomUtil.getTicket();
sendticket(ticket, cloudName, target);
smsTicketMap.put(token, new SmsTicket(ticket, cloudName, target));
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(3 * 60 * 1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
smsTicketMap.remove(token);
}
}).start();
BaseResponse<String> baseResponse = new BaseResponse<>();
baseResponse.setCode(200);
baseResponse.setData(token);
return baseResponse;
}
/**
* 修改配置
*
* @return 2016年5月12日下午1:49:48
*/
@RequestMapping(value = "switchNginxConf")
@ResponseBody
public BaseResponse switchNginxConf(String token, String ticket) {
SmsTicket smsTicket = null;
if (smsTicketMap.containsKey(token)) {
smsTicket = smsTicketMap.get(token);
String ticket_ = smsTicket.getTicket();
if (!ticket_.equals(ticket)) {
return new BaseResponse("验证码无效");
}
}
smsTicketMap.remove(token);
String result = exe(smsTicket.getCloudName(), "switch", smsTicket.getTarget());
public BaseResponse switchNginxConf(String cloudName, String target) {
String result = exe(cloudName, "switch", target);
BaseResponse<String> baseResponse = new BaseResponse<>();
baseResponse.setCode(200);
baseResponse.setData(result);
... ...
... ... @@ -16,7 +16,7 @@
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd">
<context:property-placeholder location="classpath:test/*.properties" />
<context:property-placeholder location="classpath:*.properties" />
<context:component-scan base-package="com.monitor" />
... ...