|
|
@ -1,5 +1,8 @@
|
|
|
|
package com.example.action;
|
|
|
|
package com.example.action;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.example.config.NginxConfig;
|
|
|
|
|
|
|
|
import com.example.frame.utils.*;
|
|
|
|
|
|
|
|
import com.example.module.admin.ent.NginxCtrl;
|
|
|
|
import com.example.module.admin.mgr.MappingManager;
|
|
|
|
import com.example.module.admin.mgr.MappingManager;
|
|
|
|
import com.example.module.admin.req.*;
|
|
|
|
import com.example.module.admin.req.*;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
@ -13,13 +16,9 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
|
|
|
|
|
|
|
|
import com.example.frame.utils.LocalData;
|
|
|
|
|
|
|
|
import com.example.frame.utils.MapperUtil;
|
|
|
|
|
|
|
|
import com.example.frame.utils.Message;
|
|
|
|
|
|
|
|
import com.example.frame.base.BaseResponse;
|
|
|
|
import com.example.frame.base.BaseResponse;
|
|
|
|
import com.example.frame.base.ErrorType;
|
|
|
|
import com.example.frame.base.ErrorType;
|
|
|
|
import com.example.frame.base.Token;
|
|
|
|
import com.example.frame.base.Token;
|
|
|
|
import com.example.frame.utils.LogUtil;
|
|
|
|
|
|
|
|
import com.example.frame.base.Error;
|
|
|
|
import com.example.frame.base.Error;
|
|
|
|
|
|
|
|
|
|
|
|
@Controller
|
|
|
|
@Controller
|
|
|
@ -27,6 +26,8 @@ public class AjaxController {
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private MappingManager mappingManager;
|
|
|
|
private MappingManager mappingManager;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private NginxCtrl nginxCtrl;
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping("/ajax")
|
|
|
|
@RequestMapping("/ajax")
|
|
|
|
@ResponseBody
|
|
|
|
@ResponseBody
|
|
|
@ -56,6 +57,15 @@ public class AjaxController {
|
|
|
|
// 示例
|
|
|
|
// 示例
|
|
|
|
case "ajax.example.example":
|
|
|
|
case "ajax.example.example":
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "nginx.start":
|
|
|
|
|
|
|
|
baseResponse = nginxStart(jsonString, token);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "nginx.stop":
|
|
|
|
|
|
|
|
baseResponse = nginxStop(jsonString, token);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "nginx.reload":
|
|
|
|
|
|
|
|
baseResponse = nginxReload(jsonString, token);
|
|
|
|
|
|
|
|
break;
|
|
|
|
// 创建映射
|
|
|
|
// 创建映射
|
|
|
|
case "ajax.admin.mapping.create":
|
|
|
|
case "ajax.admin.mapping.create":
|
|
|
|
baseResponse = createMapping(jsonString, token);
|
|
|
|
baseResponse = createMapping(jsonString, token);
|
|
|
@ -89,6 +99,27 @@ public class AjaxController {
|
|
|
|
return baseResponse;
|
|
|
|
return baseResponse;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private BaseResponse nginxStart(String jsonString, Token token) {
|
|
|
|
|
|
|
|
BaseResponse baseResponse = new BaseResponse();
|
|
|
|
|
|
|
|
String exec = ProcessUtil.execBat(nginxCtrl.getStartCmd());
|
|
|
|
|
|
|
|
System.out.println(exec);
|
|
|
|
|
|
|
|
return baseResponse;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private BaseResponse nginxStop(String jsonString, Token token) {
|
|
|
|
|
|
|
|
BaseResponse baseResponse = new BaseResponse();
|
|
|
|
|
|
|
|
String exec = ProcessUtil.execBat(nginxCtrl.getStopCmd());
|
|
|
|
|
|
|
|
System.out.println(exec);
|
|
|
|
|
|
|
|
return baseResponse;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private BaseResponse nginxReload(String jsonString, Token token) {
|
|
|
|
|
|
|
|
BaseResponse baseResponse = new BaseResponse();
|
|
|
|
|
|
|
|
String exec = ProcessUtil.execBat(nginxCtrl.getReloadCmd());
|
|
|
|
|
|
|
|
System.out.println(exec);
|
|
|
|
|
|
|
|
return baseResponse;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 创建映射
|
|
|
|
* 创建映射
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|