新增/private/request.do接口可以设置request.do的返回值
This commit is contained in:
parent
cfb36dd830
commit
24a214489b
@ -9,7 +9,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class ToolsApplication {
|
public class ToolsApplication {
|
||||||
public static final String version="1.0.14.1";
|
public static final String version="1.0.14.2";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println("当前版本号:"+version);
|
System.out.println("当前版本号:"+version);
|
||||||
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.yutou.tools.ToolsApplication;
|
import com.yutou.tools.ToolsApplication;
|
||||||
import com.yutou.tools.utils.QQBotManager;
|
import com.yutou.tools.utils.QQBotManager;
|
||||||
|
import com.yutou.tools.utils.RedisTools;
|
||||||
import com.yutou.tools.utils.Tools;
|
import com.yutou.tools.utils.Tools;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -56,7 +57,7 @@ public class tools {
|
|||||||
public String testRequest(HttpServletRequest request) {
|
public String testRequest(HttpServletRequest request) {
|
||||||
JSONObject params = new JSONObject();
|
JSONObject params = new JSONObject();
|
||||||
JSONArray cookies = new JSONArray();
|
JSONArray cookies = new JSONArray();
|
||||||
JSONObject header=new JSONObject();
|
JSONObject header = new JSONObject();
|
||||||
for (String key : request.getParameterMap().keySet()) {
|
for (String key : request.getParameterMap().keySet()) {
|
||||||
params.put(key, request.getParameter(key));
|
params.put(key, request.getParameter(key));
|
||||||
}
|
}
|
||||||
@ -66,20 +67,51 @@ public class tools {
|
|||||||
cookies.add(ck);
|
cookies.add(ck);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Enumeration<String> enumeration=request.getHeaderNames();
|
Enumeration<String> enumeration = request.getHeaderNames();
|
||||||
while (enumeration!=null&&enumeration.hasMoreElements()){
|
while (enumeration != null && enumeration.hasMoreElements()) {
|
||||||
String tmp= enumeration.nextElement();
|
String tmp = enumeration.nextElement();
|
||||||
header.put(tmp,request.getHeader(tmp));
|
header.put(tmp, request.getHeader(tmp));
|
||||||
}
|
}
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("code", 0);
|
json.put("code", 0);
|
||||||
json.put("address", Tools.getRemoteAddress(request));
|
json.put("address", Tools.getRemoteAddress(request));
|
||||||
json.put("UA",request.getHeader(""));
|
json.put("UA", request.getHeader(""));
|
||||||
json.put("addressUrl", request.getPathInfo());
|
json.put("addressUrl", request.getPathInfo());
|
||||||
json.put("params", params);
|
json.put("params", params);
|
||||||
json.put("cookie", cookies);
|
json.put("cookie", cookies);
|
||||||
json.put("header",header);
|
json.put("header", header);
|
||||||
Tools.sendServer("打印请求", json.toJSONString());
|
Tools.sendServer("打印请求", json.toJSONString());
|
||||||
|
try {
|
||||||
|
switch (RedisTools.get("request")){
|
||||||
|
case "success":
|
||||||
|
return "success";
|
||||||
|
case "-999":
|
||||||
|
case "param":
|
||||||
|
return json.toJSONString();
|
||||||
|
case "user":
|
||||||
|
return RedisTools.get("request");
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
return json.toJSONString();
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user