From 89346de453506f7bed72efefa7a05af7fd498057 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Wed, 8 Apr 2020 17:40:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DAndroid=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=BC=9A=E6=B7=B7=E4=B9=B1=E7=9A=84bug=20shi?= =?UTF-8?q?p/type.do=E6=8E=A5=E5=8F=A3=E5=8F=96=E6=B6=88=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=20=E6=96=B0=E5=A2=9EFilter=E6=8B=A6=E6=88=AA?= =?UTF-8?q?=E5=99=A8=EF=BC=8C=E6=89=93=E5=8D=B0=E8=AF=B7=E6=B1=82=E5=92=8C?= =?UTF-8?q?=E5=8F=82=E6=95=B0=20System.out=E6=94=B9=E6=88=90Log.i?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/home.html | 2 +- pom.xml | 2 +- src/main/java/com/yutou/Data/Ship.java | 3 ++- .../com/yutou/controller/CDNController.java | 3 ++- .../MapTop/AndroidMapController.java | 6 ----- .../controller/MapTop/MapTopController.java | 3 ++- .../controller/Web/WebLoginController.java | 6 ++--- .../Web/WebPermissionController.java | 3 ++- .../controller/Web/WebUserController.java | 23 +++++++++--------- .../controller/admin/AdminUserController.java | 3 ++- .../controller/android/SystemController.java | 10 +++++++- .../controller/android/UserController.java | 1 + src/main/java/com/yutou/controller/ulit.java | 3 ++- .../yutou/services/impl/ModServiceimpl.java | 3 ++- src/main/java/com/yutou/utlis/APIFilter.java | 24 +++++++++++++++++++ src/main/java/com/yutou/utlis/Log.java | 3 ++- .../java/com/yutou/utlis/MD5Signature.java | 3 +-- src/main/java/com/yutou/utlis/RedisUtlis.java | 2 +- src/main/java/com/yutou/utlis/Tools.java | 19 +++++++++++---- 19 files changed, 84 insertions(+), 38 deletions(-) create mode 100644 src/main/java/com/yutou/utlis/APIFilter.java diff --git a/html/home.html b/html/home.html index 6566d27..307aa40 100644 --- a/html/home.html +++ b/html/home.html @@ -161,7 +161,7 @@ try { var pw = json.data.user.power; - if (pw == '') { + if (pw === '') { location.reload(); return; } diff --git a/pom.xml b/pom.xml index 6cd4bf6..c5a1c1b 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ com.yutou.jianrmod servicer - 2.0.1-release + 2.0.2-release servicer Demo project for Spring Boot diff --git a/src/main/java/com/yutou/Data/Ship.java b/src/main/java/com/yutou/Data/Ship.java index b0d6937..7a4af56 100644 --- a/src/main/java/com/yutou/Data/Ship.java +++ b/src/main/java/com/yutou/Data/Ship.java @@ -3,6 +3,7 @@ package com.yutou.Data; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.yutou.utlis.Log; import java.util.ArrayList; import java.util.List; @@ -74,7 +75,7 @@ public class Ship { return ship; }catch (Exception e){ e.printStackTrace(); - System.out.println(json.toString()); + Log.i(json.toString()); System.exit(0); } return null; diff --git a/src/main/java/com/yutou/controller/CDNController.java b/src/main/java/com/yutou/controller/CDNController.java index 3d50d2e..0f6e8f8 100644 --- a/src/main/java/com/yutou/controller/CDNController.java +++ b/src/main/java/com/yutou/controller/CDNController.java @@ -5,6 +5,7 @@ import java.util.Date; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import com.yutou.utlis.Log; import org.json.JSONObject; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -28,7 +29,7 @@ public class CDNController { public String ballback(HttpServletRequest request, String hash, String key, String bucket, String fsize, String uuid, String uToken,String qToken) { try { - System.out.println("七牛云回调:"); + Log.i("七牛云回调:"); Tools.PrintfHttpServletRequest(request); if (qToken == null) { JSONObject json = new JSONObject(); diff --git a/src/main/java/com/yutou/controller/MapTop/AndroidMapController.java b/src/main/java/com/yutou/controller/MapTop/AndroidMapController.java index 2d41d4f..e52951b 100644 --- a/src/main/java/com/yutou/controller/MapTop/AndroidMapController.java +++ b/src/main/java/com/yutou/controller/MapTop/AndroidMapController.java @@ -107,12 +107,6 @@ public class AndroidMapController { @RequestMapping("/android/ship/type.do") public String getShipType(HttpServletRequest request){ JSONObject json=new JSONObject(); - if(Tools.getUidOfToken(request)<=0){ - json.put("msg",UserEnum.LOGIN_NOT_LOGIN.msg); - json.put("code", UserEnum.LOGIN_NOT_LOGIN.code); - return json.toString(); - } - List list=mapNodeService.selectAllShipType(); json.put("count",list.size()); json.put("data", JSONArray.toJSON(list)); diff --git a/src/main/java/com/yutou/controller/MapTop/MapTopController.java b/src/main/java/com/yutou/controller/MapTop/MapTopController.java index 81f5d90..d7e647d 100644 --- a/src/main/java/com/yutou/controller/MapTop/MapTopController.java +++ b/src/main/java/com/yutou/controller/MapTop/MapTopController.java @@ -9,6 +9,7 @@ import com.yutou.maptop.Bean.UserTeam; import com.yutou.maptop.services.MapTopService; import com.yutou.maptop.services.UserTeamService; import com.yutou.utlis.JianrDataTools; +import com.yutou.utlis.Log; import com.yutou.utlis.Tools; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -61,7 +62,7 @@ public class MapTopController { map.setMapNode(JianrDataTools.getMapNode(gameInfoLog.getExt())); map.setShipTeam(JianrDataTools.getShip(JSONObject.parseObject(gameInfoLog.getMessage()),JianrDataTools.SHIP_TYPE)); int id=mapTopService.insertMapTop(map); - System.out.println(">>>>>>ID="+id+" ---> "+JSONObject.parseObject(gameInfoLog.getExt()).getInteger("n")+" "+gameInfoLog.getId()); + Log.i(">>>>>>ID="+id+" ---> "+JSONObject.parseObject(gameInfoLog.getExt()).getInteger("n")+" "+gameInfoLog.getId()); UserTeam team=new UserTeam(); team.setMid(id); team.setMapNode(map.getMapNode()); diff --git a/src/main/java/com/yutou/controller/Web/WebLoginController.java b/src/main/java/com/yutou/controller/Web/WebLoginController.java index 48350ce..bd6ea70 100644 --- a/src/main/java/com/yutou/controller/Web/WebLoginController.java +++ b/src/main/java/com/yutou/controller/Web/WebLoginController.java @@ -9,6 +9,7 @@ import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import com.yutou.utlis.Log; import org.json.JSONObject; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -77,7 +78,7 @@ public class WebLoginController { request.getSession().setAttribute("power", 100); break; } - System.out.println(json.toString()); + Log.i(json.toString()); return json.toString(); } @@ -85,7 +86,7 @@ public class WebLoginController { @ResponseBody public String reg(HttpServletRequest request,String uname,String pass,String name) { JSONObject json = new JSONObject(); - System.out.println("注册请求"); + Log.i("注册请求"); Tools.PrintfHttpServletRequest(request); try { uname=new String(uname.getBytes(), StandardCharsets.UTF_8); @@ -120,7 +121,6 @@ public class WebLoginController { String referer=request.getHeader("referer"); JSONObject json = new JSONObject(); try { - System.out.println( RedisUtlis.get(Tools.getCookie(request,"login"))); String ujson = RedisUtlis.get(Tools.getCookie(request,"login")); JSONObject reJson=new JSONObject(ujson); udata = reJson.getInt("uid"); diff --git a/src/main/java/com/yutou/controller/Web/WebPermissionController.java b/src/main/java/com/yutou/controller/Web/WebPermissionController.java index bd3e8fa..a76f2f3 100644 --- a/src/main/java/com/yutou/controller/Web/WebPermissionController.java +++ b/src/main/java/com/yutou/controller/Web/WebPermissionController.java @@ -6,6 +6,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import com.yutou.utlis.Log; import org.json.JSONArray; import org.json.JSONObject; import org.springframework.stereotype.Controller; @@ -35,7 +36,7 @@ public class WebPermissionController { JSONObject json=new JSONObject(); JSONArray array=new JSONArray(); User user=userService.getUser(Tools.getUserId(request)); - System.out.println(user); + Log.i(user); for (UGroup group : list) { JSONObject tmp=new JSONObject(); tmp.put("permission", group.getTitle()); diff --git a/src/main/java/com/yutou/controller/Web/WebUserController.java b/src/main/java/com/yutou/controller/Web/WebUserController.java index 095ab42..fd390d0 100644 --- a/src/main/java/com/yutou/controller/Web/WebUserController.java +++ b/src/main/java/com/yutou/controller/Web/WebUserController.java @@ -12,6 +12,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import com.yutou.utlis.*; import org.json.JSONObject; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -27,10 +28,6 @@ import com.yutou.mybatis.UUserdata; import com.yutou.mybatis.User; import com.yutou.services.ModService; import com.yutou.services.UserService; -import com.yutou.utlis.EmailTools; -import com.yutou.utlis.RedisUtlis; -import com.yutou.utlis.ServiceStaticValue; -import com.yutou.utlis.Tools; @Controller @RequestMapping("/user") @@ -66,12 +63,16 @@ public class WebUserController { JSONObject userdata = new JSONObject(); try { String ujson = RedisUtlis.get(Tools.getCookie(request,"login")); - JSONObject json=new JSONObject(ujson); - int uid = json.getInt("uid"); - userdata.put("msg", UserEnum.LOGIN_SUCCESS.code); - userdata.put("message", "ok"); - userdata.put("data", userService.getUserData(uid).getJSONObject("data")); - + if(ujson==null){ + userdata.put("code", UserEnum.LOGIN_NOT_LOGIN.code); + userdata.put("msg", UserEnum.LOGIN_NOT_LOGIN.msg); + }else { + JSONObject json = new JSONObject(ujson); + int uid = json.getInt("uid"); + userdata.put("msg", UserEnum.LOGIN_SUCCESS.code); + userdata.put("message", "ok"); + userdata.put("data", userService.getUserData(uid).getJSONObject("data")); + } } catch (Exception e) { // TODO: handle exception userdata.put("code", UserEnum.LOGIN_NOT_LOGIN.code); @@ -152,7 +153,7 @@ public class WebUserController { try { String ujson =RedisUtlis.get(Tools.getCookie(request,"login")); JSONObject reJson=new JSONObject(ujson); - System.out.println(ujson); + Log.i(ujson); int uid_ =reJson.getInt("uid"); if(!Tools.StringIsEmpty(uid)) { try { diff --git a/src/main/java/com/yutou/controller/admin/AdminUserController.java b/src/main/java/com/yutou/controller/admin/AdminUserController.java index 18db976..f0d4f07 100644 --- a/src/main/java/com/yutou/controller/admin/AdminUserController.java +++ b/src/main/java/com/yutou/controller/admin/AdminUserController.java @@ -9,6 +9,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import com.yutou.utlis.Log; import org.json.JSONArray; import org.json.JSONObject; import org.springframework.stereotype.Controller; @@ -172,7 +173,7 @@ public class AdminUserController { public boolean isAdmin(HttpServletRequest request) { int uid=Tools.getUserId(request); User user=userService.getUser(uid); - System.out.println(user); + Log.i(user); if(user.getPower()0) { json.put("msg", "注销成功"); json.put("code", UserEnum.LOGIN_SUCCESS.code); diff --git a/src/main/java/com/yutou/controller/ulit.java b/src/main/java/com/yutou/controller/ulit.java index 084428a..de45b48 100644 --- a/src/main/java/com/yutou/controller/ulit.java +++ b/src/main/java/com/yutou/controller/ulit.java @@ -19,6 +19,7 @@ import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; +import com.yutou.utlis.Log; import net.sf.json.JSONObject; public class ulit { @@ -189,7 +190,7 @@ public class ulit { return false; } public static void deleteMod(String modPath){ - System.out.println("删除:"+modPath); + Log.i("删除:"+modPath); File files=new File(modPath); if(files.exists()) delete(files); diff --git a/src/main/java/com/yutou/services/impl/ModServiceimpl.java b/src/main/java/com/yutou/services/impl/ModServiceimpl.java index e315ed1..a31a877 100644 --- a/src/main/java/com/yutou/services/impl/ModServiceimpl.java +++ b/src/main/java/com/yutou/services/impl/ModServiceimpl.java @@ -6,6 +6,7 @@ import java.util.List; import javax.annotation.Resource; +import com.yutou.utlis.Log; import org.json.JSONObject; import org.springframework.stereotype.Service; @@ -73,7 +74,7 @@ public class ModServiceimpl implements ModService { public int upload(JSONObject json) { // TODO Auto-generated method stub try { - System.out.println("提交数据库:"+json.toString()); + Log.i("提交数据库:"+json.toString()); TMod mod = JSON.parseObject(json.toString(), TMod.class); mod.setCreatetime(System.currentTimeMillis()); mod.setIcon(json.getString("icon")); diff --git a/src/main/java/com/yutou/utlis/APIFilter.java b/src/main/java/com/yutou/utlis/APIFilter.java new file mode 100644 index 0000000..1406b21 --- /dev/null +++ b/src/main/java/com/yutou/utlis/APIFilter.java @@ -0,0 +1,24 @@ +package com.yutou.utlis; + +import org.springframework.stereotype.Component; + +import javax.servlet.*; +import javax.servlet.annotation.WebFilter; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; + +@Component +@WebFilter +public class APIFilter implements Filter { + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { + HttpServletRequest request= (HttpServletRequest) servletRequest; + Log.i("API", request.getRequestURI()+Tools.getHttpServletRequest(request)); + try { + filterChain.doFilter(servletRequest, servletResponse); + }catch (Exception ignored){ + + } + + } +} diff --git a/src/main/java/com/yutou/utlis/Log.java b/src/main/java/com/yutou/utlis/Log.java index 89505da..7211b6f 100644 --- a/src/main/java/com/yutou/utlis/Log.java +++ b/src/main/java/com/yutou/utlis/Log.java @@ -20,10 +20,11 @@ public class Log { * 普通输出 * @param str 正文 */ - public static void i(String str) { + public static void i(Object str) { System.out.println(str); logger.info(str); } + /** * 错误输出带标题 * @param title 标题 diff --git a/src/main/java/com/yutou/utlis/MD5Signature.java b/src/main/java/com/yutou/utlis/MD5Signature.java index b0fd2a9..833c399 100644 --- a/src/main/java/com/yutou/utlis/MD5Signature.java +++ b/src/main/java/com/yutou/utlis/MD5Signature.java @@ -38,8 +38,7 @@ public class MD5Signature { public static void main(String[] args) throws Exception { String str="channelid=1499395535416&cpArea=1&money=1000¬es=1_2_1499400140&order=T20170707120223&time=1499400143360&uid=2"; String md5=sign(str, "XT9TEBMAAOH8KNYXUC8TUQB3CTOTOZK4"); - System.out.println(md5); - + } } diff --git a/src/main/java/com/yutou/utlis/RedisUtlis.java b/src/main/java/com/yutou/utlis/RedisUtlis.java index f893b99..0e0f321 100644 --- a/src/main/java/com/yutou/utlis/RedisUtlis.java +++ b/src/main/java/com/yutou/utlis/RedisUtlis.java @@ -126,6 +126,6 @@ public class RedisUtlis { public static void main(String[] args) { String str= "\"aaa\""; str=str.replaceAll("\"aaa\"", "0"); - System.out.println(str); + Log.i(str); } } diff --git a/src/main/java/com/yutou/utlis/Tools.java b/src/main/java/com/yutou/utlis/Tools.java index c6b71c5..b8772f2 100644 --- a/src/main/java/com/yutou/utlis/Tools.java +++ b/src/main/java/com/yutou/utlis/Tools.java @@ -56,7 +56,7 @@ public class Tools { //String url = oss.upload(saveFile, path); //oss.close(); fileName=URLEncoder.encode(fileName,"UTF-8"); - System.out.println("上传文件保存路径:"+(path+fileName)); + Log.i("上传文件保存路径:"+(path+fileName)); return path+fileName; } /** @@ -220,7 +220,6 @@ public class Tools { Cookie[] cookies = request.getCookies(); String value=null; for (Cookie cookie : cookies) { - System.out.println(cookie.getName()+" "+cookie.getValue()); if (cookie.getName().equals(key)) { value=cookie.getValue(); break; @@ -300,8 +299,8 @@ public class Tools { array.put(3); array.put(4); array.put(5); - System.out.println(array.toString()); - System.out.println(array.toString()); + Log.i(array.toString()); + Log.i(array.toString()); } /** * N以内的不重复随机数 @@ -476,6 +475,15 @@ public class Tools { Log.i("HttpServletRequest", "Key:" + name + " value:" + request.getParameter(name)); } } + public static String getHttpServletRequest(HttpServletRequest request){ + String queryString="?"; + Enumeration names = request.getParameterNames(); + while (names.hasMoreElements()) { + String name = names.nextElement(); + queryString+=name+"="+request.getParameter(name)+"&"; + } + return queryString.substring(0,queryString.length()-1); + } public static void PrintfSession(HttpServletRequest request) { Enumeration names=request.getSession().getAttributeNames(); while (names.hasMoreElements()) { @@ -519,6 +527,9 @@ public class Tools { return -1; } String ujson = RedisUtlis.get(token); + if(ujson==null){ + return -1; + } JSONObject reJson=new JSONObject(ujson); if(reJson.getString("msg").equals("注册成功")) { return 0;