2021-04-07 14:52:03 +08:00
|
|
|
package com.yutou.nas.other;
|
|
|
|
|
2022-05-03 20:08:51 +08:00
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
2021-04-07 14:52:03 +08:00
|
|
|
import com.yutou.nas.NasApplication;
|
2021-08-17 08:10:58 +08:00
|
|
|
import com.yutou.nas.Services.IVideoToolsService;
|
2021-06-23 16:08:40 +08:00
|
|
|
import com.yutou.nas.utils.AppTools;
|
2021-06-18 17:39:02 +08:00
|
|
|
import com.yutou.nas.utils.DepotManager;
|
2021-04-07 14:52:03 +08:00
|
|
|
import com.yutou.nas.utils.RedisTools;
|
|
|
|
import com.yutou.nas.utils.Tools;
|
2021-06-23 16:08:40 +08:00
|
|
|
import org.springframework.beans.factory.config.BeanDefinition;
|
|
|
|
import org.springframework.beans.factory.support.GenericBeanDefinition;
|
|
|
|
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
|
|
|
import org.springframework.core.annotation.AnnotationUtils;
|
|
|
|
import org.springframework.core.type.classreading.MetadataReader;
|
|
|
|
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
|
|
|
import org.springframework.core.type.filter.TypeFilter;
|
2021-04-07 14:52:03 +08:00
|
|
|
import org.springframework.stereotype.Controller;
|
2021-06-23 16:08:40 +08:00
|
|
|
import org.springframework.util.ObjectUtils;
|
2021-04-07 14:52:03 +08:00
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
2021-08-17 08:10:58 +08:00
|
|
|
import javax.annotation.Resource;
|
2021-04-07 14:52:03 +08:00
|
|
|
import javax.servlet.http.Cookie;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.FileReader;
|
2021-06-23 16:08:40 +08:00
|
|
|
import java.io.IOException;
|
|
|
|
import java.lang.annotation.Annotation;
|
|
|
|
import java.util.*;
|
2021-04-07 14:52:03 +08:00
|
|
|
|
|
|
|
@Controller
|
|
|
|
public class tools {
|
|
|
|
|
|
|
|
|
|
|
|
@ResponseBody
|
|
|
|
@RequestMapping(value = "tools/get.do")
|
|
|
|
public String getJs(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
|
|
Enumeration<String> name = request.getHeaderNames();
|
|
|
|
while (name.hasMoreElements()) {
|
|
|
|
String na = name.nextElement();
|
2021-04-08 15:40:59 +08:00
|
|
|
com.yutou.nas.utils.Log.i(na + " " + request.getHeader(na));
|
2021-04-07 14:52:03 +08:00
|
|
|
}
|
|
|
|
File file = new File("D:\\IDEA\\web_toolset\\web\\js\\my.js");
|
|
|
|
BufferedReader reader = new BufferedReader(new FileReader(file));
|
|
|
|
String tmp, str = "";
|
|
|
|
while ((tmp = reader.readLine()) != null) {
|
|
|
|
if (tmp.contains("\"")) {
|
|
|
|
// tmp=tmp.replace("\"","\\\"");
|
|
|
|
}
|
|
|
|
str += tmp;
|
|
|
|
}
|
|
|
|
reader.close();
|
|
|
|
/* response.setHeader("Content-Type","application/javascript; charset=utf-8");
|
|
|
|
PrintWriter writer=response.getWriter();
|
|
|
|
writer.write(str);
|
|
|
|
writer.flush();
|
|
|
|
writer.close();*/
|
|
|
|
return str;
|
|
|
|
//return "function test(){ return \"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1588139022200&di=8cc8405f7514dd54bd82fcd070349603&imgtype=0&src=http%3A%2F%2Fa2.att.hudong.com%2F36%2F48%2F19300001357258133412489354717.jpg\" }";
|
|
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping("/public/version.do")
|
|
|
|
@ResponseBody
|
|
|
|
public String getVersion() {
|
|
|
|
return NasApplication.version;
|
|
|
|
}
|
|
|
|
|
|
|
|
@ResponseBody
|
|
|
|
@RequestMapping("/public/request.do")
|
|
|
|
public String testRequest(HttpServletRequest request) {
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
|
JSONArray cookies = new JSONArray();
|
|
|
|
JSONObject header = new JSONObject();
|
|
|
|
for (String key : request.getParameterMap().keySet()) {
|
|
|
|
params.put(key, request.getParameter(key));
|
|
|
|
}
|
|
|
|
if (request.getCookies() != null) {
|
|
|
|
for (Cookie cookie : request.getCookies()) {
|
2022-05-03 20:08:51 +08:00
|
|
|
JSONObject ck = JSON.parseObject(JSON.toJSONString(cookie));
|
2021-04-07 14:52:03 +08:00
|
|
|
cookies.add(ck);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Enumeration<String> enumeration = request.getHeaderNames();
|
|
|
|
while (enumeration != null && enumeration.hasMoreElements()) {
|
|
|
|
String tmp = enumeration.nextElement();
|
|
|
|
header.put(tmp, request.getHeader(tmp));
|
|
|
|
}
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
json.put("code", 0);
|
|
|
|
json.put("method", request.getMethod());
|
|
|
|
json.put("address", Tools.getRemoteAddress(request));
|
|
|
|
json.put("UA", request.getHeader("User-Agent"));
|
|
|
|
json.put("addressUrl", request.getPathInfo());
|
|
|
|
json.put("params", params);
|
|
|
|
json.put("cookie", cookies);
|
|
|
|
json.put("header", header);
|
|
|
|
Tools.sendServer("打印请求", json.toJSONString());
|
|
|
|
try {
|
|
|
|
switch (RedisTools.get("request")) {
|
|
|
|
case "success":
|
|
|
|
return "success";
|
|
|
|
case "-999":
|
|
|
|
case "param":
|
|
|
|
return json.toJSONString();
|
|
|
|
default:
|
|
|
|
return RedisTools.get("request");
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
// e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
return json.toJSONString();
|
|
|
|
}
|
|
|
|
|
|
|
|
@ResponseBody
|
|
|
|
@RequestMapping("/private/request.do")
|
|
|
|
public String setRequest(String ret, String data) {
|
|
|
|
switch (ret) {
|
|
|
|
case "success":
|
|
|
|
RedisTools.set("request", "success");
|
|
|
|
break;
|
|
|
|
case "user":
|
|
|
|
RedisTools.set("request", data);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
RedisTools.set("request", "param");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return RedisTools.get("request");
|
|
|
|
}
|
2021-06-18 17:39:02 +08:00
|
|
|
@ResponseBody
|
|
|
|
@RequestMapping("/public/deport.do")
|
|
|
|
public String testDeport(){
|
|
|
|
DepotManager.scan();
|
|
|
|
return "ok";
|
|
|
|
}
|
2021-08-17 08:10:58 +08:00
|
|
|
@Resource
|
|
|
|
IVideoToolsService videoToolsService;
|
2021-06-23 16:08:40 +08:00
|
|
|
@ResponseBody
|
|
|
|
@RequestMapping("/public/test.do")
|
|
|
|
public String test(){
|
2021-08-17 08:10:58 +08:00
|
|
|
/* List<Class> list= AppTools.scanClass("com.yutou.nas",Controller.class);
|
2021-06-23 16:08:40 +08:00
|
|
|
System.out.println("list size = "+list.size());
|
|
|
|
for (Class aClass : list) {
|
|
|
|
System.out.println(aClass.getName());
|
|
|
|
System.out.println(aClass.getAnnotation(RequestMapping.class));
|
2021-08-17 08:10:58 +08:00
|
|
|
}*/
|
|
|
|
videoToolsService.scanVideo();
|
2021-06-23 16:08:40 +08:00
|
|
|
return "ok";
|
|
|
|
}
|
2021-09-30 09:32:51 +08:00
|
|
|
@ResponseBody
|
|
|
|
@RequestMapping("/public/getUPSPower.do")
|
2022-03-17 09:22:57 +08:00
|
|
|
public int getUPSPower(){
|
2021-09-30 09:32:51 +08:00
|
|
|
return Tools.getSystemUPSPower();
|
|
|
|
}
|
2021-04-07 14:52:03 +08:00
|
|
|
|
|
|
|
}
|