mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
code clean up for cp module
This commit is contained in:
@@ -7,8 +7,8 @@ import java.io.File;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信客户端配置存储
|
* 微信客户端配置存储
|
||||||
* @author Daniel Qian
|
|
||||||
*
|
*
|
||||||
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
public interface WxCpConfigStorage {
|
public interface WxCpConfigStorage {
|
||||||
|
|
||||||
@@ -36,6 +36,7 @@ public interface WxCpConfigStorage {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 应该是线程安全的
|
* 应该是线程安全的
|
||||||
|
*
|
||||||
* @param jsapiTicket
|
* @param jsapiTicket
|
||||||
*/
|
*/
|
||||||
void updateJsapiTicket(String jsapiTicket, int expiresInSeconds);
|
void updateJsapiTicket(String jsapiTicket, int expiresInSeconds);
|
||||||
@@ -66,6 +67,7 @@ public interface WxCpConfigStorage {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* http client builder
|
* http client builder
|
||||||
|
*
|
||||||
* @return ApacheHttpClientBuilder
|
* @return ApacheHttpClientBuilder
|
||||||
*/
|
*/
|
||||||
ApacheHttpClientBuilder getApacheHttpClientBuilder();
|
ApacheHttpClientBuilder getApacheHttpClientBuilder();
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import java.io.File;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 基于内存的微信配置provider,在实际生产环境中应该将这些配置持久化
|
* 基于内存的微信配置provider,在实际生产环境中应该将这些配置持久化
|
||||||
* @author Daniel Qian
|
|
||||||
*
|
*
|
||||||
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
public class WxCpInMemoryConfigStorage implements WxCpConfigStorage {
|
public class WxCpInMemoryConfigStorage implements WxCpConfigStorage {
|
||||||
|
|
||||||
@@ -39,6 +39,10 @@ public class WxCpInMemoryConfigStorage implements WxCpConfigStorage {
|
|||||||
return this.accessToken;
|
return this.accessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAccessToken(String accessToken) {
|
||||||
|
this.accessToken = accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isAccessTokenExpired() {
|
public boolean isAccessTokenExpired() {
|
||||||
return System.currentTimeMillis() > this.expiresTime;
|
return System.currentTimeMillis() > this.expiresTime;
|
||||||
}
|
}
|
||||||
@@ -91,30 +95,34 @@ public class WxCpInMemoryConfigStorage implements WxCpConfigStorage {
|
|||||||
return this.corpId;
|
return this.corpId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCorpSecret() {
|
|
||||||
return this.corpSecret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getToken() {
|
|
||||||
return this.token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getExpiresTime() {
|
|
||||||
return this.expiresTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCorpId(String corpId) {
|
public void setCorpId(String corpId) {
|
||||||
this.corpId = corpId;
|
this.corpId = corpId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCorpSecret() {
|
||||||
|
return this.corpSecret;
|
||||||
|
}
|
||||||
|
|
||||||
public void setCorpSecret(String corpSecret) {
|
public void setCorpSecret(String corpSecret) {
|
||||||
this.corpSecret = corpSecret;
|
this.corpSecret = corpSecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getToken() {
|
||||||
|
return this.token;
|
||||||
|
}
|
||||||
|
|
||||||
public void setToken(String token) {
|
public void setToken(String token) {
|
||||||
this.token = token;
|
this.token = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getExpiresTime() {
|
||||||
|
return this.expiresTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpiresTime(long expiresTime) {
|
||||||
|
this.expiresTime = expiresTime;
|
||||||
|
}
|
||||||
|
|
||||||
public String getAesKey() {
|
public String getAesKey() {
|
||||||
return aesKey;
|
return aesKey;
|
||||||
}
|
}
|
||||||
@@ -123,14 +131,6 @@ public class WxCpInMemoryConfigStorage implements WxCpConfigStorage {
|
|||||||
this.aesKey = aesKey;
|
this.aesKey = aesKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAccessToken(String accessToken) {
|
|
||||||
this.accessToken = accessToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExpiresTime(long expiresTime) {
|
|
||||||
this.expiresTime = expiresTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAgentId() {
|
public String getAgentId() {
|
||||||
return agentId;
|
return agentId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package me.chanjar.weixin.cp.api;
|
package me.chanjar.weixin.cp.api;
|
||||||
|
|
||||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||||
import me.chanjar.weixin.common.session.WxSession;
|
|
||||||
import me.chanjar.weixin.common.session.WxSessionManager;
|
import me.chanjar.weixin.common.session.WxSessionManager;
|
||||||
import me.chanjar.weixin.cp.bean.WxCpXmlMessage;
|
import me.chanjar.weixin.cp.bean.WxCpXmlMessage;
|
||||||
import me.chanjar.weixin.cp.bean.WxCpXmlOutMessage;
|
import me.chanjar.weixin.cp.bean.WxCpXmlOutMessage;
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package me.chanjar.weixin.cp.api;
|
package me.chanjar.weixin.cp.api;
|
||||||
|
|
||||||
|
import me.chanjar.weixin.common.api.WxErrorExceptionHandler;
|
||||||
|
import me.chanjar.weixin.common.api.WxMessageDuplicateChecker;
|
||||||
|
import me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateChecker;
|
||||||
import me.chanjar.weixin.common.session.InternalSession;
|
import me.chanjar.weixin.common.session.InternalSession;
|
||||||
import me.chanjar.weixin.common.session.InternalSessionManager;
|
import me.chanjar.weixin.common.session.InternalSessionManager;
|
||||||
import me.chanjar.weixin.common.session.StandardSessionManager;
|
import me.chanjar.weixin.common.session.StandardSessionManager;
|
||||||
import me.chanjar.weixin.common.session.WxSessionManager;
|
import me.chanjar.weixin.common.session.WxSessionManager;
|
||||||
import me.chanjar.weixin.common.util.LogExceptionHandler;
|
import me.chanjar.weixin.common.util.LogExceptionHandler;
|
||||||
import me.chanjar.weixin.common.api.WxErrorExceptionHandler;
|
|
||||||
import me.chanjar.weixin.common.api.WxMessageDuplicateChecker;
|
|
||||||
import me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateChecker;
|
|
||||||
import me.chanjar.weixin.cp.bean.WxCpXmlMessage;
|
import me.chanjar.weixin.cp.bean.WxCpXmlMessage;
|
||||||
import me.chanjar.weixin.cp.bean.WxCpXmlOutMessage;
|
import me.chanjar.weixin.cp.bean.WxCpXmlOutMessage;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -45,15 +45,13 @@ import java.util.concurrent.Future;
|
|||||||
* router.route(message);
|
* router.route(message);
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
* @author Daniel Qian
|
|
||||||
*
|
*
|
||||||
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
public class WxCpMessageRouter {
|
public class WxCpMessageRouter {
|
||||||
|
|
||||||
protected final Logger log = LoggerFactory.getLogger(WxCpMessageRouter.class);
|
|
||||||
|
|
||||||
private static final int DEFAULT_THREAD_POOL_SIZE = 100;
|
private static final int DEFAULT_THREAD_POOL_SIZE = 100;
|
||||||
|
protected final Logger log = LoggerFactory.getLogger(WxCpMessageRouter.class);
|
||||||
private final List<WxCpMessageRouterRule> rules = new ArrayList<WxCpMessageRouterRule>();
|
private final List<WxCpMessageRouterRule> rules = new ArrayList<WxCpMessageRouterRule>();
|
||||||
|
|
||||||
private final WxCpService wxCpService;
|
private final WxCpService wxCpService;
|
||||||
@@ -79,6 +77,7 @@ public class WxCpMessageRouter {
|
|||||||
* 设置自定义的 {@link ExecutorService}
|
* 设置自定义的 {@link ExecutorService}
|
||||||
* 如果不调用该方法,默认使用 Executors.newFixedThreadPool(100)
|
* 如果不调用该方法,默认使用 Executors.newFixedThreadPool(100)
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
* @param executorService
|
* @param executorService
|
||||||
*/
|
*/
|
||||||
public void setExecutorService(ExecutorService executorService) {
|
public void setExecutorService(ExecutorService executorService) {
|
||||||
@@ -90,6 +89,7 @@ public class WxCpMessageRouter {
|
|||||||
* 设置自定义的 {@link me.chanjar.weixin.common.api.WxMessageDuplicateChecker}
|
* 设置自定义的 {@link me.chanjar.weixin.common.api.WxMessageDuplicateChecker}
|
||||||
* 如果不调用该方法,默认使用 {@link me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateChecker}
|
* 如果不调用该方法,默认使用 {@link me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateChecker}
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
* @param messageDuplicateChecker
|
* @param messageDuplicateChecker
|
||||||
*/
|
*/
|
||||||
public void setMessageDuplicateChecker(WxMessageDuplicateChecker messageDuplicateChecker) {
|
public void setMessageDuplicateChecker(WxMessageDuplicateChecker messageDuplicateChecker) {
|
||||||
@@ -101,6 +101,7 @@ public class WxCpMessageRouter {
|
|||||||
* 设置自定义的{@link me.chanjar.weixin.common.session.WxSessionManager}
|
* 设置自定义的{@link me.chanjar.weixin.common.session.WxSessionManager}
|
||||||
* 如果不调用该方法,默认使用 {@link me.chanjar.weixin.common.session.StandardSessionManager}
|
* 如果不调用该方法,默认使用 {@link me.chanjar.weixin.common.session.StandardSessionManager}
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
* @param sessionManager
|
* @param sessionManager
|
||||||
*/
|
*/
|
||||||
public void setSessionManager(WxSessionManager sessionManager) {
|
public void setSessionManager(WxSessionManager sessionManager) {
|
||||||
@@ -112,6 +113,7 @@ public class WxCpMessageRouter {
|
|||||||
* 设置自定义的{@link me.chanjar.weixin.common.api.WxErrorExceptionHandler}
|
* 设置自定义的{@link me.chanjar.weixin.common.api.WxErrorExceptionHandler}
|
||||||
* 如果不调用该方法,默认使用 {@link me.chanjar.weixin.common.util.LogExceptionHandler}
|
* 如果不调用该方法,默认使用 {@link me.chanjar.weixin.common.util.LogExceptionHandler}
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
* @param exceptionHandler
|
* @param exceptionHandler
|
||||||
*/
|
*/
|
||||||
public void setExceptionHandler(WxErrorExceptionHandler exceptionHandler) {
|
public void setExceptionHandler(WxErrorExceptionHandler exceptionHandler) {
|
||||||
@@ -131,6 +133,7 @@ public class WxCpMessageRouter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理微信消息
|
* 处理微信消息
|
||||||
|
*
|
||||||
* @param wxMessage
|
* @param wxMessage
|
||||||
*/
|
*/
|
||||||
public WxCpXmlOutMessage route(final WxCpXmlMessage wxMessage) {
|
public WxCpXmlOutMessage route(final WxCpXmlMessage wxMessage) {
|
||||||
@@ -216,6 +219,7 @@ public class WxCpMessageRouter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 对session的访问结束
|
* 对session的访问结束
|
||||||
|
*
|
||||||
* @param wxMessage
|
* @param wxMessage
|
||||||
*/
|
*/
|
||||||
protected void sessionEndAccess(WxCpXmlMessage wxMessage) {
|
protected void sessionEndAccess(WxCpXmlMessage wxMessage) {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package me.chanjar.weixin.cp.api;
|
package me.chanjar.weixin.cp.api;
|
||||||
|
|
||||||
|
import me.chanjar.weixin.common.api.WxErrorExceptionHandler;
|
||||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||||
import me.chanjar.weixin.common.session.WxSessionManager;
|
import me.chanjar.weixin.common.session.WxSessionManager;
|
||||||
import me.chanjar.weixin.common.api.WxErrorExceptionHandler;
|
|
||||||
import me.chanjar.weixin.cp.bean.WxCpXmlMessage;
|
import me.chanjar.weixin.cp.bean.WxCpXmlMessage;
|
||||||
import me.chanjar.weixin.cp.bean.WxCpXmlOutMessage;
|
import me.chanjar.weixin.cp.bean.WxCpXmlOutMessage;
|
||||||
|
|
||||||
@@ -186,7 +186,6 @@ public class WxCpMessageRouterRule {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 规则结束,代表如果一个消息匹配该规则,那么它将不再会进入其他规则
|
* 规则结束,代表如果一个消息匹配该规则,那么它将不再会进入其他规则
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public WxCpMessageRouter end() {
|
public WxCpMessageRouter end() {
|
||||||
this.routerBuilder.getRules().add(this);
|
this.routerBuilder.getRules().add(this);
|
||||||
@@ -195,7 +194,6 @@ public class WxCpMessageRouterRule {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 规则结束,但是消息还会进入其他规则
|
* 规则结束,但是消息还会进入其他规则
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public WxCpMessageRouter next() {
|
public WxCpMessageRouter next() {
|
||||||
this.reEnter = true;
|
this.reEnter = true;
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
package me.chanjar.weixin.cp.api;
|
package me.chanjar.weixin.cp.api;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import me.chanjar.weixin.common.bean.WxJsapiSignature;
|
import me.chanjar.weixin.common.bean.WxJsapiSignature;
|
||||||
import me.chanjar.weixin.common.bean.menu.WxMenu;
|
import me.chanjar.weixin.common.bean.menu.WxMenu;
|
||||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
|
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
|
||||||
@@ -17,6 +12,11 @@ import me.chanjar.weixin.cp.bean.WxCpMessage;
|
|||||||
import me.chanjar.weixin.cp.bean.WxCpTag;
|
import me.chanjar.weixin.cp.bean.WxCpTag;
|
||||||
import me.chanjar.weixin.cp.bean.WxCpUser;
|
import me.chanjar.weixin.cp.bean.WxCpUser;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信API的Service
|
* 微信API的Service
|
||||||
*/
|
*/
|
||||||
@@ -47,8 +47,9 @@ public interface WxCpService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取access_token, 不强制刷新access_token
|
* 获取access_token, 不强制刷新access_token
|
||||||
* @see #getAccessToken(boolean)
|
*
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
|
* @see #getAccessToken(boolean)
|
||||||
*/
|
*/
|
||||||
String getAccessToken() throws WxErrorException;
|
String getAccessToken() throws WxErrorException;
|
||||||
|
|
||||||
@@ -60,6 +61,7 @@ public interface WxCpService {
|
|||||||
* 程序员在非必要情况下尽量不要主动调用此方法
|
* 程序员在非必要情况下尽量不要主动调用此方法
|
||||||
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=获取access_token
|
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=获取access_token
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
* @param forceRefresh 强制刷新
|
* @param forceRefresh 强制刷新
|
||||||
* @throws me.chanjar.weixin.common.exception.WxErrorException
|
* @throws me.chanjar.weixin.common.exception.WxErrorException
|
||||||
*/
|
*/
|
||||||
@@ -67,8 +69,9 @@ public interface WxCpService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得jsapi_ticket,不强制刷新jsapi_ticket
|
* 获得jsapi_ticket,不强制刷新jsapi_ticket
|
||||||
* @see #getJsapiTicket(boolean)
|
*
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
|
* @see #getJsapiTicket(boolean)
|
||||||
*/
|
*/
|
||||||
String getJsapiTicket() throws WxErrorException;
|
String getJsapiTicket() throws WxErrorException;
|
||||||
|
|
||||||
@@ -79,6 +82,7 @@ public interface WxCpService {
|
|||||||
*
|
*
|
||||||
* 详情请见:http://qydev.weixin.qq.com/wiki/index.php?title=微信JS接口#.E9.99.84.E5.BD.951-JS-SDK.E4.BD.BF.E7.94.A8.E6.9D.83.E9.99.90.E7.AD.BE.E5.90.8D.E7.AE.97.E6.B3.95
|
* 详情请见:http://qydev.weixin.qq.com/wiki/index.php?title=微信JS接口#.E9.99.84.E5.BD.951-JS-SDK.E4.BD.BF.E7.94.A8.E6.9D.83.E9.99.90.E7.AD.BE.E5.90.8D.E7.AE.97.E6.B3.95
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
* @param forceRefresh 强制刷新
|
* @param forceRefresh 强制刷新
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
*/
|
*/
|
||||||
@@ -90,6 +94,7 @@ public interface WxCpService {
|
|||||||
*
|
*
|
||||||
* 详情请见:http://qydev.weixin.qq.com/wiki/index.php?title=微信JS接口#.E9.99.84.E5.BD.951-JS-SDK.E4.BD.BF.E7.94.A8.E6.9D.83.E9.99.90.E7.AD.BE.E5.90.8D.E7.AE.97.E6.B3.95
|
* 详情请见:http://qydev.weixin.qq.com/wiki/index.php?title=微信JS接口#.E9.99.84.E5.BD.951-JS-SDK.E4.BD.BF.E7.94.A8.E6.9D.83.E9.99.90.E7.AD.BE.E5.90.8D.E7.AE.97.E6.B3.95
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
* @param url url
|
* @param url url
|
||||||
*/
|
*/
|
||||||
WxJsapiSignature createJsapiSignature(String url) throws WxErrorException;
|
WxJsapiSignature createJsapiSignature(String url) throws WxErrorException;
|
||||||
@@ -128,9 +133,9 @@ public interface WxCpService {
|
|||||||
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=上传下载多媒体文件
|
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=上传下载多媒体文件
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
* @param media_id
|
||||||
* @return 保存到本地的临时文件
|
* @return 保存到本地的临时文件
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
* @param media_id
|
|
||||||
*/
|
*/
|
||||||
File mediaDownload(String media_id) throws WxErrorException;
|
File mediaDownload(String media_id) throws WxErrorException;
|
||||||
|
|
||||||
@@ -152,10 +157,10 @@ public interface WxCpService {
|
|||||||
*
|
*
|
||||||
* 注意: 这个方法使用WxCpConfigStorage里的agentId
|
* 注意: 这个方法使用WxCpConfigStorage里的agentId
|
||||||
* </pre>
|
* </pre>
|
||||||
* @see #menuCreate(String, me.chanjar.weixin.common.bean.WxMenu)
|
|
||||||
*
|
*
|
||||||
* @param menu
|
* @param menu
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
|
* @see #menuCreate(String, me.chanjar.weixin.common.bean.WxMenu)
|
||||||
*/
|
*/
|
||||||
void menuCreate(WxMenu menu) throws WxErrorException;
|
void menuCreate(WxMenu menu) throws WxErrorException;
|
||||||
|
|
||||||
@@ -166,11 +171,11 @@ public interface WxCpService {
|
|||||||
*
|
*
|
||||||
* 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出
|
* 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出
|
||||||
* </pre>
|
* </pre>
|
||||||
* @see #menuCreate(me.chanjar.weixin.common.bean.WxMenu)
|
|
||||||
*
|
*
|
||||||
* @param agentId 企业号应用的id
|
* @param agentId 企业号应用的id
|
||||||
* @param menu
|
* @param menu
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
|
* @see #menuCreate(me.chanjar.weixin.common.bean.WxMenu)
|
||||||
*/
|
*/
|
||||||
void menuCreate(String agentId, WxMenu menu) throws WxErrorException;
|
void menuCreate(String agentId, WxMenu menu) throws WxErrorException;
|
||||||
|
|
||||||
@@ -181,9 +186,9 @@ public interface WxCpService {
|
|||||||
*
|
*
|
||||||
* 注意: 这个方法使用WxCpConfigStorage里的agentId
|
* 注意: 这个方法使用WxCpConfigStorage里的agentId
|
||||||
* </pre>
|
* </pre>
|
||||||
* @see #menuDelete(String)
|
|
||||||
*
|
*
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
|
* @see #menuDelete(String)
|
||||||
*/
|
*/
|
||||||
void menuDelete() throws WxErrorException;
|
void menuDelete() throws WxErrorException;
|
||||||
|
|
||||||
@@ -194,10 +199,10 @@ public interface WxCpService {
|
|||||||
*
|
*
|
||||||
* 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出
|
* 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出
|
||||||
* </pre>
|
* </pre>
|
||||||
* @see #menuDelete()
|
|
||||||
*
|
*
|
||||||
* @param agentId 企业号应用的id
|
* @param agentId 企业号应用的id
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
|
* @see #menuDelete()
|
||||||
*/
|
*/
|
||||||
void menuDelete(String agentId) throws WxErrorException;
|
void menuDelete(String agentId) throws WxErrorException;
|
||||||
|
|
||||||
@@ -208,9 +213,9 @@ public interface WxCpService {
|
|||||||
*
|
*
|
||||||
* 注意: 这个方法使用WxCpConfigStorage里的agentId
|
* 注意: 这个方法使用WxCpConfigStorage里的agentId
|
||||||
* </pre>
|
* </pre>
|
||||||
* @see #menuGet(String)
|
|
||||||
*
|
*
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
|
* @see #menuGet(String)
|
||||||
*/
|
*/
|
||||||
WxMenu menuGet() throws WxErrorException;
|
WxMenu menuGet() throws WxErrorException;
|
||||||
|
|
||||||
@@ -221,10 +226,10 @@ public interface WxCpService {
|
|||||||
*
|
*
|
||||||
* 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出
|
* 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出
|
||||||
* </pre>
|
* </pre>
|
||||||
* @see #menuGet()
|
|
||||||
*
|
*
|
||||||
* @param agentId 企业号应用的id
|
* @param agentId 企业号应用的id
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
|
* @see #menuGet()
|
||||||
*/
|
*/
|
||||||
WxMenu menuGet(String agentId) throws WxErrorException;
|
WxMenu menuGet(String agentId) throws WxErrorException;
|
||||||
|
|
||||||
@@ -279,6 +284,7 @@ public interface WxCpService {
|
|||||||
*
|
*
|
||||||
* http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E8.8E.B7.E5.8F.96.E9.83.A8.E9.97.A8.E6.88.90.E5.91.98.28.E8.AF.A6.E6.83.85.29
|
* http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E8.8E.B7.E5.8F.96.E9.83.A8.E9.97.A8.E6.88.90.E5.91.98.28.E8.AF.A6.E6.83.85.29
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
* @param departId 必填。部门id
|
* @param departId 必填。部门id
|
||||||
* @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员
|
* @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员
|
||||||
* @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加
|
* @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加
|
||||||
@@ -330,6 +336,7 @@ public interface WxCpService {
|
|||||||
*
|
*
|
||||||
* http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E6.89.B9.E9.87.8F.E5.88.A0.E9.99.A4.E6.88.90.E5.91.98
|
* http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E6.89.B9.E9.87.8F.E5.88.A0.E9.99.A4.E6.88.90.E5.91.98
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
* @param userids 员工UserID列表。对应管理端的帐号
|
* @param userids 员工UserID列表。对应管理端的帐号
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
*/
|
*/
|
||||||
@@ -367,7 +374,6 @@ public interface WxCpService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得标签列表
|
* 获得标签列表
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
List<WxCpTag> tagGet() throws WxErrorException;
|
List<WxCpTag> tagGet() throws WxErrorException;
|
||||||
|
|
||||||
@@ -391,6 +397,7 @@ public interface WxCpService {
|
|||||||
* 构造oauth2授权的url连接
|
* 构造oauth2授权的url连接
|
||||||
* 详情请见: http://qydev.weixin.qq.com/wiki/index.php?title=企业获取code
|
* 详情请见: http://qydev.weixin.qq.com/wiki/index.php?title=企业获取code
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
* @param redirectUri
|
* @param redirectUri
|
||||||
* @param state
|
* @param state
|
||||||
* @return url
|
* @return url
|
||||||
@@ -405,10 +412,10 @@ public interface WxCpService {
|
|||||||
*
|
*
|
||||||
* 注意: 这个方法使用WxCpConfigStorage里的agentId
|
* 注意: 这个方法使用WxCpConfigStorage里的agentId
|
||||||
* </pre>
|
* </pre>
|
||||||
* @see #oauth2getUserInfo(String, String)
|
|
||||||
*
|
*
|
||||||
* @param code
|
* @param code
|
||||||
* @return [userid, deviceid]
|
* @return [userid, deviceid]
|
||||||
|
* @see #oauth2getUserInfo(String, String)
|
||||||
*/
|
*/
|
||||||
String[] oauth2getUserInfo(String code) throws WxErrorException;
|
String[] oauth2getUserInfo(String code) throws WxErrorException;
|
||||||
|
|
||||||
@@ -420,11 +427,11 @@ public interface WxCpService {
|
|||||||
*
|
*
|
||||||
* 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出
|
* 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出
|
||||||
* </pre>
|
* </pre>
|
||||||
* @see #oauth2getUserInfo(String)
|
|
||||||
*
|
*
|
||||||
* @param agentId 企业号应用的id
|
* @param agentId 企业号应用的id
|
||||||
* @param code
|
* @param code
|
||||||
* @return [userid, deviceid]
|
* @return [userid, deviceid]
|
||||||
|
* @see #oauth2getUserInfo(String)
|
||||||
*/
|
*/
|
||||||
String[] oauth2getUserInfo(String agentId, String code) throws WxErrorException;
|
String[] oauth2getUserInfo(String agentId, String code) throws WxErrorException;
|
||||||
|
|
||||||
@@ -442,6 +449,7 @@ public interface WxCpService {
|
|||||||
* 邀请成员关注
|
* 邀请成员关注
|
||||||
* http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E9.82.80.E8.AF.B7.E6.88.90.E5.91.98.E5.85.B3.E6.B3.A8
|
* http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E9.82.80.E8.AF.B7.E6.88.90.E5.91.98.E5.85.B3.E6.B3.A8
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
* @param userId 用户的userid
|
* @param userId 用户的userid
|
||||||
* @param inviteTips 推送到微信上的提示语(只有认证号可以使用)。当使用微信推送时,该字段默认为“请关注XXX企业号”,邮件邀请时,该字段无效。
|
* @param inviteTips 推送到微信上的提示语(只有认证号可以使用)。当使用微信推送时,该字段默认为“请关注XXX企业号”,邮件邀请时,该字段无效。
|
||||||
* @return 1:微信邀请 2.邮件邀请
|
* @return 1:微信邀请 2.邮件邀请
|
||||||
@@ -454,6 +462,7 @@ public interface WxCpService {
|
|||||||
* 获取微信服务器的ip段
|
* 获取微信服务器的ip段
|
||||||
* http://qydev.weixin.qq.com/wiki/index.php?title=回调模式#.E8.8E.B7.E5.8F.96.E5.BE.AE.E4.BF.A1.E6.9C.8D.E5.8A.A1.E5.99.A8.E7.9A.84ip.E6.AE.B5
|
* http://qydev.weixin.qq.com/wiki/index.php?title=回调模式#.E8.8E.B7.E5.8F.96.E5.BE.AE.E4.BF.A1.E6.9C.8D.E5.8A.A1.E5.99.A8.E7.9A.84ip.E6.AE.B5
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
* @return { "ip_list": ["101.226.103.*", "101.226.62.*"] }
|
* @return { "ip_list": ["101.226.103.*", "101.226.62.*"] }
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
*/
|
*/
|
||||||
@@ -461,6 +470,7 @@ public interface WxCpService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求
|
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求
|
||||||
|
*
|
||||||
* @param url
|
* @param url
|
||||||
* @param queryParam
|
* @param queryParam
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
@@ -469,6 +479,7 @@ public interface WxCpService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求
|
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求
|
||||||
|
*
|
||||||
* @param url
|
* @param url
|
||||||
* @param postData
|
* @param postData
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
@@ -481,6 +492,7 @@ public interface WxCpService {
|
|||||||
* 比{@link #get}和{@link #post}方法更灵活,可以自己构造RequestExecutor用来处理不同的参数和不同的返回类型。
|
* 比{@link #get}和{@link #post}方法更灵活,可以自己构造RequestExecutor用来处理不同的参数和不同的返回类型。
|
||||||
* 可以参考,{@link me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor}的实现方法
|
* 可以参考,{@link me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor}的实现方法
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
* @param executor
|
* @param executor
|
||||||
* @param uri
|
* @param uri
|
||||||
* @param data
|
* @param data
|
||||||
@@ -502,6 +514,7 @@ public interface WxCpService {
|
|||||||
* 设置当微信系统响应系统繁忙时,要等待多少 retrySleepMillis(ms) * 2^(重试次数 - 1) 再发起重试
|
* 设置当微信系统响应系统繁忙时,要等待多少 retrySleepMillis(ms) * 2^(重试次数 - 1) 再发起重试
|
||||||
* 默认:1000ms
|
* 默认:1000ms
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
* @param retrySleepMillis
|
* @param retrySleepMillis
|
||||||
*/
|
*/
|
||||||
void setRetrySleepMillis(int retrySleepMillis);
|
void setRetrySleepMillis(int retrySleepMillis);
|
||||||
@@ -511,18 +524,21 @@ public interface WxCpService {
|
|||||||
* 设置当微信系统响应系统繁忙时,最大重试次数
|
* 设置当微信系统响应系统繁忙时,最大重试次数
|
||||||
* 默认:5次
|
* 默认:5次
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
* @param maxRetryTimes
|
* @param maxRetryTimes
|
||||||
*/
|
*/
|
||||||
void setMaxRetryTimes(int maxRetryTimes);
|
void setMaxRetryTimes(int maxRetryTimes);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取某个sessionId对应的session,如果sessionId没有对应的session,则新建一个并返回。
|
* 获取某个sessionId对应的session,如果sessionId没有对应的session,则新建一个并返回。
|
||||||
|
*
|
||||||
* @param id id可以为任意字符串,建议使用FromUserName作为id
|
* @param id id可以为任意字符串,建议使用FromUserName作为id
|
||||||
*/
|
*/
|
||||||
WxSession getSession(String id);
|
WxSession getSession(String id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取某个sessionId对应的session,如果sessionId没有对应的session,若create为true则新建一个,否则返回null。
|
* 获取某个sessionId对应的session,如果sessionId没有对应的session,若create为true则新建一个,否则返回null。
|
||||||
|
*
|
||||||
* @param id id可以为任意字符串,建议使用FromUserName作为id
|
* @param id id可以为任意字符串,建议使用FromUserName作为id
|
||||||
* @param create
|
* @param create
|
||||||
*/
|
*/
|
||||||
@@ -533,12 +549,14 @@ public interface WxCpService {
|
|||||||
* 设置WxSessionManager,只有当需要使用个性化的WxSessionManager的时候才需要调用此方法,
|
* 设置WxSessionManager,只有当需要使用个性化的WxSessionManager的时候才需要调用此方法,
|
||||||
* WxCpService默认使用的是{@link me.chanjar.weixin.common.session.StandardSessionManager}
|
* WxCpService默认使用的是{@link me.chanjar.weixin.common.session.StandardSessionManager}
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
* @param sessionManager
|
* @param sessionManager
|
||||||
*/
|
*/
|
||||||
void setSessionManager(WxSessionManager sessionManager);
|
void setSessionManager(WxSessionManager sessionManager);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传部门列表覆盖企业号上的部门信息
|
* 上传部门列表覆盖企业号上的部门信息
|
||||||
|
*
|
||||||
* @param mediaId
|
* @param mediaId
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
*/
|
*/
|
||||||
@@ -546,6 +564,7 @@ public interface WxCpService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传用户列表覆盖企业号上的用户信息
|
* 上传用户列表覆盖企业号上的用户信息
|
||||||
|
*
|
||||||
* @param mediaId
|
* @param mediaId
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
*/
|
*/
|
||||||
@@ -553,6 +572,7 @@ public interface WxCpService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取异步任务结果
|
* 获取异步任务结果
|
||||||
|
*
|
||||||
* @param joinId
|
* @param joinId
|
||||||
* @throws WxErrorException
|
* @throws WxErrorException
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,23 +1,5 @@
|
|||||||
package me.chanjar.weixin.cp.api;
|
package me.chanjar.weixin.cp.api;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.StringReader;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.apache.http.HttpHost;
|
|
||||||
import org.apache.http.client.ClientProtocolException;
|
|
||||||
import org.apache.http.client.config.RequestConfig;
|
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
||||||
import org.apache.http.client.methods.HttpGet;
|
|
||||||
import org.apache.http.impl.client.BasicResponseHandler;
|
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
@@ -25,7 +7,6 @@ import com.google.gson.JsonPrimitive;
|
|||||||
import com.google.gson.internal.Streams;
|
import com.google.gson.internal.Streams;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
|
|
||||||
import me.chanjar.weixin.common.bean.WxAccessToken;
|
import me.chanjar.weixin.common.bean.WxAccessToken;
|
||||||
import me.chanjar.weixin.common.bean.WxJsapiSignature;
|
import me.chanjar.weixin.common.bean.WxJsapiSignature;
|
||||||
import me.chanjar.weixin.common.bean.menu.WxMenu;
|
import me.chanjar.weixin.common.bean.menu.WxMenu;
|
||||||
@@ -39,20 +20,30 @@ import me.chanjar.weixin.common.util.RandomUtils;
|
|||||||
import me.chanjar.weixin.common.util.StringUtils;
|
import me.chanjar.weixin.common.util.StringUtils;
|
||||||
import me.chanjar.weixin.common.util.crypto.SHA1;
|
import me.chanjar.weixin.common.util.crypto.SHA1;
|
||||||
import me.chanjar.weixin.common.util.fs.FileUtils;
|
import me.chanjar.weixin.common.util.fs.FileUtils;
|
||||||
import me.chanjar.weixin.common.util.http.ApacheHttpClientBuilder;
|
import me.chanjar.weixin.common.util.http.*;
|
||||||
import me.chanjar.weixin.common.util.http.DefaultApacheHttpHttpClientBuilder;
|
|
||||||
import me.chanjar.weixin.common.util.http.MediaDownloadRequestExecutor;
|
|
||||||
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor;
|
|
||||||
import me.chanjar.weixin.common.util.http.RequestExecutor;
|
|
||||||
import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor;
|
|
||||||
import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor;
|
|
||||||
import me.chanjar.weixin.common.util.http.URIUtil;
|
|
||||||
import me.chanjar.weixin.common.util.json.GsonHelper;
|
import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||||
import me.chanjar.weixin.cp.bean.WxCpDepart;
|
import me.chanjar.weixin.cp.bean.WxCpDepart;
|
||||||
import me.chanjar.weixin.cp.bean.WxCpMessage;
|
import me.chanjar.weixin.cp.bean.WxCpMessage;
|
||||||
import me.chanjar.weixin.cp.bean.WxCpTag;
|
import me.chanjar.weixin.cp.bean.WxCpTag;
|
||||||
import me.chanjar.weixin.cp.bean.WxCpUser;
|
import me.chanjar.weixin.cp.bean.WxCpUser;
|
||||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||||
|
import org.apache.http.HttpHost;
|
||||||
|
import org.apache.http.client.ClientProtocolException;
|
||||||
|
import org.apache.http.client.config.RequestConfig;
|
||||||
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
|
import org.apache.http.client.methods.HttpGet;
|
||||||
|
import org.apache.http.impl.client.BasicResponseHandler;
|
||||||
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class WxCpServiceImpl implements WxCpService {
|
public class WxCpServiceImpl implements WxCpService {
|
||||||
|
|
||||||
@@ -73,17 +64,13 @@ public class WxCpServiceImpl implements WxCpService {
|
|||||||
protected CloseableHttpClient httpClient;
|
protected CloseableHttpClient httpClient;
|
||||||
|
|
||||||
protected HttpHost httpProxy;
|
protected HttpHost httpProxy;
|
||||||
|
|
||||||
private int retrySleepMillis = 1000;
|
|
||||||
|
|
||||||
private int maxRetryTimes = 5;
|
|
||||||
|
|
||||||
protected WxSessionManager sessionManager = new StandardSessionManager();
|
protected WxSessionManager sessionManager = new StandardSessionManager();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 临时文件目录
|
* 临时文件目录
|
||||||
*/
|
*/
|
||||||
protected File tmpDirFile;
|
protected File tmpDirFile;
|
||||||
|
private int retrySleepMillis = 1000;
|
||||||
|
private int maxRetryTimes = 5;
|
||||||
|
|
||||||
public boolean checkSignature(String msgSignature, String timestamp, String nonce, String data) {
|
public boolean checkSignature(String msgSignature, String timestamp, String nonce, String data) {
|
||||||
try {
|
try {
|
||||||
@@ -342,7 +329,8 @@ public class WxCpServiceImpl implements WxCpService {
|
|||||||
return WxCpGsonBuilder.INSTANCE.create()
|
return WxCpGsonBuilder.INSTANCE.create()
|
||||||
.fromJson(
|
.fromJson(
|
||||||
tmpJsonElement.getAsJsonObject().get("userlist"),
|
tmpJsonElement.getAsJsonObject().get("userlist"),
|
||||||
new TypeToken<List<WxCpUser>>() { }.getType()
|
new TypeToken<List<WxCpUser>>() {
|
||||||
|
}.getType()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,7 +352,8 @@ public class WxCpServiceImpl implements WxCpService {
|
|||||||
return WxCpGsonBuilder.INSTANCE.create()
|
return WxCpGsonBuilder.INSTANCE.create()
|
||||||
.fromJson(
|
.fromJson(
|
||||||
tmpJsonElement.getAsJsonObject().get("userlist"),
|
tmpJsonElement.getAsJsonObject().get("userlist"),
|
||||||
new TypeToken<List<WxCpUser>>() { }.getType()
|
new TypeToken<List<WxCpUser>>() {
|
||||||
|
}.getType()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,7 +403,8 @@ public class WxCpServiceImpl implements WxCpService {
|
|||||||
return WxCpGsonBuilder.INSTANCE.create()
|
return WxCpGsonBuilder.INSTANCE.create()
|
||||||
.fromJson(
|
.fromJson(
|
||||||
tmpJsonElement.getAsJsonObject().get("userlist"),
|
tmpJsonElement.getAsJsonObject().get("userlist"),
|
||||||
new TypeToken<List<WxCpUser>>() { }.getType()
|
new TypeToken<List<WxCpUser>>() {
|
||||||
|
}.getType()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,6 +570,7 @@ public class WxCpServiceImpl implements WxCpService {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CloseableHttpClient getHttpclient() {
|
protected CloseableHttpClient getHttpclient() {
|
||||||
return httpClient;
|
return httpClient;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ public class WxCpDepart implements Serializable {
|
|||||||
private Integer parentId;
|
private Integer parentId;
|
||||||
private Integer order;
|
private Integer order;
|
||||||
|
|
||||||
|
public static WxCpDepart fromJson(String json) {
|
||||||
|
return WxCpGsonBuilder.create().fromJson(json, WxCpDepart.class);
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -48,10 +52,6 @@ public class WxCpDepart implements Serializable {
|
|||||||
this.order = order;
|
this.order = order;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WxCpDepart fromJson(String json) {
|
|
||||||
return WxCpGsonBuilder.create().fromJson(json, WxCpDepart.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toJson() {
|
public String toJson() {
|
||||||
return WxCpGsonBuilder.create().toJson(this);
|
return WxCpGsonBuilder.create().toJson(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息
|
* 消息
|
||||||
* @author Daniel Qian
|
|
||||||
*
|
*
|
||||||
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
public class WxCpMessage implements Serializable {
|
public class WxCpMessage implements Serializable {
|
||||||
|
|
||||||
@@ -29,151 +29,6 @@ public class WxCpMessage implements Serializable {
|
|||||||
private String safe;
|
private String safe;
|
||||||
private List<WxArticle> articles = new ArrayList<WxArticle>();
|
private List<WxArticle> articles = new ArrayList<WxArticle>();
|
||||||
|
|
||||||
public String getToUser() {
|
|
||||||
return toUser;
|
|
||||||
}
|
|
||||||
public void setToUser(String toUser) {
|
|
||||||
this.toUser = toUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getToParty() {
|
|
||||||
return toParty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setToParty(String toParty) {
|
|
||||||
this.toParty = toParty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getToTag() {
|
|
||||||
return toTag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setToTag(String toTag) {
|
|
||||||
this.toTag = toTag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAgentId() {
|
|
||||||
return agentId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAgentId(String agentId) {
|
|
||||||
this.agentId = agentId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMsgType() {
|
|
||||||
return msgType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSafe() {
|
|
||||||
return safe;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSafe(String safe) {
|
|
||||||
this.safe = safe;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* 请使用
|
|
||||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_TEXT}
|
|
||||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_IMAGE}
|
|
||||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VOICE}
|
|
||||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_MUSIC}
|
|
||||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VIDEO}
|
|
||||||
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_NEWS}
|
|
||||||
* </pre>
|
|
||||||
* @param msgType
|
|
||||||
*/
|
|
||||||
public void setMsgType(String msgType) {
|
|
||||||
this.msgType = msgType;
|
|
||||||
}
|
|
||||||
public String getContent() {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
public void setContent(String content) {
|
|
||||||
this.content = content;
|
|
||||||
}
|
|
||||||
public String getMediaId() {
|
|
||||||
return mediaId;
|
|
||||||
}
|
|
||||||
public void setMediaId(String mediaId) {
|
|
||||||
this.mediaId = mediaId;
|
|
||||||
}
|
|
||||||
public String getThumbMediaId() {
|
|
||||||
return thumbMediaId;
|
|
||||||
}
|
|
||||||
public void setThumbMediaId(String thumbMediaId) {
|
|
||||||
this.thumbMediaId = thumbMediaId;
|
|
||||||
}
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
public String getMusicUrl() {
|
|
||||||
return musicUrl;
|
|
||||||
}
|
|
||||||
public void setMusicUrl(String musicUrl) {
|
|
||||||
this.musicUrl = musicUrl;
|
|
||||||
}
|
|
||||||
public String getHqMusicUrl() {
|
|
||||||
return hqMusicUrl;
|
|
||||||
}
|
|
||||||
public void setHqMusicUrl(String hqMusicUrl) {
|
|
||||||
this.hqMusicUrl = hqMusicUrl;
|
|
||||||
}
|
|
||||||
public List<WxArticle> getArticles() {
|
|
||||||
return articles;
|
|
||||||
}
|
|
||||||
public void setArticles(List<WxArticle> articles) {
|
|
||||||
this.articles = articles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toJson() {
|
|
||||||
return WxCpGsonBuilder.INSTANCE.create().toJson(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class WxArticle {
|
|
||||||
|
|
||||||
private String title;
|
|
||||||
private String description;
|
|
||||||
private String url;
|
|
||||||
private String picUrl;
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
public String getUrl() {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
public void setUrl(String url) {
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
public String getPicUrl() {
|
|
||||||
return picUrl;
|
|
||||||
}
|
|
||||||
public void setPicUrl(String picUrl) {
|
|
||||||
this.picUrl = picUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得文本消息builder
|
* 获得文本消息builder
|
||||||
*/
|
*/
|
||||||
@@ -216,4 +71,174 @@ public class WxCpMessage implements Serializable {
|
|||||||
return new FileBuilder();
|
return new FileBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getToUser() {
|
||||||
|
return toUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToUser(String toUser) {
|
||||||
|
this.toUser = toUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToParty() {
|
||||||
|
return toParty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToParty(String toParty) {
|
||||||
|
this.toParty = toParty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToTag() {
|
||||||
|
return toTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToTag(String toTag) {
|
||||||
|
this.toTag = toTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAgentId() {
|
||||||
|
return agentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAgentId(String agentId) {
|
||||||
|
this.agentId = agentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsgType() {
|
||||||
|
return msgType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 请使用
|
||||||
|
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_TEXT}
|
||||||
|
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_IMAGE}
|
||||||
|
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VOICE}
|
||||||
|
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_MUSIC}
|
||||||
|
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VIDEO}
|
||||||
|
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_NEWS}
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param msgType
|
||||||
|
*/
|
||||||
|
public void setMsgType(String msgType) {
|
||||||
|
this.msgType = msgType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSafe() {
|
||||||
|
return safe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSafe(String safe) {
|
||||||
|
this.safe = safe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMediaId() {
|
||||||
|
return mediaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMediaId(String mediaId) {
|
||||||
|
this.mediaId = mediaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getThumbMediaId() {
|
||||||
|
return thumbMediaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setThumbMediaId(String thumbMediaId) {
|
||||||
|
this.thumbMediaId = thumbMediaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMusicUrl() {
|
||||||
|
return musicUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMusicUrl(String musicUrl) {
|
||||||
|
this.musicUrl = musicUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHqMusicUrl() {
|
||||||
|
return hqMusicUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHqMusicUrl(String hqMusicUrl) {
|
||||||
|
this.hqMusicUrl = hqMusicUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<WxArticle> getArticles() {
|
||||||
|
return articles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArticles(List<WxArticle> articles) {
|
||||||
|
this.articles = articles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toJson() {
|
||||||
|
return WxCpGsonBuilder.INSTANCE.create().toJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class WxArticle {
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
private String description;
|
||||||
|
private String url;
|
||||||
|
private String picUrl;
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPicUrl() {
|
||||||
|
return picUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPicUrl(String picUrl) {
|
||||||
|
this.picUrl = picUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ public class WxCpTag implements Serializable {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static WxCpTag fromJson(String json) {
|
||||||
|
return WxCpGsonBuilder.create().fromJson(json, WxCpTag.class);
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@@ -39,10 +43,6 @@ public class WxCpTag implements Serializable {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WxCpTag fromJson(String json) {
|
|
||||||
return WxCpGsonBuilder.create().fromJson(json, WxCpTag.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toJson() {
|
public String toJson() {
|
||||||
return WxCpGsonBuilder.create().toJson(this);
|
return WxCpGsonBuilder.create().toJson(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class WxCpUser implements Serializable {
|
public class WxCpUser implements Serializable {
|
||||||
|
|
||||||
|
private final List<Attr> extAttrs = new ArrayList<Attr>();
|
||||||
private String userId;
|
private String userId;
|
||||||
private String name;
|
private String name;
|
||||||
private Integer[] departIds;
|
private Integer[] departIds;
|
||||||
@@ -25,7 +26,10 @@ public class WxCpUser implements Serializable {
|
|||||||
private String avatar;
|
private String avatar;
|
||||||
private Integer status;
|
private Integer status;
|
||||||
private Integer enable;
|
private Integer enable;
|
||||||
private final List<Attr> extAttrs = new ArrayList<Attr>();
|
|
||||||
|
public static WxCpUser fromJson(String json) {
|
||||||
|
return WxCpGsonBuilder.INSTANCE.create().fromJson(json, WxCpUser.class);
|
||||||
|
}
|
||||||
|
|
||||||
public String getUserId() {
|
public String getUserId() {
|
||||||
return userId;
|
return userId;
|
||||||
@@ -135,10 +139,6 @@ public class WxCpUser implements Serializable {
|
|||||||
return WxCpGsonBuilder.INSTANCE.create().toJson(this);
|
return WxCpGsonBuilder.INSTANCE.create().toJson(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WxCpUser fromJson(String json) {
|
|
||||||
return WxCpGsonBuilder.INSTANCE.create().fromJson(json, WxCpUser.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Attr {
|
public static class Attr {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|||||||
@@ -162,6 +162,43 @@ public class WxCpXmlMessage implements Serializable {
|
|||||||
@XStreamAlias("SendLocationInfo")
|
@XStreamAlias("SendLocationInfo")
|
||||||
private SendLocationInfo sendLocationInfo = new SendLocationInfo();
|
private SendLocationInfo sendLocationInfo = new SendLocationInfo();
|
||||||
|
|
||||||
|
protected static WxCpXmlMessage fromXml(String xml) {
|
||||||
|
return XStreamTransformer.fromXml(WxCpXmlMessage.class, xml);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static WxCpXmlMessage fromXml(InputStream is) {
|
||||||
|
return XStreamTransformer.fromXml(WxCpXmlMessage.class, is);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从加密字符串转换
|
||||||
|
*
|
||||||
|
* @param encryptedXml
|
||||||
|
* @param wxCpConfigStorage
|
||||||
|
* @param timestamp
|
||||||
|
* @param nonce
|
||||||
|
* @param msgSignature
|
||||||
|
*/
|
||||||
|
public static WxCpXmlMessage fromEncryptedXml(
|
||||||
|
String encryptedXml,
|
||||||
|
WxCpConfigStorage wxCpConfigStorage,
|
||||||
|
String timestamp, String nonce, String msgSignature) {
|
||||||
|
WxCpCryptUtil cryptUtil = new WxCpCryptUtil(wxCpConfigStorage);
|
||||||
|
String plainText = cryptUtil.decrypt(msgSignature, timestamp, nonce, encryptedXml);
|
||||||
|
return fromXml(plainText);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WxCpXmlMessage fromEncryptedXml(
|
||||||
|
InputStream is,
|
||||||
|
WxCpConfigStorage wxCpConfigStorage,
|
||||||
|
String timestamp, String nonce, String msgSignature) {
|
||||||
|
try {
|
||||||
|
return fromEncryptedXml(IOUtils.toString(is, "UTF-8"), wxCpConfigStorage, timestamp, nonce, msgSignature);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getAgentId() {
|
public Integer getAgentId() {
|
||||||
return agentId;
|
return agentId;
|
||||||
}
|
}
|
||||||
@@ -197,7 +234,6 @@ public class WxCpXmlMessage implements Serializable {
|
|||||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LINK}
|
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LINK}
|
||||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_EVENT}
|
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_EVENT}
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public String getMsgType() {
|
public String getMsgType() {
|
||||||
return msgType;
|
return msgType;
|
||||||
@@ -387,43 +423,6 @@ public class WxCpXmlMessage implements Serializable {
|
|||||||
this.fromUserName = fromUserName;
|
this.fromUserName = fromUserName;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static WxCpXmlMessage fromXml(String xml) {
|
|
||||||
return XStreamTransformer.fromXml(WxCpXmlMessage.class, xml);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static WxCpXmlMessage fromXml(InputStream is) {
|
|
||||||
return XStreamTransformer.fromXml(WxCpXmlMessage.class, is);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从加密字符串转换
|
|
||||||
*
|
|
||||||
* @param encryptedXml
|
|
||||||
* @param wxCpConfigStorage
|
|
||||||
* @param timestamp
|
|
||||||
* @param nonce
|
|
||||||
* @param msgSignature
|
|
||||||
*/
|
|
||||||
public static WxCpXmlMessage fromEncryptedXml(
|
|
||||||
String encryptedXml,
|
|
||||||
WxCpConfigStorage wxCpConfigStorage,
|
|
||||||
String timestamp, String nonce, String msgSignature) {
|
|
||||||
WxCpCryptUtil cryptUtil = new WxCpCryptUtil(wxCpConfigStorage);
|
|
||||||
String plainText = cryptUtil.decrypt(msgSignature, timestamp, nonce, encryptedXml);
|
|
||||||
return fromXml(plainText);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static WxCpXmlMessage fromEncryptedXml(
|
|
||||||
InputStream is,
|
|
||||||
WxCpConfigStorage wxCpConfigStorage,
|
|
||||||
String timestamp, String nonce, String msgSignature) {
|
|
||||||
try {
|
|
||||||
return fromEncryptedXml(IOUtils.toString(is, "UTF-8"), wxCpConfigStorage, timestamp, nonce, msgSignature);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStatus() {
|
public String getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -566,11 +565,10 @@ public class WxCpXmlMessage implements Serializable {
|
|||||||
@XStreamAlias("SendPicsInfo")
|
@XStreamAlias("SendPicsInfo")
|
||||||
public static class SendPicsInfo {
|
public static class SendPicsInfo {
|
||||||
|
|
||||||
@XStreamAlias("Count")
|
|
||||||
private Long count;
|
|
||||||
|
|
||||||
@XStreamAlias("PicList")
|
@XStreamAlias("PicList")
|
||||||
protected final List<Item> picList = new ArrayList<Item>();
|
protected final List<Item> picList = new ArrayList<Item>();
|
||||||
|
@XStreamAlias("Count")
|
||||||
|
private Long count;
|
||||||
|
|
||||||
public Long getCount() {
|
public Long getCount() {
|
||||||
return count;
|
return count;
|
||||||
|
|||||||
@@ -26,6 +26,41 @@ public abstract class WxCpXmlOutMessage {
|
|||||||
@XStreamConverter(value = XStreamCDataConverter.class)
|
@XStreamConverter(value = XStreamCDataConverter.class)
|
||||||
protected String msgType;
|
protected String msgType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得文本消息builder
|
||||||
|
*/
|
||||||
|
public static TextBuilder TEXT() {
|
||||||
|
return new TextBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得图片消息builder
|
||||||
|
*/
|
||||||
|
public static ImageBuilder IMAGE() {
|
||||||
|
return new ImageBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得语音消息builder
|
||||||
|
*/
|
||||||
|
public static VoiceBuilder VOICE() {
|
||||||
|
return new VoiceBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得视频消息builder
|
||||||
|
*/
|
||||||
|
public static VideoBuilder VIDEO() {
|
||||||
|
return new VideoBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得图文消息builder
|
||||||
|
*/
|
||||||
|
public static NewsBuilder NEWS() {
|
||||||
|
return new NewsBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
public String getToUserName() {
|
public String getToUserName() {
|
||||||
return toUserName;
|
return toUserName;
|
||||||
}
|
}
|
||||||
@@ -70,39 +105,4 @@ public abstract class WxCpXmlOutMessage {
|
|||||||
WxCpCryptUtil pc = new WxCpCryptUtil(wxCpConfigStorage);
|
WxCpCryptUtil pc = new WxCpCryptUtil(wxCpConfigStorage);
|
||||||
return pc.encrypt(plainXml);
|
return pc.encrypt(plainXml);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得文本消息builder
|
|
||||||
*/
|
|
||||||
public static TextBuilder TEXT() {
|
|
||||||
return new TextBuilder();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得图片消息builder
|
|
||||||
*/
|
|
||||||
public static ImageBuilder IMAGE() {
|
|
||||||
return new ImageBuilder();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得语音消息builder
|
|
||||||
*/
|
|
||||||
public static VoiceBuilder VOICE() {
|
|
||||||
return new VoiceBuilder();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得视频消息builder
|
|
||||||
*/
|
|
||||||
public static VideoBuilder VIDEO() {
|
|
||||||
return new VideoBuilder();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得图文消息builder
|
|
||||||
*/
|
|
||||||
public static NewsBuilder NEWS() {
|
|
||||||
return new NewsBuilder();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,10 @@ import java.util.List;
|
|||||||
@XStreamAlias("xml")
|
@XStreamAlias("xml")
|
||||||
public class WxCpXmlOutNewsMessage extends WxCpXmlOutMessage {
|
public class WxCpXmlOutNewsMessage extends WxCpXmlOutMessage {
|
||||||
|
|
||||||
@XStreamAlias("ArticleCount")
|
|
||||||
protected int articleCount;
|
|
||||||
|
|
||||||
@XStreamAlias("Articles")
|
@XStreamAlias("Articles")
|
||||||
protected final List<Item> articles = new ArrayList<Item>();
|
protected final List<Item> articles = new ArrayList<Item>();
|
||||||
|
@XStreamAlias("ArticleCount")
|
||||||
|
protected int articleCount;
|
||||||
|
|
||||||
public WxCpXmlOutNewsMessage() {
|
public WxCpXmlOutNewsMessage() {
|
||||||
this.msgType = WxConsts.XML_MSG_NEWS;
|
this.msgType = WxConsts.XML_MSG_NEWS;
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import me.chanjar.weixin.cp.bean.WxCpMessage;
|
|||||||
* <pre>
|
* <pre>
|
||||||
* 用法: WxCustomMessage m = WxCustomMessage.FILE().mediaId(...).toUser(...).build();
|
* 用法: WxCustomMessage m = WxCustomMessage.FILE().mediaId(...).toUser(...).build();
|
||||||
* </pre>
|
* </pre>
|
||||||
* @author Daniel Qian
|
|
||||||
*
|
*
|
||||||
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
public final class FileBuilder extends BaseBuilder<FileBuilder> {
|
public final class FileBuilder extends BaseBuilder<FileBuilder> {
|
||||||
private String mediaId;
|
private String mediaId;
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import me.chanjar.weixin.cp.bean.WxCpMessage;
|
|||||||
* <pre>
|
* <pre>
|
||||||
* 用法: WxCustomMessage m = WxCustomMessage.IMAGE().mediaId(...).toUser(...).build();
|
* 用法: WxCustomMessage m = WxCustomMessage.IMAGE().mediaId(...).toUser(...).build();
|
||||||
* </pre>
|
* </pre>
|
||||||
* @author Daniel Qian
|
|
||||||
*
|
*
|
||||||
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
public final class ImageBuilder extends BaseBuilder<ImageBuilder> {
|
public final class ImageBuilder extends BaseBuilder<ImageBuilder> {
|
||||||
private String mediaId;
|
private String mediaId;
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import java.util.List;
|
|||||||
* 用法:
|
* 用法:
|
||||||
* WxCustomMessage m = WxCustomMessage.NEWS().addArticle(article).toUser(...).build();
|
* WxCustomMessage m = WxCustomMessage.NEWS().addArticle(article).toUser(...).build();
|
||||||
* </pre>
|
* </pre>
|
||||||
* @author Daniel Qian
|
|
||||||
*
|
*
|
||||||
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
public final class NewsBuilder extends BaseBuilder<NewsBuilder> {
|
public final class NewsBuilder extends BaseBuilder<NewsBuilder> {
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import me.chanjar.weixin.cp.bean.WxCpMessage;
|
|||||||
* <pre>
|
* <pre>
|
||||||
* 用法: WxCustomMessage m = WxCustomMessage.TEXT().content(...).toUser(...).build();
|
* 用法: WxCustomMessage m = WxCustomMessage.TEXT().content(...).toUser(...).build();
|
||||||
* </pre>
|
* </pre>
|
||||||
* @author Daniel Qian
|
|
||||||
*
|
*
|
||||||
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
public final class TextBuilder extends BaseBuilder<TextBuilder> {
|
public final class TextBuilder extends BaseBuilder<TextBuilder> {
|
||||||
private String content;
|
private String content;
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import me.chanjar.weixin.cp.bean.WxCpMessage;
|
|||||||
* .toUser(...)
|
* .toUser(...)
|
||||||
* .build();
|
* .build();
|
||||||
* </pre>
|
* </pre>
|
||||||
* @author Daniel Qian
|
|
||||||
*
|
*
|
||||||
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
public final class VideoBuilder extends BaseBuilder<VideoBuilder> {
|
public final class VideoBuilder extends BaseBuilder<VideoBuilder> {
|
||||||
private String mediaId;
|
private String mediaId;
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import me.chanjar.weixin.cp.bean.WxCpMessage;
|
|||||||
* <pre>
|
* <pre>
|
||||||
* 用法: WxCustomMessage m = WxCustomMessage.VOICE().mediaId(...).toUser(...).build();
|
* 用法: WxCustomMessage m = WxCustomMessage.VOICE().mediaId(...).toUser(...).build();
|
||||||
* </pre>
|
* </pre>
|
||||||
* @author Daniel Qian
|
|
||||||
*
|
*
|
||||||
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
public final class VoiceBuilder extends BaseBuilder<VoiceBuilder> {
|
public final class VoiceBuilder extends BaseBuilder<VoiceBuilder> {
|
||||||
private String mediaId;
|
private String mediaId;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import me.chanjar.weixin.cp.bean.WxCpXmlOutImageMessage;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 图片消息builder
|
* 图片消息builder
|
||||||
|
*
|
||||||
* @author Daniel Qian
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
public final class ImageBuilder extends BaseBuilder<ImageBuilder, WxCpXmlOutImageMessage> {
|
public final class ImageBuilder extends BaseBuilder<ImageBuilder, WxCpXmlOutImageMessage> {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 图文消息builder
|
* 图文消息builder
|
||||||
|
*
|
||||||
* @author Daniel Qian
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
public final class NewsBuilder extends BaseBuilder<NewsBuilder, WxCpXmlOutNewsMessage> {
|
public final class NewsBuilder extends BaseBuilder<NewsBuilder, WxCpXmlOutNewsMessage> {
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import me.chanjar.weixin.cp.bean.WxCpXmlOutTextMessage;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 文本消息builder
|
* 文本消息builder
|
||||||
* @author Daniel Qian
|
|
||||||
*
|
*
|
||||||
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
public final class TextBuilder extends BaseBuilder<TextBuilder, WxCpXmlOutTextMessage> {
|
public final class TextBuilder extends BaseBuilder<TextBuilder, WxCpXmlOutTextMessage> {
|
||||||
private String content;
|
private String content;
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import me.chanjar.weixin.cp.bean.WxCpXmlOutVideoMessage;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 视频消息builder
|
* 视频消息builder
|
||||||
* @author Daniel Qian
|
|
||||||
*
|
*
|
||||||
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
public final class VideoBuilder extends BaseBuilder<VideoBuilder, WxCpXmlOutVideoMessage> {
|
public final class VideoBuilder extends BaseBuilder<VideoBuilder, WxCpXmlOutVideoMessage> {
|
||||||
|
|
||||||
@@ -17,10 +17,12 @@ public final class VideoBuilder extends BaseBuilder<VideoBuilder, WxCpXmlOutVide
|
|||||||
this.title = title;
|
this.title = title;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VideoBuilder description(String description) {
|
public VideoBuilder description(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VideoBuilder mediaId(String mediaId) {
|
public VideoBuilder mediaId(String mediaId) {
|
||||||
this.mediaId = mediaId;
|
this.mediaId = mediaId;
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import me.chanjar.weixin.cp.bean.WxCpXmlOutVoiceMessage;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 语音消息builder
|
* 语音消息builder
|
||||||
|
*
|
||||||
* @author Daniel Qian
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
public final class VoiceBuilder extends BaseBuilder<VoiceBuilder, WxCpXmlOutVoiceMessage> {
|
public final class VoiceBuilder extends BaseBuilder<VoiceBuilder, WxCpXmlOutVoiceMessage> {
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
* 对公众平台发送给公众账号的消息加解密示例代码.
|
* 对公众平台发送给公众账号的消息加解密示例代码.
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 1998-2014 Tencent Inc.
|
* @copyright Copyright (c) 1998-2014 Tencent Inc.
|
||||||
|
* <p>
|
||||||
|
* 针对org.apache.commons.codec.binary.Base64,
|
||||||
|
* 需要导入架包commons-codec-1.9(或commons-codec-1.8等其他版本)
|
||||||
|
* 官方下载地址:http://commons.apache.org/proper/commons-codec/download_codec.cgi
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -16,9 +16,7 @@ import me.chanjar.weixin.cp.bean.WxCpMessage;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Daniel Qian
|
* @author Daniel Qian
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class WxCpMessageGsonAdapter implements JsonSerializer<WxCpMessage> {
|
public class WxCpMessageGsonAdapter implements JsonSerializer<WxCpMessage> {
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ public class XStreamTransformer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册扩展消息的解析器
|
* 注册扩展消息的解析器
|
||||||
|
*
|
||||||
* @param clz 类型
|
* @param clz 类型
|
||||||
* @param xStream xml解析器
|
* @param xStream xml解析器
|
||||||
*/
|
*/
|
||||||
@@ -38,7 +39,6 @@ public class XStreamTransformer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* pojo -> xml
|
* pojo -> xml
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static <T> String toXml(Class<T> clazz, T object) {
|
public static <T> String toXml(Class<T> clazz, T object) {
|
||||||
return CLASS_2_XSTREAM_INSTANCE.get(clazz).toXML(object);
|
return CLASS_2_XSTREAM_INSTANCE.get(clazz).toXML(object);
|
||||||
|
|||||||
@@ -10,6 +10,13 @@ import java.io.InputStream;
|
|||||||
|
|
||||||
public class ApiTestModule implements Module {
|
public class ApiTestModule implements Module {
|
||||||
|
|
||||||
|
public static <T> T fromXml(Class<T> clazz, InputStream is) {
|
||||||
|
XStream xstream = XStreamInitializer.getInstance();
|
||||||
|
xstream.alias("xml", clazz);
|
||||||
|
xstream.processAnnotations(clazz);
|
||||||
|
return (T) xstream.fromXML(is);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configure(Binder binder) {
|
public void configure(Binder binder) {
|
||||||
InputStream is1 = ClassLoader.getSystemResourceAsStream("test-config.xml");
|
InputStream is1 = ClassLoader.getSystemResourceAsStream("test-config.xml");
|
||||||
@@ -21,13 +28,6 @@ public class ApiTestModule implements Module {
|
|||||||
binder.bind(WxCpConfigStorage.class).toInstance(config);
|
binder.bind(WxCpConfigStorage.class).toInstance(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T fromXml(Class<T> clazz, InputStream is) {
|
|
||||||
XStream xstream = XStreamInitializer.getInstance();
|
|
||||||
xstream.alias("xml", clazz);
|
|
||||||
xstream.processAnnotations(clazz);
|
|
||||||
return (T) xstream.fromXML(is);
|
|
||||||
}
|
|
||||||
|
|
||||||
@XStreamAlias("xml")
|
@XStreamAlias("xml")
|
||||||
public static class WxXmlCpInMemoryConfigStorage extends WxCpInMemoryConfigStorage {
|
public static class WxXmlCpInMemoryConfigStorage extends WxCpInMemoryConfigStorage {
|
||||||
|
|
||||||
@@ -40,6 +40,7 @@ public class ApiTestModule implements Module {
|
|||||||
public String getUserId() {
|
public String getUserId() {
|
||||||
return userId;
|
return userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserId(String userId) {
|
public void setUserId(String userId) {
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import org.testng.annotations.Test;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 基础API测试
|
* 基础API测试
|
||||||
* @author Daniel Qian
|
|
||||||
*
|
*
|
||||||
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
@Test(groups = "baseAPI")
|
@Test(groups = "baseAPI")
|
||||||
@Guice(modules = ApiTestModule.class)
|
@Guice(modules = ApiTestModule.class)
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 测试多媒体文件上传下载
|
* 测试多媒体文件上传下载
|
||||||
* @author Daniel Qian
|
|
||||||
*
|
*
|
||||||
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
//@Test(groups="mediaAPI", dependsOnGroups="baseAPI")
|
//@Test(groups="mediaAPI", dependsOnGroups="baseAPI")
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 测试消息路由器
|
* 测试消息路由器
|
||||||
* @author Daniel Qian
|
|
||||||
*
|
*
|
||||||
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public class WxCpMessageRouterTest {
|
public class WxCpMessageRouterTest {
|
||||||
@@ -152,25 +152,6 @@ public class WxCpMessageRouterTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class WxEchoCpMessageHandler implements WxCpMessageHandler {
|
|
||||||
|
|
||||||
private StringBuffer sb;
|
|
||||||
private String echoStr;
|
|
||||||
|
|
||||||
public WxEchoCpMessageHandler(StringBuffer sb, String echoStr) {
|
|
||||||
this.sb = sb;
|
|
||||||
this.echoStr = echoStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WxCpXmlOutMessage handle(WxCpXmlMessage wxMessage, Map<String, Object> context, WxCpService wxCpService,
|
|
||||||
WxSessionManager sessionManager) {
|
|
||||||
sb.append(this.echoStr).append(',');
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@DataProvider
|
@DataProvider
|
||||||
public Object[][] standardSessionManager() {
|
public Object[][] standardSessionManager() {
|
||||||
|
|
||||||
@@ -292,6 +273,25 @@ public class WxCpMessageRouterTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class WxEchoCpMessageHandler implements WxCpMessageHandler {
|
||||||
|
|
||||||
|
private StringBuffer sb;
|
||||||
|
private String echoStr;
|
||||||
|
|
||||||
|
public WxEchoCpMessageHandler(StringBuffer sb, String echoStr) {
|
||||||
|
this.sb = sb;
|
||||||
|
this.echoStr = echoStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WxCpXmlOutMessage handle(WxCpXmlMessage wxMessage, Map<String, Object> context, WxCpService wxCpService,
|
||||||
|
WxSessionManager sessionManager) {
|
||||||
|
sb.append(this.echoStr).append(',');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static class WxSessionMessageHandler implements WxCpMessageHandler {
|
public static class WxSessionMessageHandler implements WxCpMessageHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,21 +1,19 @@
|
|||||||
package me.chanjar.weixin.cp.api;
|
package me.chanjar.weixin.cp.api;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import me.chanjar.weixin.common.api.WxConsts;
|
||||||
|
import me.chanjar.weixin.common.bean.menu.WxMenu;
|
||||||
|
import me.chanjar.weixin.common.bean.menu.WxMenuButton;
|
||||||
|
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
import org.testng.annotations.DataProvider;
|
import org.testng.annotations.DataProvider;
|
||||||
import org.testng.annotations.Guice;
|
import org.testng.annotations.Guice;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
|
|
||||||
import me.chanjar.weixin.common.api.WxConsts;
|
|
||||||
import me.chanjar.weixin.common.bean.menu.WxMenu;
|
|
||||||
import me.chanjar.weixin.common.bean.menu.WxMenuButton;
|
|
||||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 测试菜单
|
* 测试菜单
|
||||||
* @author Daniel Qian
|
|
||||||
*
|
*
|
||||||
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
@Test(groups = "menuAPI", dependsOnGroups = "baseAPI")
|
@Test(groups = "menuAPI", dependsOnGroups = "baseAPI")
|
||||||
@Guice(modules = ApiTestModule.class)
|
@Guice(modules = ApiTestModule.class)
|
||||||
|
|||||||
@@ -13,17 +13,16 @@ import java.io.InputStream;
|
|||||||
@XStreamAlias("xml")
|
@XStreamAlias("xml")
|
||||||
class WxCpDemoInMemoryConfigStorage extends WxCpInMemoryConfigStorage {
|
class WxCpDemoInMemoryConfigStorage extends WxCpInMemoryConfigStorage {
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "SimpleWxConfigProvider [appidOrCorpid=" + corpId + ", corpSecret=" + corpSecret + ", accessToken=" + accessToken
|
|
||||||
+ ", expiresTime=" + expiresTime + ", token=" + token + ", aesKey=" + aesKey + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static WxCpDemoInMemoryConfigStorage fromXml(InputStream is) {
|
public static WxCpDemoInMemoryConfigStorage fromXml(InputStream is) {
|
||||||
XStream xstream = XStreamInitializer.getInstance();
|
XStream xstream = XStreamInitializer.getInstance();
|
||||||
xstream.processAnnotations(WxCpDemoInMemoryConfigStorage.class);
|
xstream.processAnnotations(WxCpDemoInMemoryConfigStorage.class);
|
||||||
return (WxCpDemoInMemoryConfigStorage) xstream.fromXML(is);
|
return (WxCpDemoInMemoryConfigStorage) xstream.fromXML(is);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "SimpleWxConfigProvider [appidOrCorpid=" + corpId + ", corpSecret=" + corpSecret + ", accessToken=" + accessToken
|
||||||
|
+ ", expiresTime=" + expiresTime + ", token=" + token + ", aesKey=" + aesKey + "]";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ public class WxCpOAuth2Servlet extends HttpServlet {
|
|||||||
this.wxCpService = wxCpService;
|
this.wxCpService = wxCpService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected void service(HttpServletRequest request, HttpServletResponse response)
|
@Override
|
||||||
|
protected void service(HttpServletRequest request, HttpServletResponse response)
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
|
|
||||||
response.setContentType("text/html;charset=utf-8");
|
response.setContentType("text/html;charset=utf-8");
|
||||||
|
|||||||
Reference in New Issue
Block a user