56 lines
1.9 KiB
Java
56 lines
1.9 KiB
Java
package com.yutou.nas.Controllers;
|
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
import com.yutou.nas.utils.*;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.io.File;
|
|
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";
|
|
}
|
|
@ResponseBody
|
|
@RequestMapping("/tools/anim/items.do")
|
|
public JSONArray getAnimItems(){
|
|
return new JellyfinAPIManager().getAnimPaths();
|
|
}
|
|
@ResponseBody
|
|
@RequestMapping(value = "/tools/anim/set.do",method = RequestMethod.POST)
|
|
public String setAnimMeta(String path,String id){
|
|
new JellyfinAPIManager().init(new File(path),id);
|
|
return "1";
|
|
}
|
|
}
|