2021-12-18 17:33:14 +08:00
|
|
|
package com.yutou.qqbot.Controllers;
|
|
|
|
|
|
|
|
import com.yutou.qqbot.utlis.AppTools;
|
2021-12-20 00:47:02 +08:00
|
|
|
import com.yutou.qqbot.utlis.RedisTools;
|
2021-12-18 17:33:14 +08:00
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
|
|
@Controller
|
|
|
|
public class AppController {
|
|
|
|
@RequestMapping("/restart.do")
|
|
|
|
@ResponseBody
|
2021-12-20 00:47:02 +08:00
|
|
|
public String restart() {
|
|
|
|
AppTools.exec("cd /home/yutou/public/servier/qqbot && ./start.sh", null, true, false);
|
2021-12-18 17:33:14 +08:00
|
|
|
return "";
|
|
|
|
}
|
2021-12-20 00:47:02 +08:00
|
|
|
|
|
|
|
@ResponseBody
|
|
|
|
@RequestMapping("/door/set.do")
|
|
|
|
public String openDoor(String status) {
|
|
|
|
RedisTools.set("door", status);
|
|
|
|
return "1";
|
|
|
|
}
|
|
|
|
|
|
|
|
@ResponseBody
|
|
|
|
@RequestMapping("/door/get.do")
|
|
|
|
public String getDoor() {
|
|
|
|
if ("open".equals(RedisTools.get("door"))) {
|
|
|
|
RedisTools.set("door", "on");
|
|
|
|
return "1";
|
|
|
|
}
|
|
|
|
return "0";
|
|
|
|
}
|
|
|
|
|
|
|
|
@ResponseBody
|
|
|
|
@RequestMapping("/door/status.do")
|
|
|
|
public String getStatus() {
|
|
|
|
String status = RedisTools.get("door");
|
|
|
|
if ("open".equals(status)) {
|
|
|
|
return "0";
|
|
|
|
} else if ("on".equals(status)) {
|
|
|
|
return "1";
|
|
|
|
}
|
|
|
|
return "-1";
|
|
|
|
}
|
2021-12-18 17:33:14 +08:00
|
|
|
}
|