移植原始版本
This commit is contained in:
44
src/main/java/com/yutou/nas/Controllers/ToolsController.java
Normal file
44
src/main/java/com/yutou/nas/Controllers/ToolsController.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.yutou.nas.Controllers;
|
||||
|
||||
import com.yutou.nas.utils.HttpTools;
|
||||
import com.yutou.nas.utils.RedisTools;
|
||||
import com.yutou.nas.utils.Tools;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
|
||||
@Controller
|
||||
public class ToolsController {
|
||||
@ResponseBody
|
||||
@RequestMapping("/tools/openpc.do")
|
||||
public String open_pc(HttpServletRequest request, String type) {
|
||||
if (StringUtils.isEmpty(type)) {
|
||||
if (Tools.checkWebLogin(request) == 1) {
|
||||
HttpTools.get("http://" + UpdateIp.nas_ip + ":8000/tools/openpc.do?token=zIrsh9TUZP2lfRW753PannG49E7VJvor&type=nas");
|
||||
}
|
||||
} else {
|
||||
if (type.equals("nas")) {
|
||||
try {
|
||||
Process process = Runtime.getRuntime().exec("wakeonlan 00:D8:61:6F:02:2F");
|
||||
RedisTools.processOut(process.getInputStream());
|
||||
RedisTools.processOut(process.getErrorStream());
|
||||
process.destroy();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/tools/server.do")
|
||||
public String sendServerManager(String title, String msg) {
|
||||
Tools.sendServer(title, msg);
|
||||
return "ok";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user