From 87b6ae5480682a399c21309780c7bcac81230048 Mon Sep 17 00:00:00 2001 From: limqhz Date: Fri, 27 Aug 2021 14:30:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9shiro=E6=8B=A6=E6=88=AA?= =?UTF-8?q?=E5=99=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/mybatis/RequestSearchPlugin.java | 6 ++ oms/src/main/resources/logback.xml | 37 +++++++- oms/src/test/java/com/TestWebSocket.java | 85 ++++++++++++++++++- 3 files changed, 121 insertions(+), 7 deletions(-) diff --git a/oms/src/main/java/com/ydd/oms/config/mybatis/RequestSearchPlugin.java b/oms/src/main/java/com/ydd/oms/config/mybatis/RequestSearchPlugin.java index 5845ee5..0a44219 100644 --- a/oms/src/main/java/com/ydd/oms/config/mybatis/RequestSearchPlugin.java +++ b/oms/src/main/java/com/ydd/oms/config/mybatis/RequestSearchPlugin.java @@ -14,6 +14,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.servlet.http.HttpServletRequest; +import java.lang.reflect.Method; import java.util.List; import java.util.Properties; @@ -45,6 +46,11 @@ public class RequestSearchPlugin implements Interceptor { @Override public Object intercept(Invocation invocation) throws Throwable { + Method method = invocation.getMethod(); + logger.info("method is " + method.getName()); + if ("findByAccount".equals(method.getName())){ + return invocation.proceed(); + } // 准备参数 Executor executor = (Executor) invocation.getTarget(); Object[] args = invocation.getArgs(); diff --git a/oms/src/main/resources/logback.xml b/oms/src/main/resources/logback.xml index 12bfc1a..80e88d0 100644 --- a/oms/src/main/resources/logback.xml +++ b/oms/src/main/resources/logback.xml @@ -14,8 +14,8 @@ class="ch.qos.logback.core.rolling.RollingFileAppender"> ${LOG_HOME}/common-default.log - ${LOG_HOME}/common-default-%d{yyyy-MM-dd}.log - + ${LOG_HOME}/common-default-%d{yyyy-MM-dd}.log + 30 %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n @@ -29,17 +29,46 @@ ERROR - ${LOG_HOME}/common-error-%d{yyyy-MM-dd}.log - + ${LOG_HOME}/common-error-%d{yyyy-MM-dd}.log + 30 %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + + ${LOG_HOME}/service/service.log + + ${LOG_HOME}/service/service-%d{yyyy-MM-dd}.log + 30 + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + + + + + + + + + + + + + + + + + + + + diff --git a/oms/src/test/java/com/TestWebSocket.java b/oms/src/test/java/com/TestWebSocket.java index a7bcebc..bfc762c 100644 --- a/oms/src/test/java/com/TestWebSocket.java +++ b/oms/src/test/java/com/TestWebSocket.java @@ -1,14 +1,93 @@ package com; -import java.net.URI; -import java.net.URISyntaxException; +import org.apache.http.NameValuePair; +import org.apache.http.client.CookieStore; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.BasicCookieStore; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicNameValuePair; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; public class TestWebSocket { - public static void main(String args[]) throws URISyntaxException { + public static void main(String args[]) throws IOException { + CookieStore cookieStore = new BasicCookieStore(); + CloseableHttpClient httpClient = HttpClients.custom().setDefaultCookieStore(cookieStore).build(); + HttpPost httpPost = new HttpPost("https://www.imstlife.com.cn/ClubManage/login.do?ret="); + httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded"); + RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(7000) + .setSocketTimeout(7000).setConnectTimeout(1000).build(); + httpPost.setConfig(requestConfig); + List nameValuePairList = new ArrayList<>(); + NameValuePair p1 = new BasicNameValuePair("username","上海弘娱管理员"); + NameValuePair p2 = new BasicNameValuePair("password","12345678"); + nameValuePairList.add(p1); + nameValuePairList.add(p2); + httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairList, "UTF-8")); + CloseableHttpResponse response = httpClient.execute(httpPost); + String s = convertStreamToString(response.getEntity().getContent()); + System.out.println(s); + HttpPost httpPost2 = new HttpPost("https://www.imstlife.com.cn/ClubManage/class/editClassInfo.do?aclModuleId=45240&buttonId=127290"); + httpPost2.addHeader("Content-Type", "application/x-www-form-urlencoded"); + httpPost2.setConfig(requestConfig); + List param = new ArrayList<>(); + NameValuePair c1 = new BasicNameValuePair("id","8353"); + NameValuePair c2 = new BasicNameValuePair("thumbnailUrl",""); + NameValuePair c3 = new BasicNameValuePair("name","晚间及周末自由训练"); + NameValuePair c4 = new BasicNameValuePair("classTypeId","3810"); + NameValuePair c5 = new BasicNameValuePair("duration","120"); + NameValuePair c6 = new BasicNameValuePair("difficulLevel","0"); + NameValuePair c7 = new BasicNameValuePair("freeState","1"); + NameValuePair c8 = new BasicNameValuePair("price","15"); + NameValuePair c9 = new BasicNameValuePair("isSingle","1"); + NameValuePair c10 = new BasicNameValuePair("wechatShow","1"); + param.add(c1); + param.add(c2); + param.add(c3); + param.add(c4); + param.add(c5); + param.add(c6); + param.add(c7); + param.add(c8); + param.add(c9); + param.add(c10); + httpPost2.setEntity(new UrlEncodedFormEntity(param, "UTF-8")); + CloseableHttpResponse res = httpClient.execute(httpPost2); + String result = convertStreamToString(res.getEntity().getContent()); + System.out.println(result); } + public static String convertStreamToString(InputStream is) { + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + StringBuilder sb = new StringBuilder(); + + String line = null; + try { + while ((line = reader.readLine()) != null) { + sb.append(line + "\n"); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return sb.toString(); + } }