From 772c971ad00ba1f990ba8cc803c50af963479ca9 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Wed, 13 May 2020 08:24:54 +0800 Subject: [PATCH] update --- pom.xml | 2 +- .../controller/Web/WebModController.java | 3 +- .../Web/WebUploadModController.java | 13 +- .../controller/android/ModController.java | 5 +- src/main/java/com/yutou/controller/test.java | 156 +++++++++++------- src/main/java/com/yutou/utlis/APIFilter.java | 3 +- src/main/java/com/yutou/utlis/Tools.java | 8 +- 7 files changed, 115 insertions(+), 75 deletions(-) diff --git a/pom.xml b/pom.xml index c5a1c1b..8fc0f26 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ com.yutou.jianrmod servicer - 2.0.2-release + 2.0.4-release servicer Demo project for Spring Boot diff --git a/src/main/java/com/yutou/controller/Web/WebModController.java b/src/main/java/com/yutou/controller/Web/WebModController.java index 7d0be64..a8c878a 100644 --- a/src/main/java/com/yutou/controller/Web/WebModController.java +++ b/src/main/java/com/yutou/controller/Web/WebModController.java @@ -6,6 +6,7 @@ import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import com.yutou.utlis.Tools; import org.json.JSONObject; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -38,7 +39,7 @@ public class WebModController { JSONObject json = new JSONObject(); List list=new ArrayList<>(); try { - JSONObject user=new JSONObject(RedisUtlis.get(request.getSession().getId())); + JSONObject user=new JSONObject(RedisUtlis.get(Tools.getCookie(request,"login"))); list = modService.getUserOfId(user.getInt("id")); } catch (Exception e) { // TODO: handle exception diff --git a/src/main/java/com/yutou/controller/Web/WebUploadModController.java b/src/main/java/com/yutou/controller/Web/WebUploadModController.java index 9bd7ec0..d56d6bd 100644 --- a/src/main/java/com/yutou/controller/Web/WebUploadModController.java +++ b/src/main/java/com/yutou/controller/Web/WebUploadModController.java @@ -50,7 +50,9 @@ public class WebUploadModController { data=new JSONObject(_json); User user=null; try { - user=userService.getUser((int) Integer.valueOf(RedisUtlis.get(request.getSession().getId()))); + JSONObject ujson=new JSONObject(RedisUtlis.get(Tools.getCookie(request,"login"))); + int uid = ujson.getInt("uid"); + user=userService.getUser(uid); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); @@ -95,12 +97,15 @@ public class WebUploadModController { public String upload_icon(@RequestParam(value = "icon", required = false) MultipartFile file,HttpServletRequest request) { JSONObject json=new JSONObject(); try { - String url=Tools.createFile(request, "mods/"+request.getParameter("path")+"/", file,"icon.png"); + String url=Tools.createFile(request, "mods"+"/"+request.getParameter("path")+"/", file,"icon.png"); json.put("id", 1); json.put("url", ServiceStaticValue.SERVICE_URL+url); json.put("path", request.getParameter("path")); - Log.i("上传", Tools.getRootModsPath(request)+request.getParameter("path")+"/lock"); - new File(Tools.getRootModsPath(request)+request.getParameter("path")+"/lock").createNewFile(); + Log.i("上传", Tools.getRootModsPath(request)+request.getParameter("path")+File.separator+"lock"); + if(!new File(Tools.getRootModsPath(request)+request.getParameter("path")+File.separator).exists()){ + new File(Tools.getRootModsPath(request)+request.getParameter("path")+File.separator).mkdirs(); + } + new File(Tools.getRootModsPath(request)+request.getParameter("path")+File.separator+"lock").createNewFile(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/src/main/java/com/yutou/controller/android/ModController.java b/src/main/java/com/yutou/controller/android/ModController.java index 4dcac0a..1e54f81 100644 --- a/src/main/java/com/yutou/controller/android/ModController.java +++ b/src/main/java/com/yutou/controller/android/ModController.java @@ -68,17 +68,18 @@ public class ModController { int min, max; JSONObject json = new JSONObject(); try { - min = Integer.valueOf(min_str); + min = Integer.parseInt(min_str); } catch (Exception e) { // TODO: handle exception min = -1; } try { - max = Integer.valueOf(max_str); + max = Integer.parseInt(max_str); } catch (Exception e) { // TODO: handle exception max = -1; } + max=99999; int uPower = 0; if ((boolean) request.getAttribute(LOGINSTATE)) { try { diff --git a/src/main/java/com/yutou/controller/test.java b/src/main/java/com/yutou/controller/test.java index 269a714..3fdafe5 100644 --- a/src/main/java/com/yutou/controller/test.java +++ b/src/main/java/com/yutou/controller/test.java @@ -3,15 +3,13 @@ package com.yutou.controller; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.util.Base64; -import java.util.Date; -import java.util.Enumeration; -import java.util.List; +import java.util.*; import java.util.zip.GZIPInputStream; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import com.alibaba.fastjson.JSONObject; import com.yutou.jianrdb.Mapper.MapNodeService; import com.yutou.maptop.Bean.UserTeam; import com.yutou.maptop.services.UserTeamService; @@ -25,68 +23,104 @@ import com.yutou.mybatis.TMod; import com.yutou.services.ModService; import com.yutou.utlis.AESTools; import com.yutou.utlis.RedisUtlis; +import redis.clients.jedis.Jedis; @Controller public class test { - @Resource - ModService modService; - @Resource - MapNodeService service; - - @ResponseBody - @RequestMapping("/map/test.do") - public String getMod(HttpServletRequest request) { + @Resource + ModService modService; + @Resource + MapNodeService service; - return JSON.toJSONString(service.selectMapName()); - } - private static int index=0; + @ResponseBody + @RequestMapping("/map/test.do") + public String getMod(HttpServletRequest request) { - - @RequestMapping("/redis/set.do") - @ResponseBody - public String set(String key,String value) { - boolean tmp=false; - tmp=RedisUtlis.set(key, value); - return tmp+""; - } - @RequestMapping("/redis/get.do") - @ResponseBody - public String get(String key) { - String value="get"; - value=RedisUtlis.get(key); - return value; - } - @RequestMapping("/cookie/get.do") - @ResponseBody - public String cookies(HttpServletRequest request){ - String cookie=Tools.getCookie(request,null); - Enumeration names=request.getHeaderNames(); - String header=""; - while (names.hasMoreElements()){ - String name=names.nextElement(); - header+=name+":"+request.getHeader(name)+"\n"; - } - System.out.println(cookie); - System.out.println(header); - return cookie; - } + return JSON.toJSONString(service.selectMapName()); + } - public static void main(String[] args) { - String data="qobgbw9QQxWj9p3GayjP1uaRO1yXq/pIo+FHc16dUxU0yZqHXzI1w63RgH6xtSWV4cmGpqZFy7dD8ZD1PAKYG1xGGM66zfi+ok4nsJ1culeMEyawS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PEtr/NqZQ4gYqWqt1jPjlaA08KFhIBRoOwarT4d5ByZZNWbzyJlts9rFVfao/TIK2GNcreggug/7xl5DZppJtMaUUk4VXZ3YTw4AxVlqjcBJuc25oxlQwFgM5qq7t6DFkeEmJik1W1Vw2MvRtAJmYoe+gKz8AvOo7cYGpkzS3lDw9Tj+iNfKnfNQ+5ETc5ZR5UHEHbiA7YS7Hqblq4fz+lVozo2n3OL93BnffYSqPbrYuiYPDgelWdTVGLZwAj1kr+cgcU5/g=="; - byte[] bytes=Base64.getDecoder().decode(data); - try { - GZIPInputStream inputStream=new GZIPInputStream(new ByteArrayInputStream(bytes)); - int len=0; - byte bs[]=new byte[1024]; - ByteArrayOutputStream outputStream=new ByteArrayOutputStream(); - while ((len=inputStream.read(bs))!=-1){ - outputStream.write(bs,0,len); - outputStream.flush(); - } - System.out.println(new java.lang.String(bs)); - } catch (IOException e) { - e.printStackTrace(); - } - } + private static int index = 0; + + + @RequestMapping("/redis/set.do") + @ResponseBody + public String set(String key, String value) { + boolean tmp = false; + tmp = RedisUtlis.set(key, value); + return tmp + ""; + } + + @RequestMapping("/redis/get.do") + @ResponseBody + public String get(String key) { + String value = "get"; + value = RedisUtlis.get(key); + return value; + } + + @RequestMapping("/cookie/get.do") + @ResponseBody + public String cookies(HttpServletRequest request) { + String cookie = Tools.getCookie(request, null); + Enumeration names = request.getHeaderNames(); + String header = ""; + while (names.hasMoreElements()) { + String name = names.nextElement(); + header += name + ":" + request.getHeader(name) + "\n"; + } + System.out.println(cookie); + System.out.println(header); + return cookie; + } + + @RequestMapping("/cnmglz/excel.do") + @ResponseBody + public String addIp(HttpServletRequest request, String type) { + if (Tools.StringIsEmpty(type)) { + String ip = Tools.getRemoteAddress(request); + String redis = RedisUtlis.get("ip_" + ip); + if (redis==null||redis.equals("-999")) { + redis = "1"; + } else { + redis = Integer.parseInt(redis) + 1 + ""; + } + RedisUtlis.set("ip_" + ip, redis); + } else { + Jedis jedis = RedisUtlis.getRedis(); + Set keys = jedis.keys("*"); + String data = ""; + for (String key : keys) { + if (type.equals("del")) { + jedis.del(key); + }else { + if (key.startsWith("ip_")) { + data += "ip=" + key.replace("ip_", "") + " num=" + jedis.get(key) + "\n"; + } + } + } + jedis.close(); + return data; + } + return ""; + } + + + public static void main(String[] args) { + String data = "qobgbw9QQxWj9p3GayjP1uaRO1yXq/pIo+FHc16dUxU0yZqHXzI1w63RgH6xtSWV4cmGpqZFy7dD8ZD1PAKYG1xGGM66zfi+ok4nsJ1culeMEyawSqG53/zj4+F//DMEEsAUCZyJu2vrP+2MzzwcvkUM62Fd9zVvBjlx2IHn7DM55hKnaEjN9qXlb9TLWsuOEHb877/CIUieHPHuWN0oCENANgUnqycNc6w2XNIWCzcqHPKnR1wz82TxbUFggDCjWYQwysYNNS6DG0JSVE+1opDABPsxc5N2g8c7v6Q0Q969Z749dQl0uJEJiJMUNxN16vcmDH7ZEN7FQQWMfUSV+eFi5u5LCEX2TgHhcUkVS2sPlBAGHZ3/6TmmQdcEyEdz2pJXaFUMnjcJiYgZo32Mm6AssXD2EazJJYJ3mEATYtby3vdw5W/VeDotmTSpXabCScpXOh4C0fBBPZM32+6SRR5aAbh8hI6Ts3CY7NkI7Y2xJS/ASmUOBc+RBNu+s5l2NAsfhubLLxUsrpZKh1TvrOcZv8JJQlE3QRq/QZlk9cFXUFMY7hFQLh2hyLTMqzTxYNEgXyXdOplvq+Aw5Tn+9F5lfTzv+GvnU5/agF6MxPqvrZywsTp0ZOFabigghQlK8MneHnSFfpoiuFqjtKhAzQib07yRp05Q+NNK7qSaxBqaZsWnt76NM5gBwHNhE8Jm1N+8uT9WkqA5Cht0DJgqfbb7qybLAgsvUdlPQB6e1oZ/0qjbDO+7vIP62Bio3BpxTgAND4QQlTHuoLSsV0dBrT+UeiM5FByH6yTDpb9qZMNA5867YuUhmoXZ3q8v05IlUeE/V8a6kDE83oJd7LQeISIKkMeYxC6arXwK7bdpapufFQN4+29rzzeXrDyXG2okuiImBmd5BgX6Lr6Oc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CBW7onLrKmtFhFqbE3EfbbSy1lF+HfCl4ohzqybLtvivz5AtGXDtzXklNC2vSfA9iiZzYatI9V1PhSDc5VPHsn01P44gX+O+LvIV+aKaA/iE2KIx863Qzif3mFbG/ndr2QNbuOWWjx3S47CX/V8KDtMjMh7iONN1XyGdQsBebDbwj+cAPfdnO9meysj9mfaJbl++BtMR/neo2vbEN8SRj7PkJvMRnXnrmFHYDkZzXrKvkNL9TP7YcIfi9OpKYfOpf+QoWh11HqOMppHcY7BMWt8PEtr/NqZQ4gYqWqt1jPjlaA08KFhIBRoOwarT4d5ByZZNWbzyJlts9rFVfao/TIK2GNcreggug/7xl5DZppJtMaUUk4VXZ3YTw4AxVlqjcBJuc25oxlQwFgM5qq7t6DFkeEmJik1W1Vw2MvRtAJmYoe+gKz8AvOo7cYGpkzS3lDw9Tj+iNfKnfNQ+5ETc5ZR5UHEHbiA7YS7Hqblq4fz+lVozo2n3OL93BnffYSqPbrYuiYPDgelWdTVGLZwAj1kr+cgcU5/g=="; + byte[] bytes = Base64.getDecoder().decode(data); + try { + GZIPInputStream inputStream = new GZIPInputStream(new ByteArrayInputStream(bytes)); + int len = 0; + byte bs[] = new byte[1024]; + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + while ((len = inputStream.read(bs)) != -1) { + outputStream.write(bs, 0, len); + outputStream.flush(); + } + System.out.println(new java.lang.String(bs)); + } catch (IOException e) { + e.printStackTrace(); + } + } } diff --git a/src/main/java/com/yutou/utlis/APIFilter.java b/src/main/java/com/yutou/utlis/APIFilter.java index 1406b21..0c60ac6 100644 --- a/src/main/java/com/yutou/utlis/APIFilter.java +++ b/src/main/java/com/yutou/utlis/APIFilter.java @@ -7,8 +7,7 @@ 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 { diff --git a/src/main/java/com/yutou/utlis/Tools.java b/src/main/java/com/yutou/utlis/Tools.java index 240354b..7fc98f0 100644 --- a/src/main/java/com/yutou/utlis/Tools.java +++ b/src/main/java/com/yutou/utlis/Tools.java @@ -36,7 +36,7 @@ public class Tools { * @throws Exception */ public static String createFile(HttpServletRequest request, String path, MultipartFile file,String type) throws Exception { - String savePath = request.getServletContext().getRealPath("/") + "/" + path; + String savePath =new File("").getAbsolutePath()+File.separator +"html"+File.separator+ path; // savePath=savePath.replace("/", "\\"); File servicePath = new File(savePath); if (!servicePath.exists()) { @@ -57,7 +57,7 @@ public class Tools { //String url = oss.upload(saveFile, path); //oss.close(); fileName=URLEncoder.encode(fileName,"UTF-8"); - Log.i("上传文件保存路径:"+(path+fileName)); + Log.i("上传文件保存路径:"+saveFile.getAbsolutePath()); return path+fileName; } /** @@ -498,10 +498,10 @@ public class Tools { } } public static String getRootModsPath(HttpServletRequest request) { - return request.getServletContext().getRealPath("/") + "/"+"mods/"; + return new File("").getAbsolutePath() + File.separator+"html"+File.separator+"mods"+File.separator; } public static String getRootPath(HttpServletRequest request) { - return request.getServletContext().getRealPath("/") + "/"; + return new File("").getAbsolutePath() +File.separator; } public static JSONObject isLogin(HttpServletRequest request,String... args) { JSONObject json=new JSONObject();