diff --git a/pom.xml b/pom.xml index f36073f..1f6eac9 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.thankjava.wqq smartqq-agreement-core - 1.1.2 + 1.2.0 org.sonatype.oss @@ -19,7 +19,7 @@ UTF-8 UTF-8 - 1.0.10 + 1.1.0 4.1.4 1.2.49 1.7.25 @@ -122,17 +122,20 @@ repo + master git@github.com:thankjava/smartqq-agreement-core.git scm:git@github.com:thankjava/smartqq-agreement-core.git scm:git:git@github.com:thankjava/smartqq-agreement-core.git + acexy acexy@thankjava.com - Thankjava + Lazy-Koala + \ No newline at end of file diff --git a/src/main/java/com/thankjava/wqq/SmartQQClientBuilder.java b/src/main/java/com/thankjava/wqq/SmartQQClientBuilder.java index cada295..b188704 100644 --- a/src/main/java/com/thankjava/wqq/SmartQQClientBuilder.java +++ b/src/main/java/com/thankjava/wqq/SmartQQClientBuilder.java @@ -1,6 +1,6 @@ package com.thankjava.wqq; -import com.thankjava.toolkit.reflect.ReflectHelper; +import com.thankjava.toolkit.core.reflect.ReflectUtil; import com.thankjava.wqq.consts.ConfigParams; import com.thankjava.wqq.core.action.LoginAction; import com.thankjava.wqq.entity.enums.LoginResultStatus; @@ -17,11 +17,11 @@ */ public class SmartQQClientBuilder { + private static SmartQQClient smartQQClient; + private SmartQQClientBuilder() { } - private static SmartQQClient smartQQClient; - /** * 声明需要自定义参数化 SmartQQClient * @@ -36,7 +36,7 @@ public static SmartQQClientBuilder custom(NotifyListener notifyListener) { throw new NullPointerException("notifyListener can not be null"); } - ReflectHelper.setFieldVal(smartQQClient, "notifyListener", notifyListener); + ReflectUtil.setFieldVal(smartQQClient, "notifyListener", notifyListener); return new SmartQQClientBuilder(); } @@ -77,6 +77,7 @@ public SmartQQClientBuilder setAutoRefreshQrcode() { /** * 当系统计算出登陆状态异常时会重新登录,连续异常到限定阀值后放弃 + * * @param times * @return */ @@ -90,11 +91,12 @@ public SmartQQClientBuilder setAutoLoginMaxRetryTimes(int times) { /** * 注册一个掉线通知 + * * @param offlineListener * @return */ public SmartQQClientBuilder setOffLineListener(CallBackListener offlineListener) { - ReflectHelper.setFieldVal(smartQQClient, "offlineListener", offlineListener); + ReflectUtil.setFieldVal(smartQQClient, "offlineListener", offlineListener); return this; } @@ -107,7 +109,7 @@ public SmartQQClientBuilder setOffLineListener(CallBackListener offlineListener) public void createAndLogin(final CallBackListener getQrListener, final CallBackListener loginListener) { if (getQrListener == null || loginListener == null) { - throw new NullPointerException("listener can not be null"); + throw new NullPointerException("listener can not be null"); } LoginAction loginAction = ActionFactory.getInstance(LoginAction.class); @@ -116,7 +118,7 @@ public void createAndLogin(final CallBackListener getQrListener, final CallBackL @Override public void onListener(ActionListener actionListener) { - loginListener.onListener(new ActionListener(new LoginResult(smartQQClient, (LoginResultStatus)actionListener.getData()))); + loginListener.onListener(new ActionListener(new LoginResult(smartQQClient, (LoginResultStatus) actionListener.getData()))); } }); diff --git a/src/main/java/com/thankjava/wqq/core/action/GetInfoAction.java b/src/main/java/com/thankjava/wqq/core/action/GetInfoAction.java index f7aa952..69504f6 100644 --- a/src/main/java/com/thankjava/wqq/core/action/GetInfoAction.java +++ b/src/main/java/com/thankjava/wqq/core/action/GetInfoAction.java @@ -1,26 +1,20 @@ package com.thankjava.wqq.core.action; -import com.thankjava.wqq.extend.ActionListener; -import com.thankjava.wqq.extend.CallBackListener; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import com.thankjava.toolkit3d.bean.http.AsyncResponse; import com.thankjava.wqq.consts.ConfigParams; import com.thankjava.wqq.core.request.RequestBuilder; -import com.thankjava.wqq.core.request.api.GetDiscusList; -import com.thankjava.wqq.core.request.api.GetGroupNameListMask2; -import com.thankjava.wqq.core.request.api.GetOnlineBuddies2; -import com.thankjava.wqq.core.request.api.GetRecentList2; -import com.thankjava.wqq.core.request.api.GetSelfInfo2; -import com.thankjava.wqq.core.request.api.GetUserFriends2; +import com.thankjava.wqq.core.request.api.*; import com.thankjava.wqq.entity.Session; import com.thankjava.wqq.entity.wqq.DetailedInfo; import com.thankjava.wqq.entity.wqq.DiscusList; import com.thankjava.wqq.entity.wqq.FriendsList; import com.thankjava.wqq.entity.wqq.GroupsList; +import com.thankjava.wqq.extend.ActionListener; +import com.thankjava.wqq.extend.CallBackListener; import com.thankjava.wqq.factory.RequestFactory; import com.thankjava.wqq.util.JSON2Entity; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class GetInfoAction { @@ -199,6 +193,7 @@ public DiscusList getDiscusList() { /** * 异步获取讨论组信息 + * * @param callBackListener * @param tryTimes */ @@ -260,6 +255,7 @@ public GroupsList getGroupsList() { /** * 异步获取群组列表 + * * @param callBackListener * @param tryTimes */ @@ -324,6 +320,7 @@ public DetailedInfo getSelfInfo() { /** * 异步获取个人信息 + * * @param callBackListener * @param tryTimes */ diff --git a/src/main/java/com/thankjava/wqq/core/action/LoginAction.java b/src/main/java/com/thankjava/wqq/core/action/LoginAction.java index e11d707..e193397 100644 --- a/src/main/java/com/thankjava/wqq/core/action/LoginAction.java +++ b/src/main/java/com/thankjava/wqq/core/action/LoginAction.java @@ -1,33 +1,27 @@ package com.thankjava.wqq.core.action; -import java.io.ByteArrayInputStream; -import java.io.IOException; - -import javax.imageio.ImageIO; - -import com.thankjava.wqq.entity.enums.LoginResultStatus; -import com.thankjava.wqq.extend.ActionListener; -import org.apache.http.cookie.Cookie; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; +import com.alibaba.fastjson.JSONObject; +import com.thankjava.toolkit3d.bean.http.AsyncResponse; import com.thankjava.wqq.consts.ConfigParams; import com.thankjava.wqq.consts.ConstsParams; import com.thankjava.wqq.consts.DataResRegx; import com.thankjava.wqq.core.event.MsgPollEvent; import com.thankjava.wqq.core.request.RequestBuilder; -import com.thankjava.wqq.core.request.api.CheckLoginQRcodeStatus; -import com.thankjava.wqq.core.request.api.CheckSig; -import com.thankjava.wqq.core.request.api.GetLoginQRcode; -import com.thankjava.wqq.core.request.api.GetVfWebqq; -import com.thankjava.wqq.core.request.api.Login2; +import com.thankjava.wqq.core.request.api.*; import com.thankjava.wqq.entity.Session; -import com.thankjava.wqq.entity.wqq.FriendsList; +import com.thankjava.wqq.entity.enums.LoginResultStatus; +import com.thankjava.wqq.extend.ActionListener; import com.thankjava.wqq.extend.CallBackListener; import com.thankjava.wqq.factory.ActionFactory; import com.thankjava.wqq.factory.RequestFactory; import com.thankjava.wqq.util.RegexUtil; -import com.alibaba.fastjson.JSONObject; +import org.apache.http.cookie.Cookie; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.imageio.ImageIO; +import java.io.ByteArrayInputStream; +import java.io.IOException; public class LoginAction { @@ -215,7 +209,7 @@ public void onListener(ActionListener actionListener) { public void onListener(ActionListener actionListener) { if (actionListener.getData() != null) { logger.debug("获取群列表成功"); - }else { + } else { logger.error("获取群列表失败"); } } @@ -226,7 +220,7 @@ public void onListener(ActionListener actionListener) { public void onListener(ActionListener actionListener) { if (actionListener.getData() != null) { logger.debug("获取个人信息成功"); - }else { + } else { logger.error("获取个人信息失败"); } } diff --git a/src/main/java/com/thankjava/wqq/core/event/MsgPollEvent.java b/src/main/java/com/thankjava/wqq/core/event/MsgPollEvent.java index a348e06..1633daa 100644 --- a/src/main/java/com/thankjava/wqq/core/event/MsgPollEvent.java +++ b/src/main/java/com/thankjava/wqq/core/event/MsgPollEvent.java @@ -1,23 +1,23 @@ package com.thankjava.wqq.core.event; -import com.thankjava.toolkit.reflect.ReflectHelper; +import com.thankjava.toolkit.core.reflect.ReflectUtil; +import com.thankjava.toolkit3d.bean.http.AsyncResponse; +import com.thankjava.wqq.WQQClient; import com.thankjava.wqq.consts.ConfigParams; import com.thankjava.wqq.core.action.LoginAction; -import com.thankjava.wqq.extend.ActionListener; -import com.thankjava.wqq.factory.ActionFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.wqq.WQQClient; import com.thankjava.wqq.core.request.RequestBuilder; import com.thankjava.wqq.core.request.api.Poll2; import com.thankjava.wqq.entity.Session; import com.thankjava.wqq.entity.enums.PullMsgStatus; import com.thankjava.wqq.entity.msg.PollMsg; import com.thankjava.wqq.entity.sys.MonitoringData; +import com.thankjava.wqq.extend.ActionListener; import com.thankjava.wqq.extend.CallBackListener; +import com.thankjava.wqq.factory.ActionFactory; import com.thankjava.wqq.factory.RequestFactory; import com.thankjava.wqq.util.JSON2Entity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.lang.reflect.Method; @@ -27,14 +27,10 @@ public class MsgPollEvent { private static final Logger logger = LoggerFactory.getLogger(MsgPollEvent.class); - + private static Session session = Session.getSession(); private RequestBuilder poll2 = RequestFactory.getInstance(Poll2.class); - private LoginAction loginAction = ActionFactory.getInstance(LoginAction.class); - - private static Session session = Session.getSession(); - public void poll() { poll2.doRequest(new CallBackListener() { @@ -88,10 +84,10 @@ private boolean doExceptionCheck(PullMsgStatus pullMsgStatus) { // 重置监控数据 session.resetMonitoringData(); try { - Method method = ReflectHelper.getMethod(LoginAction.class, "beginLogin"); + Method method = ReflectUtil.getMethod(LoginAction.class, "beginLogin"); int retryTimes = ConfigParams.AUTO_RE_LOGIN_RETRY_MAX_TIME; while (retryTimes > 0) { - boolean flag = (boolean) ReflectHelper.invokeMethod(loginAction, method); + boolean flag = (boolean) ReflectUtil.invokeMethod(loginAction, method); if (flag) { logger.debug("执行重连完成"); break; diff --git a/src/main/java/com/thankjava/wqq/core/request/RequestBuilder.java b/src/main/java/com/thankjava/wqq/core/request/RequestBuilder.java index 59a55d2..9d89f8f 100644 --- a/src/main/java/com/thankjava/wqq/core/request/RequestBuilder.java +++ b/src/main/java/com/thankjava/wqq/core/request/RequestBuilder.java @@ -1,22 +1,21 @@ - -package com.thankjava.wqq.core.request; - -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.wqq.extend.CallBackListener; - -public interface RequestBuilder { - - /** - * 请求腾讯服务器 得到请求结果 - *

Function: doRequest

- *

Description:

- * - * @param listener 回调函数 如果回调函数为空 则通过 return 返回请求结果 - * @return 如果没有传入回调函数则结果将通过该参数返回, 如果传入了回调函数则返回值为null - * @author acexy@thankjava.com - * @date 2016年12月19日 下午3:05:37 - * @version 1.0 - */ - public AsyncResponse doRequest(CallBackListener listener); - -} +package com.thankjava.wqq.core.request; + +import com.thankjava.toolkit3d.bean.http.AsyncResponse; +import com.thankjava.wqq.extend.CallBackListener; + +public interface RequestBuilder { + + /** + * 请求腾讯服务器 得到请求结果 + *

Function: doRequest

+ *

Description:

+ * + * @param listener 回调函数 如果回调函数为空 则通过 return 返回请求结果 + * @return 如果没有传入回调函数则结果将通过该参数返回, 如果传入了回调函数则返回值为null + * @author acexy@thankjava.com + * @date 2016年12月19日 下午3:05:37 + * @version 1.0 + */ + public AsyncResponse doRequest(CallBackListener listener); + +} diff --git a/src/main/java/com/thankjava/wqq/core/request/aop/DoRequest.java b/src/main/java/com/thankjava/wqq/core/request/aop/DoRequest.java index 94d058a..d8dd5dd 100644 --- a/src/main/java/com/thankjava/wqq/core/request/aop/DoRequest.java +++ b/src/main/java/com/thankjava/wqq/core/request/aop/DoRequest.java @@ -1,19 +1,18 @@ package com.thankjava.wqq.core.request.aop; -import java.lang.reflect.Method; - -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponseCallback; +import com.thankjava.toolkit.bean.aop.entity.AopArgs; +import com.thankjava.toolkit.core.reflect.ReflectUtil; +import com.thankjava.toolkit3d.bean.http.AsyncRequest; +import com.thankjava.toolkit3d.bean.http.AsyncResponse; +import com.thankjava.toolkit3d.bean.http.AsyncResponseCallback; +import com.thankjava.toolkit3d.core.http.AsyncHttpClient; +import com.thankjava.wqq.core.request.api.BaseHttpService; +import com.thankjava.wqq.extend.ActionListener; +import com.thankjava.wqq.extend.CallBackListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.thankjava.toolkit3d.aop.entity.AopParam; -import com.thankjava.toolkit.reflect.ReflectHelper; -import com.thankjava.toolkit3d.http.async.AsyncHttpClient; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.wqq.core.request.api.BaseHttpService; -import com.thankjava.wqq.extend.CallBackListener; -import com.thankjava.wqq.extend.ActionListener; +import java.lang.reflect.Method; public class DoRequest { @@ -23,19 +22,19 @@ public class DoRequest { private static AsyncHttpClient asyncHttpClient = BaseHttpService.asyncHttpClient; - public AopParam doRequest(AopParam aopParam) { + public void doRequest(AopArgs aopArgs) { // 指定代理的函数不要被执行 - aopParam.setInvokeProxyMethod(false); + aopArgs.setInvokeProxyMethod(false); // 获取被代理的函数的参数列 - final CallBackListener listener = (CallBackListener) aopParam.getParams()[0]; + final CallBackListener listener = (CallBackListener) aopArgs.getInvokeArgs()[0]; // 执行buildRequestParams 得到请求的参数体 - Object proxyInstance = aopParam.getProxyInstance(); + Object proxyInstance = aopArgs.getProxyInstance(); - Method method = ReflectHelper.getMethod(proxyInstance.getClass(), proxyMethodName); - AsyncRequest asyncRequest = (AsyncRequest) ReflectHelper.invokeMethod(proxyInstance, method); + Method method = ReflectUtil.getMethod(proxyInstance.getClass(), proxyMethodName); + AsyncRequest asyncRequest = (AsyncRequest) ReflectUtil.invokeMethod(proxyInstance, method); if (listener != null) { @@ -68,15 +67,12 @@ public void cancelled() { } else { try { - aopParam.setResult(asyncHttpClient.syncRequestWithSession(asyncRequest)); + aopArgs.setReturnResult(asyncHttpClient.syncRequestWithSession(asyncRequest)); } catch (Throwable e) { - aopParam.setResult(null); + aopArgs.setReturnResult(null); logger.error("http request error", e); } } - - // 通过普通的方式返回结果 - return aopParam; } } diff --git a/src/main/java/com/thankjava/wqq/core/request/api/BaseHttpService.java b/src/main/java/com/thankjava/wqq/core/request/api/BaseHttpService.java index a9cdc3d..fca928f 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/BaseHttpService.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/BaseHttpService.java @@ -1,26 +1,24 @@ package com.thankjava.wqq.core.request.api; -import java.util.concurrent.atomic.AtomicLong; - -import com.thankjava.toolkit3d.http.async.AsyncHttpClient; -import com.thankjava.toolkit3d.http.async.AsyncHttpClientBuilder; -import com.thankjava.toolkit3d.http.async.consts.CookieCheckLevel; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; +import com.thankjava.toolkit3d.bean.http.AsyncRequest; +import com.thankjava.toolkit3d.bean.http.CookieCheckLevel; +import com.thankjava.toolkit3d.core.http.AsyncHttpClient; +import com.thankjava.toolkit3d.core.http.AsyncHttpClientBuilder; import com.thankjava.wqq.consts.ConstsParams; import com.thankjava.wqq.core.request.RequestBuilder; import com.thankjava.wqq.entity.Session; -public abstract class BaseHttpService implements RequestBuilder { - - protected final Session session = Session.getSession(); +import java.util.concurrent.atomic.AtomicLong; - protected static final AtomicLong msgId = new AtomicLong(ConstsParams.INIT_MSG_ID); +public abstract class BaseHttpService implements RequestBuilder { public final static AsyncHttpClient asyncHttpClient = new AsyncHttpClientBuilder() .setWithoutSSLCheck() .setCookiePolicyLevel(CookieCheckLevel.BROWSER_COMPATIBILITY) .setCloseWarnLogger() .create(); + protected static final AtomicLong msgId = new AtomicLong(ConstsParams.INIT_MSG_ID); + protected final Session session = Session.getSession(); /** * 关闭AsyncHttpClient diff --git a/src/main/java/com/thankjava/wqq/core/request/api/CheckLoginQRcodeStatus.java b/src/main/java/com/thankjava/wqq/core/request/api/CheckLoginQRcodeStatus.java index 6a7c43d..cc29e07 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/CheckLoginQRcodeStatus.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/CheckLoginQRcodeStatus.java @@ -1,11 +1,7 @@ package com.thankjava.wqq.core.request.api; -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.*; import com.thankjava.wqq.consts.RequestUrls; import com.thankjava.wqq.core.request.aop.DoRequest; import com.thankjava.wqq.extend.CallBackListener; diff --git a/src/main/java/com/thankjava/wqq/core/request/api/CheckSig.java b/src/main/java/com/thankjava/wqq/core/request/api/CheckSig.java index 7e7be05..678008a 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/CheckSig.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/CheckSig.java @@ -1,26 +1,26 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; - -public class CheckSig extends BaseHttpService { - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } - - @Override - protected AsyncRequest buildRequestParams() { - return new AsyncRequest( - session.getCheckSigUrl(), - HttpMethod.get - ); - } - -} +package com.thankjava.wqq.core.request.api; + +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.AsyncRequest; +import com.thankjava.toolkit3d.bean.http.AsyncResponse; +import com.thankjava.toolkit3d.bean.http.HttpMethod; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; + +public class CheckSig extends BaseHttpService { + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + return new AsyncRequest( + session.getCheckSigUrl(), + HttpMethod.get + ); + } + +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/GetDiscusList.java b/src/main/java/com/thankjava/wqq/core/request/api/GetDiscusList.java index ff50120..a9679a2 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/GetDiscusList.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/GetDiscusList.java @@ -1,38 +1,34 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.wqq.consts.ConstsParams; -import com.thankjava.wqq.consts.RequestUrls; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; - -public class GetDiscusList extends BaseHttpService { - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } - - @Override - protected AsyncRequest buildRequestParams() { - Parameters params = new Parameters("clientid", String.valueOf(ConstsParams.CLIENT_ID)); - params.append("psessionid", session.getPsessionid()); - params.append("vfwebqq", session.getVfwebqq()); - params.append("t", String.valueOf(System.currentTimeMillis() / 1000)); - - Headers headers = new Headers("Referer", RequestUrls.referer_common.url); - return new AsyncRequest( - RequestUrls.get_discus_list.url, - HttpMethod.get, - params, - headers - ); - } - -} +package com.thankjava.wqq.core.request.api; + +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.*; +import com.thankjava.wqq.consts.ConstsParams; +import com.thankjava.wqq.consts.RequestUrls; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; + +public class GetDiscusList extends BaseHttpService { + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + Parameters params = new Parameters("clientid", String.valueOf(ConstsParams.CLIENT_ID)); + params.append("psessionid", session.getPsessionid()); + params.append("vfwebqq", session.getVfwebqq()); + params.append("t", String.valueOf(System.currentTimeMillis() / 1000)); + + Headers headers = new Headers("Referer", RequestUrls.referer_common.url); + return new AsyncRequest( + RequestUrls.get_discus_list.url, + HttpMethod.get, + params, + headers + ); + } + +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/GetGroupNameListMask2.java b/src/main/java/com/thankjava/wqq/core/request/api/GetGroupNameListMask2.java index 629dce9..e512bef 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/GetGroupNameListMask2.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/GetGroupNameListMask2.java @@ -1,34 +1,29 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.wqq.consts.RequestUrls; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; -import com.thankjava.wqq.util.WqqEncryptor; - -import com.alibaba.fastjson.JSONObject; - -public class GetGroupNameListMask2 extends BaseHttpService { - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } - - @Override - protected AsyncRequest buildRequestParams() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("vfwebqq", session.getVfwebqq()); - jsonObject.put("hash", WqqEncryptor.hash(String.valueOf(session.getUin()), session.getPtwebqq())); - Parameters params = new Parameters("r", jsonObject.toJSONString()); - Headers headers = new Headers("Referer", RequestUrls.referer_common.url); - return new AsyncRequest(RequestUrls.get_group_name_list_mask2.url, HttpMethod.post, params, headers); - } - -} +package com.thankjava.wqq.core.request.api; + +import com.alibaba.fastjson.JSONObject; +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.*; +import com.thankjava.wqq.consts.RequestUrls; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; +import com.thankjava.wqq.util.WqqEncryptor; + +public class GetGroupNameListMask2 extends BaseHttpService { + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("vfwebqq", session.getVfwebqq()); + jsonObject.put("hash", WqqEncryptor.hash(String.valueOf(session.getUin()), session.getPtwebqq())); + Parameters params = new Parameters("r", jsonObject.toJSONString()); + Headers headers = new Headers("Referer", RequestUrls.referer_common.url); + return new AsyncRequest(RequestUrls.get_group_name_list_mask2.url, HttpMethod.post, params, headers); + } + +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/GetLoginQRcode.java b/src/main/java/com/thankjava/wqq/core/request/api/GetLoginQRcode.java index 62a36a5..7dc2e9b 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/GetLoginQRcode.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/GetLoginQRcode.java @@ -1,45 +1,47 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.wqq.consts.ConstsParams; -import com.thankjava.wqq.consts.RequestUrls; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; - -/** - * 获取登录二维码 -*

Function: GetLoginQRcode

-*

Description:

-* @author acexy@thankjava.com -* @date 2016年12月13日 下午5:53:53 -* @version 1.0 - */ -public class GetLoginQRcode extends BaseHttpService{ - - @Override - protected AsyncRequest buildRequestParams() { - Parameters params = new Parameters("appid", String.valueOf(ConstsParams.APP_ID)); - params.append("e", "0"); - params.append("l", "M"); - params.append("s", "5"); - params.append("d", "72"); - params.append("v", "4"); - params.append("4", String.valueOf(Math.random())); - - return new AsyncRequest( - RequestUrls.get_login_qrcode.url, - HttpMethod.get, - params - ); - } - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } -} +package com.thankjava.wqq.core.request.api; + +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.AsyncRequest; +import com.thankjava.toolkit3d.bean.http.AsyncResponse; +import com.thankjava.toolkit3d.bean.http.HttpMethod; +import com.thankjava.toolkit3d.bean.http.Parameters; +import com.thankjava.wqq.consts.ConstsParams; +import com.thankjava.wqq.consts.RequestUrls; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; + +/** + * 获取登录二维码 + *

Function: GetLoginQRcode

+ *

Description:

+ * + * @author acexy@thankjava.com + * @version 1.0 + * @date 2016年12月13日 下午5:53:53 + */ +public class GetLoginQRcode extends BaseHttpService { + + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + Parameters params = new Parameters("appid", String.valueOf(ConstsParams.APP_ID)); + params.append("e", "0"); + params.append("l", "M"); + params.append("s", "5"); + params.append("d", "72"); + params.append("v", "4"); + params.append("4", String.valueOf(Math.random())); + + return new AsyncRequest( + RequestUrls.get_login_qrcode.url, + HttpMethod.get, + params + ); + } +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/GetOnlineBuddies2.java b/src/main/java/com/thankjava/wqq/core/request/api/GetOnlineBuddies2.java index a02c009..73b7a0e 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/GetOnlineBuddies2.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/GetOnlineBuddies2.java @@ -1,38 +1,34 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.wqq.consts.ConstsParams; -import com.thankjava.wqq.consts.RequestUrls; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; - -public class GetOnlineBuddies2 extends BaseHttpService{ - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } - - @Override - protected AsyncRequest buildRequestParams() { - - Parameters params = new Parameters("vfwebqq", session.getVfwebqq()); - params.append("clientid", String.valueOf(ConstsParams.CLIENT_ID)); - params.append("psessionid", session.getPsessionid()); - params.append("t", String.valueOf(System.currentTimeMillis() / 1000)); - Headers headers = new Headers("Referer", RequestUrls.referer_common.url); - return new AsyncRequest( - RequestUrls.get_online_buddies2.url, - HttpMethod.get, - params, - headers - ); - } - -} +package com.thankjava.wqq.core.request.api; + +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.*; +import com.thankjava.wqq.consts.ConstsParams; +import com.thankjava.wqq.consts.RequestUrls; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; + +public class GetOnlineBuddies2 extends BaseHttpService { + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + + Parameters params = new Parameters("vfwebqq", session.getVfwebqq()); + params.append("clientid", String.valueOf(ConstsParams.CLIENT_ID)); + params.append("psessionid", session.getPsessionid()); + params.append("t", String.valueOf(System.currentTimeMillis() / 1000)); + Headers headers = new Headers("Referer", RequestUrls.referer_common.url); + return new AsyncRequest( + RequestUrls.get_online_buddies2.url, + HttpMethod.get, + params, + headers + ); + } + +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/GetRecentList2.java b/src/main/java/com/thankjava/wqq/core/request/api/GetRecentList2.java index 9381a9f..207acd0 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/GetRecentList2.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/GetRecentList2.java @@ -1,42 +1,37 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.wqq.consts.ConstsParams; -import com.thankjava.wqq.consts.RequestUrls; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; - -import com.alibaba.fastjson.JSONObject; - -public class GetRecentList2 extends BaseHttpService { - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } - - @Override - protected AsyncRequest buildRequestParams() { - - JSONObject jsonObject = new JSONObject(); - jsonObject.put("vfwebqq", session.getVfwebqq()); - jsonObject.put("clientid", ConstsParams.CLIENT_ID); - jsonObject.put("psessionid", session.getPsessionid()); - - Parameters params = new Parameters("r", jsonObject.toJSONString()); - Headers headers = new Headers("Referer", RequestUrls.referer_common.url); - return new AsyncRequest( - RequestUrls.get_recent_list2.url, - HttpMethod.post, - params, - headers - ); - } - -} +package com.thankjava.wqq.core.request.api; + +import com.alibaba.fastjson.JSONObject; +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.*; +import com.thankjava.wqq.consts.ConstsParams; +import com.thankjava.wqq.consts.RequestUrls; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; + +public class GetRecentList2 extends BaseHttpService { + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("vfwebqq", session.getVfwebqq()); + jsonObject.put("clientid", ConstsParams.CLIENT_ID); + jsonObject.put("psessionid", session.getPsessionid()); + + Parameters params = new Parameters("r", jsonObject.toJSONString()); + Headers headers = new Headers("Referer", RequestUrls.referer_common.url); + return new AsyncRequest( + RequestUrls.get_recent_list2.url, + HttpMethod.post, + params, + headers + ); + } + +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/GetSelfInfo2.java b/src/main/java/com/thankjava/wqq/core/request/api/GetSelfInfo2.java index 3dc4cfe..5f8b6af 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/GetSelfInfo2.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/GetSelfInfo2.java @@ -1,34 +1,30 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.wqq.consts.RequestUrls; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; - -public class GetSelfInfo2 extends BaseHttpService { - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } - - @Override - protected AsyncRequest buildRequestParams() { - Parameters params = new Parameters("t", String.valueOf(System.currentTimeMillis() / 1000)); - - Headers headers = new Headers("Referer", RequestUrls.referer_common.url); - return new AsyncRequest( - RequestUrls.get_self_info2.url, - HttpMethod.get, - params, - headers - ); - } - -} +package com.thankjava.wqq.core.request.api; + +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.*; +import com.thankjava.wqq.consts.RequestUrls; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; + +public class GetSelfInfo2 extends BaseHttpService { + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + Parameters params = new Parameters("t", String.valueOf(System.currentTimeMillis() / 1000)); + + Headers headers = new Headers("Referer", RequestUrls.referer_common.url); + return new AsyncRequest( + RequestUrls.get_self_info2.url, + HttpMethod.get, + params, + headers + ); + } + +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/GetUserFriends2.java b/src/main/java/com/thankjava/wqq/core/request/api/GetUserFriends2.java index 81ab17e..7071d3b 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/GetUserFriends2.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/GetUserFriends2.java @@ -1,34 +1,29 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.wqq.consts.RequestUrls; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; -import com.thankjava.wqq.util.WqqEncryptor; - -import com.alibaba.fastjson.JSONObject; - -public class GetUserFriends2 extends BaseHttpService { - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } - - @Override - protected AsyncRequest buildRequestParams() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("vfwebqq", session.getVfwebqq()); - jsonObject.put("hash", WqqEncryptor.hash(String.valueOf(session.getUin()), session.getPtwebqq())); - Parameters params = new Parameters("r", jsonObject.toJSONString()); - Headers headers = new Headers("Referer", RequestUrls.referer_common.url); - return new AsyncRequest(RequestUrls.get_user_friends2.url, HttpMethod.post, params, headers); - } - -} +package com.thankjava.wqq.core.request.api; + +import com.alibaba.fastjson.JSONObject; +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.*; +import com.thankjava.wqq.consts.RequestUrls; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; +import com.thankjava.wqq.util.WqqEncryptor; + +public class GetUserFriends2 extends BaseHttpService { + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("vfwebqq", session.getVfwebqq()); + jsonObject.put("hash", WqqEncryptor.hash(String.valueOf(session.getUin()), session.getPtwebqq())); + Parameters params = new Parameters("r", jsonObject.toJSONString()); + Headers headers = new Headers("Referer", RequestUrls.referer_common.url); + return new AsyncRequest(RequestUrls.get_user_friends2.url, HttpMethod.post, params, headers); + } + +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/GetVfWebqq.java b/src/main/java/com/thankjava/wqq/core/request/api/GetVfWebqq.java index 4c43cd2..8cdae31 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/GetVfWebqq.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/GetVfWebqq.java @@ -1,30 +1,26 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.wqq.consts.RequestUrls; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; - -public class GetVfWebqq extends BaseHttpService { - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } - - @Override - protected AsyncRequest buildRequestParams() { - Parameters params = new Parameters("ptwebqq", session.getPtwebqq()); - params.append("clientid", "53999199"); - params.append("psessionid", ""); - params.append("t", String.valueOf(System.currentTimeMillis() / 1000)); - Headers header = new Headers("Referer", RequestUrls.referer_getvfwebqq.url); - return new AsyncRequest(RequestUrls.getvfwebqq.url, HttpMethod.get, params, header); - } -} +package com.thankjava.wqq.core.request.api; + +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.*; +import com.thankjava.wqq.consts.RequestUrls; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; + +public class GetVfWebqq extends BaseHttpService { + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + Parameters params = new Parameters("ptwebqq", session.getPtwebqq()); + params.append("clientid", "53999199"); + params.append("psessionid", ""); + params.append("t", String.valueOf(System.currentTimeMillis() / 1000)); + Headers header = new Headers("Referer", RequestUrls.referer_getvfwebqq.url); + return new AsyncRequest(RequestUrls.getvfwebqq.url, HttpMethod.get, params, header); + } +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/Login2.java b/src/main/java/com/thankjava/wqq/core/request/api/Login2.java index 3283389..3ba5fc7 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/Login2.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/Login2.java @@ -1,36 +1,31 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.wqq.consts.ConstsParams; -import com.thankjava.wqq.consts.RequestUrls; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; - -import com.alibaba.fastjson.JSONObject; - -public class Login2 extends BaseHttpService { - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } - - @Override - protected AsyncRequest buildRequestParams() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("ptwebqq", session.getPtwebqq()); - jsonObject.put("clientid", ConstsParams.CLIENT_ID); - jsonObject.put("psessionid", ""); - jsonObject.put("status", "online"); - Parameters params = new Parameters("r", jsonObject.toJSONString()); - Headers headers = new Headers("Referer", RequestUrls.referer_common.url); - return new AsyncRequest(RequestUrls.login2.url, HttpMethod.post, params, headers); - } - -} +package com.thankjava.wqq.core.request.api; + +import com.alibaba.fastjson.JSONObject; +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.*; +import com.thankjava.wqq.consts.ConstsParams; +import com.thankjava.wqq.consts.RequestUrls; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; + +public class Login2 extends BaseHttpService { + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("ptwebqq", session.getPtwebqq()); + jsonObject.put("clientid", ConstsParams.CLIENT_ID); + jsonObject.put("psessionid", ""); + jsonObject.put("status", "online"); + Parameters params = new Parameters("r", jsonObject.toJSONString()); + Headers headers = new Headers("Referer", RequestUrls.referer_common.url); + return new AsyncRequest(RequestUrls.login2.url, HttpMethod.post, params, headers); + } + +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/Poll2.java b/src/main/java/com/thankjava/wqq/core/request/api/Poll2.java index 0eceead..37cde47 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/Poll2.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/Poll2.java @@ -1,36 +1,31 @@ -package com.thankjava.wqq.core.request.api; - -import com.thankjava.toolkit3d.aop.anno.Before; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.wqq.consts.ConstsParams; -import com.thankjava.wqq.consts.RequestUrls; -import com.thankjava.wqq.core.request.aop.DoRequest; -import com.thankjava.wqq.extend.CallBackListener; - -import com.alibaba.fastjson.JSONObject; - -public class Poll2 extends BaseHttpService { - - @Override - @Before(cutClass = DoRequest.class, cutMethod = "doRequest") - public AsyncResponse doRequest(CallBackListener listener) { - return null; - } - - @Override - protected AsyncRequest buildRequestParams() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("ptwebqq", session.getPtwebqq()); - jsonObject.put("clientid", ConstsParams.CLIENT_ID); - jsonObject.put("psessionid", session.getPsessionid()); - jsonObject.put("key", ""); - Parameters params = new Parameters("r", jsonObject.toJSONString()); - Headers headers = new Headers("Referer", RequestUrls.referer_about_msg.url); - return new AsyncRequest(RequestUrls.poll2.url, HttpMethod.post, params, headers); - } - -} +package com.thankjava.wqq.core.request.api; + +import com.alibaba.fastjson.JSONObject; +import com.thankjava.toolkit.bean.aop.anno.Before; +import com.thankjava.toolkit3d.bean.http.*; +import com.thankjava.wqq.consts.ConstsParams; +import com.thankjava.wqq.consts.RequestUrls; +import com.thankjava.wqq.core.request.aop.DoRequest; +import com.thankjava.wqq.extend.CallBackListener; + +public class Poll2 extends BaseHttpService { + + @Override + @Before(cutClass = DoRequest.class, cutMethod = "doRequest") + public AsyncResponse doRequest(CallBackListener listener) { + return null; + } + + @Override + protected AsyncRequest buildRequestParams() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("ptwebqq", session.getPtwebqq()); + jsonObject.put("clientid", ConstsParams.CLIENT_ID); + jsonObject.put("psessionid", session.getPsessionid()); + jsonObject.put("key", ""); + Parameters params = new Parameters("r", jsonObject.toJSONString()); + Headers headers = new Headers("Referer", RequestUrls.referer_about_msg.url); + return new AsyncRequest(RequestUrls.poll2.url, HttpMethod.post, params, headers); + } + +} diff --git a/src/main/java/com/thankjava/wqq/core/request/api/SendBuddyMsg2.java b/src/main/java/com/thankjava/wqq/core/request/api/SendBuddyMsg2.java index 80c69b8..d45ef14 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/SendBuddyMsg2.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/SendBuddyMsg2.java @@ -1,48 +1,43 @@ package com.thankjava.wqq.core.request.api; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; +import com.alibaba.fastjson.JSONObject; +import com.thankjava.toolkit3d.bean.http.*; import com.thankjava.wqq.consts.ConstsParams; import com.thankjava.wqq.consts.RequestUrls; import com.thankjava.wqq.entity.msg.SendMsg; import com.thankjava.wqq.extend.ActionListener; import com.thankjava.wqq.extend.CallBackListener; -import com.alibaba.fastjson.JSONObject; +public class SendBuddyMsg2 extends BaseHttpService { + + private SendMsg sendMsg; -public class SendBuddyMsg2 extends BaseHttpService{ + public SendBuddyMsg2(SendMsg sendMsg) { + this.sendMsg = sendMsg; + } - private SendMsg sendMsg; - - public SendBuddyMsg2(SendMsg sendMsg) { - this.sendMsg = sendMsg; - } - - @Override - public AsyncResponse doRequest(CallBackListener listener) { - if(listener != null){ - listener.onListener(new ActionListener(asyncHttpClient.syncRequestWithSession(buildRequestParams()))); - return null; - }else{ - return asyncHttpClient.syncRequestWithSession(buildRequestParams()); - } - } + @Override + public AsyncResponse doRequest(CallBackListener listener) { + if (listener != null) { + listener.onListener(new ActionListener(asyncHttpClient.syncRequestWithSession(buildRequestParams()))); + return null; + } else { + return asyncHttpClient.syncRequestWithSession(buildRequestParams()); + } + } - @Override - protected AsyncRequest buildRequestParams() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("to", sendMsg.getTo()); // - jsonObject.put("content", sendMsg.getContent().toSendMsg()); // - jsonObject.put("face", 546); // 这个其实没啥用 - jsonObject.put("clientid", ConstsParams.CLIENT_ID); - jsonObject.put("msg_id", msgId.incrementAndGet()); - jsonObject.put("psessionid", session.getPsessionid()); - Parameters params = new Parameters("r", jsonObject.toJSONString()); - Headers headers = new Headers("Referer", RequestUrls.referer_about_msg.url); - return new AsyncRequest(RequestUrls.send_buddy_msg2.url, HttpMethod.post, params, headers); - } + @Override + protected AsyncRequest buildRequestParams() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("to", sendMsg.getTo()); // + jsonObject.put("content", sendMsg.getContent().toSendMsg()); // + jsonObject.put("face", 546); // 这个其实没啥用 + jsonObject.put("clientid", ConstsParams.CLIENT_ID); + jsonObject.put("msg_id", msgId.incrementAndGet()); + jsonObject.put("psessionid", session.getPsessionid()); + Parameters params = new Parameters("r", jsonObject.toJSONString()); + Headers headers = new Headers("Referer", RequestUrls.referer_about_msg.url); + return new AsyncRequest(RequestUrls.send_buddy_msg2.url, HttpMethod.post, params, headers); + } } diff --git a/src/main/java/com/thankjava/wqq/core/request/api/SendDiscuMsg2.java b/src/main/java/com/thankjava/wqq/core/request/api/SendDiscuMsg2.java index c39aabf..59e7abc 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/SendDiscuMsg2.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/SendDiscuMsg2.java @@ -1,48 +1,43 @@ package com.thankjava.wqq.core.request.api; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; +import com.alibaba.fastjson.JSONObject; +import com.thankjava.toolkit3d.bean.http.*; import com.thankjava.wqq.consts.ConstsParams; import com.thankjava.wqq.consts.RequestUrls; import com.thankjava.wqq.entity.msg.SendMsg; import com.thankjava.wqq.extend.ActionListener; import com.thankjava.wqq.extend.CallBackListener; -import com.alibaba.fastjson.JSONObject; +public class SendDiscuMsg2 extends BaseHttpService { + + private SendMsg sendMsg; -public class SendDiscuMsg2 extends BaseHttpService{ + public SendDiscuMsg2(SendMsg sendMsg) { + this.sendMsg = sendMsg; + } - private SendMsg sendMsg; - - public SendDiscuMsg2(SendMsg sendMsg) { - this.sendMsg = sendMsg; - } - - @Override - public AsyncResponse doRequest(CallBackListener listener) { - if(listener != null){ - listener.onListener(new ActionListener(asyncHttpClient.syncRequestWithSession(buildRequestParams()))); - return null; - }else{ - return asyncHttpClient.syncRequestWithSession(buildRequestParams()); - } - } + @Override + public AsyncResponse doRequest(CallBackListener listener) { + if (listener != null) { + listener.onListener(new ActionListener(asyncHttpClient.syncRequestWithSession(buildRequestParams()))); + return null; + } else { + return asyncHttpClient.syncRequestWithSession(buildRequestParams()); + } + } - @Override - protected AsyncRequest buildRequestParams() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("did", sendMsg.getDid()); // - jsonObject.put("content", sendMsg.getContent().toSendMsg()); // - jsonObject.put("face", 546); // 这个其实没啥用 - jsonObject.put("clientid", ConstsParams.CLIENT_ID); - jsonObject.put("msg_id", msgId.incrementAndGet()); - jsonObject.put("psessionid", session.getPsessionid()); - Parameters params = new Parameters("r", jsonObject.toJSONString()); - Headers headers = new Headers("Referer", RequestUrls.referer_about_msg.url); - return new AsyncRequest(RequestUrls.send_discu_msg2.url, HttpMethod.post, params, headers); - } + @Override + protected AsyncRequest buildRequestParams() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("did", sendMsg.getDid()); // + jsonObject.put("content", sendMsg.getContent().toSendMsg()); // + jsonObject.put("face", 546); // 这个其实没啥用 + jsonObject.put("clientid", ConstsParams.CLIENT_ID); + jsonObject.put("msg_id", msgId.incrementAndGet()); + jsonObject.put("psessionid", session.getPsessionid()); + Parameters params = new Parameters("r", jsonObject.toJSONString()); + Headers headers = new Headers("Referer", RequestUrls.referer_about_msg.url); + return new AsyncRequest(RequestUrls.send_discu_msg2.url, HttpMethod.post, params, headers); + } } diff --git a/src/main/java/com/thankjava/wqq/core/request/api/SendQunMsg2.java b/src/main/java/com/thankjava/wqq/core/request/api/SendQunMsg2.java index d62df47..cf4ad79 100644 --- a/src/main/java/com/thankjava/wqq/core/request/api/SendQunMsg2.java +++ b/src/main/java/com/thankjava/wqq/core/request/api/SendQunMsg2.java @@ -1,49 +1,44 @@ package com.thankjava.wqq.core.request.api; -import com.thankjava.toolkit3d.http.async.consts.HttpMethod; -import com.thankjava.toolkit3d.http.async.entity.Headers; -import com.thankjava.toolkit3d.http.async.entity.Parameters; -import com.thankjava.toolkit3d.http.async.entity.AsyncResponse; -import com.thankjava.toolkit3d.http.async.entity.AsyncRequest; +import com.alibaba.fastjson.JSONObject; +import com.thankjava.toolkit3d.bean.http.*; import com.thankjava.wqq.consts.ConstsParams; import com.thankjava.wqq.consts.RequestUrls; import com.thankjava.wqq.entity.msg.SendMsg; -import com.thankjava.wqq.extend.CallBackListener; import com.thankjava.wqq.extend.ActionListener; - -import com.alibaba.fastjson.JSONObject; +import com.thankjava.wqq.extend.CallBackListener; public class SendQunMsg2 extends BaseHttpService { - private SendMsg sendMsg; - - public SendQunMsg2(SendMsg sendMsg) { - this.sendMsg = sendMsg; - } - - @Override - public AsyncResponse doRequest(CallBackListener listener) { - if(listener != null){ - ActionListener actionListener = new ActionListener(asyncHttpClient.syncRequestWithSession(buildRequestParams())); - listener.onListener(actionListener); - return null; - }else{ - return asyncHttpClient.syncRequestWithSession(buildRequestParams()); - } - } + private SendMsg sendMsg; + + public SendQunMsg2(SendMsg sendMsg) { + this.sendMsg = sendMsg; + } + + @Override + public AsyncResponse doRequest(CallBackListener listener) { + if (listener != null) { + ActionListener actionListener = new ActionListener(asyncHttpClient.syncRequestWithSession(buildRequestParams())); + listener.onListener(actionListener); + return null; + } else { + return asyncHttpClient.syncRequestWithSession(buildRequestParams()); + } + } - @Override - protected AsyncRequest buildRequestParams() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("group_uin", sendMsg.getGroupUin()); // - jsonObject.put("content", sendMsg.getContent().toSendMsg()); // - jsonObject.put("face", 546); // 这个其实没啥用 - jsonObject.put("clientid", ConstsParams.CLIENT_ID); - jsonObject.put("msg_id", msgId.incrementAndGet()); - jsonObject.put("psessionid", session.getPsessionid()); - Parameters params = new Parameters("r", jsonObject.toJSONString()); - Headers headers = new Headers("Referer", RequestUrls.referer_about_msg.url); - return new AsyncRequest(RequestUrls.send_qun_msg2.url, HttpMethod.post, params, headers); - } + @Override + protected AsyncRequest buildRequestParams() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("group_uin", sendMsg.getGroupUin()); // + jsonObject.put("content", sendMsg.getContent().toSendMsg()); // + jsonObject.put("face", 546); // 这个其实没啥用 + jsonObject.put("clientid", ConstsParams.CLIENT_ID); + jsonObject.put("msg_id", msgId.incrementAndGet()); + jsonObject.put("psessionid", session.getPsessionid()); + Parameters params = new Parameters("r", jsonObject.toJSONString()); + Headers headers = new Headers("Referer", RequestUrls.referer_about_msg.url); + return new AsyncRequest(RequestUrls.send_qun_msg2.url, HttpMethod.post, params, headers); + } } diff --git a/src/main/java/com/thankjava/wqq/entity/sys/MonitoringData.java b/src/main/java/com/thankjava/wqq/entity/sys/MonitoringData.java index 3fbeee4..3625896 100644 --- a/src/main/java/com/thankjava/wqq/entity/sys/MonitoringData.java +++ b/src/main/java/com/thankjava/wqq/entity/sys/MonitoringData.java @@ -2,7 +2,7 @@ import java.util.ArrayDeque; -import com.thankjava.toolkit.math.MathUtils; +import com.thankjava.toolkit.core.utils.MathUtil; import com.thankjava.wqq.consts.ConfigParams; public class MonitoringData { @@ -25,6 +25,6 @@ public double getAverageValueOfOneSecond() { long first = frequencyData.getFirst(); long last = frequencyData.getLast(); long timeSecond = (last - first) / 1000; - return MathUtils.divide(ConfigParams.MONITOR_THE_NUMBER_OF_DATA_SAMPLES, timeSecond, 0); + return MathUtil.divide(ConfigParams.MONITOR_THE_NUMBER_OF_DATA_SAMPLES, timeSecond, 0); } } diff --git a/src/main/java/com/thankjava/wqq/factory/RequestFactory.java b/src/main/java/com/thankjava/wqq/factory/RequestFactory.java index f96cbf3..f05f118 100644 --- a/src/main/java/com/thankjava/wqq/factory/RequestFactory.java +++ b/src/main/java/com/thankjava/wqq/factory/RequestFactory.java @@ -1,26 +1,27 @@ -package com.thankjava.wqq.factory; - -import java.util.HashMap; -import java.util.Map; - -import com.thankjava.wqq.core.request.RequestBuilder; - -import com.thankjava.toolkit3d.aop.core.AopProxyFactory; - -public class RequestFactory { - - private RequestFactory(){} - - private static final Map, RequestBuilder> instances = new HashMap<>(); - - public static RequestBuilder getInstance(Class requestClass){ - RequestBuilder baseFunction = instances.get(requestClass); - - if(baseFunction == null){ - baseFunction = (RequestBuilder) AopProxyFactory.createProxyObject(requestClass); - instances.put(requestClass, baseFunction); - } - - return baseFunction; - } -} +package com.thankjava.wqq.factory; + +import com.thankjava.toolkit3d.core.aop.CglibAopProxy; +import com.thankjava.wqq.core.request.RequestBuilder; + +import java.util.HashMap; +import java.util.Map; + + +public class RequestFactory { + + private static final Map, RequestBuilder> instances = new HashMap<>(); + + private RequestFactory() { + } + + public static RequestBuilder getInstance(Class requestClass) { + RequestBuilder baseFunction = instances.get(requestClass); + + if (baseFunction == null) { + baseFunction = (RequestBuilder) CglibAopProxy.createProxyObject(requestClass); + instances.put(requestClass, baseFunction); + } + + return baseFunction; + } +} diff --git a/src/main/java/com/thankjava/wqq/util/JSON2Entity.java b/src/main/java/com/thankjava/wqq/util/JSON2Entity.java index d989407..0dcb8de 100644 --- a/src/main/java/com/thankjava/wqq/util/JSON2Entity.java +++ b/src/main/java/com/thankjava/wqq/util/JSON2Entity.java @@ -1,314 +1,306 @@ -package com.thankjava.wqq.util; - -import java.util.HashMap; -import java.util.Map; - -import com.thankjava.wqq.entity.Session; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.thankjava.toolkit3d.fastjson.FastJson; -import com.thankjava.wqq.entity.msg.Content; -import com.thankjava.wqq.entity.msg.Font; -import com.thankjava.wqq.entity.msg.PollMsg; -import com.thankjava.wqq.entity.msg.Value; -import com.thankjava.wqq.entity.wqq.CategorieInfo; -import com.thankjava.wqq.entity.wqq.DetailedInfo; -import com.thankjava.wqq.entity.wqq.DiscuInfo; -import com.thankjava.wqq.entity.wqq.DiscusList; -import com.thankjava.wqq.entity.wqq.FriendInfo; -import com.thankjava.wqq.entity.wqq.FriendsList; -import com.thankjava.wqq.entity.wqq.GroupInfo; -import com.thankjava.wqq.entity.wqq.GroupsList; - -/** - * 用于解析腾讯返回json格式的数据 - *

Function: JSON2Entity

- *

Description:

- * - * @author acexy@thankjava.com - * @version 1.0 - * @date 2017年6月14日 下午2:27:34 - */ -public class JSON2Entity { - - private static Logger logger = LoggerFactory.getLogger(JSON2Entity.class); - - /** - * 解析所有好友信息 - *

Function: userFriend2

- *

Description:

- * - * @param content - * @return - * @author acexy@thankjava.com - * @date 2017年6月14日 下午2:33:31 - * @version 1.0 - */ - public static FriendsList userFriends2(String content) { - FriendsList friendsList = new FriendsList(); - JSONObject userFriends2Json; - try { - userFriends2Json = FastJson.toJSONObject(content); - JSONObject result = (JSONObject) userFriends2Json.get("result"); - Map categories = new HashMap<>(); - Map friendInfos = new HashMap<>(); - // 处理分组信息 - JSONArray array = (JSONArray) result.get("categories"); - CategorieInfo categorie; - Object[] objs = array.toArray(); - for (Object obj : objs) { - categorie = FastJson.toObject(obj.toString(), CategorieInfo.class); - categories.put(categorie.getIndex(), categorie); - } - // 设置默认分组 - if (categories.size() == 0) { - categorie = new CategorieInfo(); - categorie.setIndex(0); - categorie.setSort(1); - categorie.setName("默认分组"); - } - friendsList.setCategories(categories); - - // 处理好友信息 - FriendInfo friendInfo; - long uin = -1L; - - // 好友信息 - array = (JSONArray) result.get("info"); - objs = array.toArray(); - for (Object obj : objs) { - friendInfo = FastJson.toObject(obj.toString(), FriendInfo.class); - friendInfos.put(friendInfo.getUin(), friendInfo); - } - - // 备注名信息 - array = (JSONArray) result.get("marknames"); - objs = array.toArray(); - for (Object obj : objs) { - uin = ((JSONObject) obj).getLongValue("uin"); - friendInfo = friendInfos.get(uin); - friendInfo = FastJson.appendObject(obj.toString(), friendInfo); - } - - // 分组 - array = (JSONArray) result.get("friends"); - objs = array.toArray(); - for (Object obj : objs) { - uin = ((JSONObject) obj).getLongValue("uin"); - friendInfo = friendInfos.get(uin); - friendInfo = FastJson.appendObject(obj.toString(), friendInfo); - } - - // 会员信息 - array = (JSONArray) result.get("vipinfo"); - objs = array.toArray(); - for (Object obj : objs) { - uin = ((JSONObject) obj).getLongValue("u"); - friendInfo = friendInfos.get(uin); - friendInfo = FastJson.appendObject(obj.toString(), friendInfo); - } - friendsList.setFriendsInfo(friendInfos); - } catch (Exception e) { - logger.error("解析userFriends2返回数据失败", e); - return null; - } - - return friendsList; - } - - /** - * 解析好友在线状态 - *

Function: onlineStatus

- *

Description:

- * - * @param friendsList - * @param content - * @return - * @author acexy@thankjava.com - * @date 2017年6月14日 下午4:05:59 - * @version 1.0 - */ - public static FriendsList onlineStatus(FriendsList friendsList, String content) { - try { - Map friendsInfo = friendsList.getFriendsInfo(); - JSONObject onlineBuddiesJson = FastJson.toJSONObject(content); - JSONArray array = (JSONArray) onlineBuddiesJson.get("result"); - Object[] objs = array.toArray(); - Long uin = null; - FriendInfo friendInfo; - for (Object obj : objs) { - uin = ((JSONObject) obj).getLongValue("uin"); - friendInfo = friendsInfo.get(uin); - if (friendInfo != null) { - friendInfo = FastJson.appendObject(obj.toString(), friendInfo); - } - } - friendsList.setFriendsInfo(friendsInfo); - } catch (Exception e) { - logger.error("解析onlineStatus返回数据失败", e); - return null; - } - return friendsList; - } - - /** - * 解析讨论组信息 - *

Function: getDiscusList

- *

Description:

- * - * @param content - * @return - * @author acexy@thankjava.com - * @date 2017年6月14日 下午4:06:12 - * @version 1.0 - */ - public static DiscusList getDiscusList(String content) { - DiscusList discusList = new DiscusList(); - try { - JSONObject discusListJson = FastJson.toJSONObject(content); - JSONObject result = (JSONObject) discusListJson.get("result"); - - Map discuInfo = new HashMap(); - - JSONArray array = (JSONArray) result.get("dnamelist"); - DiscuInfo discu; - Object[] objs = array.toArray(); - for (Object obj : objs) { - discu = FastJson.toObject(obj.toString(), DiscuInfo.class); - discuInfo.put(discu.getDid(), discu); - } - discusList.setDiscus(discuInfo); - } catch (Exception e) { - logger.error("解析getDiscusList返回数据失败", e); - return null; - } - return discusList; - } - - /** - * 解析群信息 - *

Function: getGroupsList

- *

Description:

- * - * @param content - * @return - * @author acexy@thankjava.com - * @date 2017年6月14日 下午4:08:47 - * @version 1.0 - */ - public static GroupsList getGroupsList(String content) { - GroupsList groupsList = new GroupsList(); - try { - JSONObject groupsListJson = FastJson.toJSONObject(content); - JSONObject result = (JSONObject) groupsListJson.get("result"); - - Map groups = new HashMap(); - - // 群信息 - JSONArray array = (JSONArray) result.get("gnamelist"); - GroupInfo group; - long gid = -1; - Object[] objs = array.toArray(); - for (Object obj : objs) { - group = FastJson.toObject(obj.toString(), GroupInfo.class); - groups.put(group.getGid(), group); - } - // 备注信息 - array = (JSONArray) result.get("gmarklist"); - objs = array.toArray(); - for (Object obj : objs) { - gid = ((JSONObject) obj).getLongValue("uin"); - group = FastJson.appendObject(obj.toString(), groups.get(gid)); - } - groupsList.setGroups(groups); - } catch (Exception e) { - logger.error("解析getGroupsList返回数据失败", e); - return null; - } - return groupsList; - } - - /** - * 解析个人信息 - *

Function: getSelfInfo

- *

Description:

- * - * @param content - * @return - * @author acexy@thankjava.com - * @date 2017年6月14日 下午4:11:42 - * @version 1.0 - */ - public static DetailedInfo getSelfInfo(String content) { - try { - JSONObject discusListJson = FastJson.toJSONObject(content); - JSONObject result = (JSONObject) discusListJson.get("result"); - return FastJson.toObject(result.toJSONString(), DetailedInfo.class); - } catch (Exception e) { - logger.error("解析getSelfInfo返回数据失败", e); - } - return null; - } - - /** - * 消息拉取数据解析 - *

Function: parseToPollMsg

- *

Description:

- * - * @param content - * @return - * @author acexy@thankjava.com - * @date 2017年6月14日 下午4:21:38 - * @version 1.0 - */ - public static PollMsg pollMsg(String content) { - try { - JSONObject contentJson = FastJson.toJSONObject(content); - if (contentJson.getInteger("retcode") != 0) { - return null; - } - // 处理数据 - JSONArray array = (JSONArray) contentJson.get("result"); - JSONObject pollMsgJson = (JSONObject) array.get(0); - - - JSONObject valueJson = pollMsgJson.getJSONObject("value"); - - // 由于腾讯协议bug造成群消息&讨论组消息,会将自己发送的消息poll识别成别人的消息, - // 此处需要过滤 - if (Session.getSession().getUin() == valueJson.getLongValue("send_uin")) { - return null; - } - - JSONArray contentArray = valueJson.getJSONArray("content"); - - valueJson.remove("content"); - - PollMsg pollMsg = FastJson.toObject(array.get(0).toString(), PollMsg.class); - Value value = pollMsg.getValue(); - int contentSize = contentArray.size(); - Content contentMsg = new Content(); - value.setContent(contentMsg); - Font font = FastJson.toObject(contentArray.getJSONArray(0).get(1).toString(), Font.class); - contentMsg.setFont(font); - - Object[] objs = new Object[contentSize - 1]; - Object obj; - for (int index = 1; index < contentSize; index++) { - obj = contentArray.get(index); - if (JSONArray.class == obj.getClass()) { - objs[index - 1] = Integer.parseInt(((JSONArray) obj).get(1).toString()); - } else if (String.class == obj.getClass()) { - objs[index - 1] = obj.toString(); - } - } - contentMsg.setMsg(objs); - return pollMsg; - } catch (Exception e) { - return null; - } - } -} +package com.thankjava.wqq.util; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.thankjava.toolkit3d.core.fastjson.FastJson; +import com.thankjava.wqq.entity.Session; +import com.thankjava.wqq.entity.msg.Content; +import com.thankjava.wqq.entity.msg.Font; +import com.thankjava.wqq.entity.msg.PollMsg; +import com.thankjava.wqq.entity.msg.Value; +import com.thankjava.wqq.entity.wqq.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; +import java.util.Map; + +/** + * 用于解析腾讯返回json格式的数据 + *

Function: JSON2Entity

+ *

Description:

+ * + * @author acexy@thankjava.com + * @version 1.0 + * @date 2017年6月14日 下午2:27:34 + */ +public class JSON2Entity { + + private static Logger logger = LoggerFactory.getLogger(JSON2Entity.class); + + /** + * 解析所有好友信息 + *

Function: userFriend2

+ *

Description:

+ * + * @param content + * @return + * @author acexy@thankjava.com + * @date 2017年6月14日 下午2:33:31 + * @version 1.0 + */ + public static FriendsList userFriends2(String content) { + FriendsList friendsList = new FriendsList(); + JSONObject userFriends2Json; + try { + userFriends2Json = FastJson.toJSONObject(content); + JSONObject result = (JSONObject) userFriends2Json.get("result"); + Map categories = new HashMap<>(); + Map friendInfos = new HashMap<>(); + // 处理分组信息 + JSONArray array = (JSONArray) result.get("categories"); + CategorieInfo categorie; + Object[] objs = array.toArray(); + for (Object obj : objs) { + categorie = FastJson.toObject(obj.toString(), CategorieInfo.class); + categories.put(categorie.getIndex(), categorie); + } + // 设置默认分组 + if (categories.size() == 0) { + categorie = new CategorieInfo(); + categorie.setIndex(0); + categorie.setSort(1); + categorie.setName("默认分组"); + } + friendsList.setCategories(categories); + + // 处理好友信息 + FriendInfo friendInfo; + long uin = -1L; + + // 好友信息 + array = (JSONArray) result.get("info"); + objs = array.toArray(); + for (Object obj : objs) { + friendInfo = FastJson.toObject(obj.toString(), FriendInfo.class); + friendInfos.put(friendInfo.getUin(), friendInfo); + } + + // 备注名信息 + array = (JSONArray) result.get("marknames"); + objs = array.toArray(); + for (Object obj : objs) { + uin = ((JSONObject) obj).getLongValue("uin"); + friendInfo = friendInfos.get(uin); + friendInfo = FastJson.appendObject(obj.toString(), friendInfo); + } + + // 分组 + array = (JSONArray) result.get("friends"); + objs = array.toArray(); + for (Object obj : objs) { + uin = ((JSONObject) obj).getLongValue("uin"); + friendInfo = friendInfos.get(uin); + friendInfo = FastJson.appendObject(obj.toString(), friendInfo); + } + + // 会员信息 + array = (JSONArray) result.get("vipinfo"); + objs = array.toArray(); + for (Object obj : objs) { + uin = ((JSONObject) obj).getLongValue("u"); + friendInfo = friendInfos.get(uin); + friendInfo = FastJson.appendObject(obj.toString(), friendInfo); + } + friendsList.setFriendsInfo(friendInfos); + } catch (Exception e) { + logger.error("解析userFriends2返回数据失败", e); + return null; + } + + return friendsList; + } + + /** + * 解析好友在线状态 + *

Function: onlineStatus

+ *

Description:

+ * + * @param friendsList + * @param content + * @return + * @author acexy@thankjava.com + * @date 2017年6月14日 下午4:05:59 + * @version 1.0 + */ + public static FriendsList onlineStatus(FriendsList friendsList, String content) { + try { + Map friendsInfo = friendsList.getFriendsInfo(); + JSONObject onlineBuddiesJson = FastJson.toJSONObject(content); + JSONArray array = (JSONArray) onlineBuddiesJson.get("result"); + Object[] objs = array.toArray(); + Long uin = null; + FriendInfo friendInfo; + for (Object obj : objs) { + uin = ((JSONObject) obj).getLongValue("uin"); + friendInfo = friendsInfo.get(uin); + if (friendInfo != null) { + friendInfo = FastJson.appendObject(obj.toString(), friendInfo); + } + } + friendsList.setFriendsInfo(friendsInfo); + } catch (Exception e) { + logger.error("解析onlineStatus返回数据失败", e); + return null; + } + return friendsList; + } + + /** + * 解析讨论组信息 + *

Function: getDiscusList

+ *

Description:

+ * + * @param content + * @return + * @author acexy@thankjava.com + * @date 2017年6月14日 下午4:06:12 + * @version 1.0 + */ + public static DiscusList getDiscusList(String content) { + DiscusList discusList = new DiscusList(); + try { + JSONObject discusListJson = FastJson.toJSONObject(content); + JSONObject result = (JSONObject) discusListJson.get("result"); + + Map discuInfo = new HashMap(); + + JSONArray array = (JSONArray) result.get("dnamelist"); + DiscuInfo discu; + Object[] objs = array.toArray(); + for (Object obj : objs) { + discu = FastJson.toObject(obj.toString(), DiscuInfo.class); + discuInfo.put(discu.getDid(), discu); + } + discusList.setDiscus(discuInfo); + } catch (Exception e) { + logger.error("解析getDiscusList返回数据失败", e); + return null; + } + return discusList; + } + + /** + * 解析群信息 + *

Function: getGroupsList

+ *

Description:

+ * + * @param content + * @return + * @author acexy@thankjava.com + * @date 2017年6月14日 下午4:08:47 + * @version 1.0 + */ + public static GroupsList getGroupsList(String content) { + GroupsList groupsList = new GroupsList(); + try { + JSONObject groupsListJson = FastJson.toJSONObject(content); + JSONObject result = (JSONObject) groupsListJson.get("result"); + + Map groups = new HashMap(); + + // 群信息 + JSONArray array = (JSONArray) result.get("gnamelist"); + GroupInfo group; + long gid = -1; + Object[] objs = array.toArray(); + for (Object obj : objs) { + group = FastJson.toObject(obj.toString(), GroupInfo.class); + groups.put(group.getGid(), group); + } + // 备注信息 + array = (JSONArray) result.get("gmarklist"); + objs = array.toArray(); + for (Object obj : objs) { + gid = ((JSONObject) obj).getLongValue("uin"); + group = FastJson.appendObject(obj.toString(), groups.get(gid)); + } + groupsList.setGroups(groups); + } catch (Exception e) { + logger.error("解析getGroupsList返回数据失败", e); + return null; + } + return groupsList; + } + + /** + * 解析个人信息 + *

Function: getSelfInfo

+ *

Description:

+ * + * @param content + * @return + * @author acexy@thankjava.com + * @date 2017年6月14日 下午4:11:42 + * @version 1.0 + */ + public static DetailedInfo getSelfInfo(String content) { + try { + JSONObject discusListJson = FastJson.toJSONObject(content); + JSONObject result = (JSONObject) discusListJson.get("result"); + return FastJson.toObject(result.toJSONString(), DetailedInfo.class); + } catch (Exception e) { + logger.error("解析getSelfInfo返回数据失败", e); + } + return null; + } + + /** + * 消息拉取数据解析 + *

Function: parseToPollMsg

+ *

Description:

+ * + * @param content + * @return + * @author acexy@thankjava.com + * @date 2017年6月14日 下午4:21:38 + * @version 1.0 + */ + public static PollMsg pollMsg(String content) { + try { + JSONObject contentJson = FastJson.toJSONObject(content); + if (contentJson.getInteger("retcode") != 0) { + return null; + } + // 处理数据 + JSONArray array = (JSONArray) contentJson.get("result"); + JSONObject pollMsgJson = (JSONObject) array.get(0); + + + JSONObject valueJson = pollMsgJson.getJSONObject("value"); + + // 由于腾讯协议bug造成群消息&讨论组消息,会将自己发送的消息poll识别成别人的消息, + // 此处需要过滤 + if (Session.getSession().getUin() == valueJson.getLongValue("send_uin")) { + return null; + } + + JSONArray contentArray = valueJson.getJSONArray("content"); + + valueJson.remove("content"); + + PollMsg pollMsg = FastJson.toObject(array.get(0).toString(), PollMsg.class); + Value value = pollMsg.getValue(); + int contentSize = contentArray.size(); + Content contentMsg = new Content(); + value.setContent(contentMsg); + Font font = FastJson.toObject(contentArray.getJSONArray(0).get(1).toString(), Font.class); + contentMsg.setFont(font); + + Object[] objs = new Object[contentSize - 1]; + Object obj; + for (int index = 1; index < contentSize; index++) { + obj = contentArray.get(index); + if (JSONArray.class == obj.getClass()) { + objs[index - 1] = Integer.parseInt(((JSONArray) obj).get(1).toString()); + } else if (String.class == obj.getClass()) { + objs[index - 1] = obj.toString(); + } + } + contentMsg.setMsg(objs); + return pollMsg; + } catch (Exception e) { + return null; + } + } +} diff --git a/src/main/java/com/thankjava/wqq/util/WqqEncryptor.java b/src/main/java/com/thankjava/wqq/util/WqqEncryptor.java index 50d5c19..ac480ae 100644 --- a/src/main/java/com/thankjava/wqq/util/WqqEncryptor.java +++ b/src/main/java/com/thankjava/wqq/util/WqqEncryptor.java @@ -1,14 +1,14 @@ package com.thankjava.wqq.util; -import javax.script.Invocable; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; - +import com.thankjava.toolkit.core.utils.SourceLoaderUtil; +import com.thankjava.wqq.core.action.LoginAction; import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.thankjava.toolkit.resource.SourceLoader; -import com.thankjava.wqq.core.action.LoginAction; + +import javax.script.Invocable; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; public class WqqEncryptor { @@ -29,7 +29,7 @@ public class WqqEncryptor { public static String hash(String uin, String ptwebqq) { try { - String jsSource = IOUtils.toString(SourceLoader.getResourceAsInputStream("hash.js"), "utf-8"); + String jsSource = IOUtils.toString(SourceLoaderUtil.getResourceAsInputStream("hash.js"), "utf-8"); ScriptEngineManager scriptEMgr = new ScriptEngineManager(); ScriptEngine engine = scriptEMgr.getEngineByMimeType("application/javascript"); engine.eval(jsSource);