规范统一config部分代码

This commit is contained in:
Binary Wang
2019-08-03 23:36:44 +08:00
parent d0d83a7b81
commit d9b7217009
34 changed files with 272 additions and 289 deletions

View File

@ -10,6 +10,7 @@ import me.chanjar.weixin.mp.bean.result.WxMpCurrentAutoReplyInfo;
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.enums.TicketType;
import me.chanjar.weixin.mp.enums.WxMpApiUrl;

View File

@ -22,6 +22,7 @@ import me.chanjar.weixin.mp.bean.result.WxMpCurrentAutoReplyInfo;
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.enums.TicketType;
import me.chanjar.weixin.mp.enums.WxMpApiUrl;
import me.chanjar.weixin.mp.util.WxMpConfigStorageHolder;

View File

@ -7,7 +7,7 @@ import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.HttpType;
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import org.apache.http.HttpHost;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;

View File

@ -7,7 +7,7 @@ import me.chanjar.weixin.common.bean.WxAccessToken;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.HttpType;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import java.util.concurrent.locks.Lock;

View File

@ -6,7 +6,7 @@ import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.HttpType;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import okhttp3.*;
import java.io.IOException;

View File

@ -3,7 +3,7 @@ package me.chanjar.weixin.mp.api.impl;
import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.URIUtil;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.WxMpSubscribeMsgService;
import me.chanjar.weixin.mp.bean.subscribe.WxMpSubscribeMessage;

View File

@ -15,7 +15,7 @@ import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.util.XmlUtils;
import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.util.crypto.WxMpCryptUtil;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
import me.chanjar.weixin.mp.util.xml.XStreamTransformer;
@ -527,10 +527,10 @@ public class WxMpXmlMessage implements Serializable {
@XStreamAlias("DeviceID")
@XStreamConverter(value = XStreamCDataConverter.class)
private String deviceId;
/**
* 微信客户端生成的session id用于request和response对应
* 因此响应中该字段第三方需要原封不变的带回
* 因此响应中该字段第三方需要原封不变的带回
*/
@XStreamAlias("SessionID")
@XStreamConverter(value = XStreamCDataConverter.class)

View File

@ -4,7 +4,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamConverter;
import lombok.Data;
import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.builder.outxml.*;
import me.chanjar.weixin.mp.util.crypto.WxMpCryptUtil;
import me.chanjar.weixin.mp.util.xml.XStreamTransformer;
@ -79,7 +79,7 @@ public abstract class WxMpXmlOutMessage implements Serializable {
public static TransferCustomerServiceBuilder TRANSFER_CUSTOMER_SERVICE() {
return new TransferCustomerServiceBuilder();
}
/**
* 获得设备消息builder
*/

View File

@ -1,4 +1,4 @@
package me.chanjar.weixin.mp.api;
package me.chanjar.weixin.mp.config;
import me.chanjar.weixin.common.bean.WxAccessToken;
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;

View File

@ -1,4 +1,4 @@
package me.chanjar.weixin.mp.api;
package me.chanjar.weixin.mp.config.impl;
import java.io.File;
import java.io.Serializable;
@ -8,6 +8,7 @@ import java.util.concurrent.locks.ReentrantLock;
import lombok.Data;
import me.chanjar.weixin.common.bean.WxAccessToken;
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.bean.WxMpHostConfig;
import me.chanjar.weixin.mp.enums.TicketType;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
@ -18,7 +19,7 @@ import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
* @author chanjarster
*/
@Data
public class WxMpInMemoryConfigStorage implements WxMpConfigStorage, Serializable {
public class WxMpDefaultConfigImpl implements WxMpConfigStorage, Serializable {
private static final long serialVersionUID = -6646519023303395185L;
protected volatile String appId;

View File

@ -1,4 +1,4 @@
package me.chanjar.weixin.mp.api;
package me.chanjar.weixin.mp.config.impl;
import me.chanjar.weixin.mp.enums.TicketType;
import redis.clients.jedis.Jedis;
@ -15,17 +15,17 @@ import redis.clients.jedis.JedisPool;
* @author nickwong
*/
@SuppressWarnings("hiding")
public class WxMpInRedisConfigStorage extends WxMpInMemoryConfigStorage {
public class WxMpRedisConfigImpl extends WxMpDefaultConfigImpl {
private static final String ACCESS_TOKEN_KEY = "wx:access_token:";
/**
* 使用连接池保证线程安全.
*/
protected final JedisPool jedisPool;
private final JedisPool jedisPool;
private String accessTokenKey;
public WxMpInRedisConfigStorage(JedisPool jedisPool) {
public WxMpRedisConfigImpl(JedisPool jedisPool) {
this.jedisPool = jedisPool;
}

View File

@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.enums;
import lombok.AllArgsConstructor;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import static me.chanjar.weixin.mp.bean.WxMpHostConfig.*;

View File

@ -17,7 +17,7 @@
*/
package me.chanjar.weixin.mp.util.crypto;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import org.apache.commons.codec.binary.Base64;
public class WxMpCryptUtil extends me.chanjar.weixin.common.util.crypto.WxCryptUtil {

View File

@ -7,7 +7,7 @@ import org.testng.annotations.*;
import com.google.inject.Inject;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.api.test.TestConfigStorage;

View File

@ -12,7 +12,7 @@ import com.google.inject.Binder;
import com.google.inject.Module;
import com.thoughtworks.xstream.XStream;
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.WxMpService;
public class ApiTestModule implements Module {

View File

@ -1,13 +1,13 @@
package me.chanjar.weixin.mp.api.test;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import org.apache.commons.lang3.builder.ToStringBuilder;
import java.util.concurrent.locks.Lock;
@XStreamAlias("xml")
public class TestConfigStorage extends WxMpInMemoryConfigStorage {
public class TestConfigStorage extends WxMpDefaultConfigImpl {
private String openid;
private String kfAccount;

View File

@ -6,13 +6,13 @@ import java.util.concurrent.locks.ReentrantLock;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
/**
* @author Daniel Qian
*/
@XStreamAlias("xml")
class WxMpDemoInMemoryConfigStorage extends WxMpInMemoryConfigStorage {
class WxMpDemoInMemoryConfigStorage extends WxMpDefaultConfigImpl {
private static final long serialVersionUID = -3706236839197109704L;
public static WxMpDemoInMemoryConfigStorage fromXml(InputStream is) {

View File

@ -1,7 +1,7 @@
package me.chanjar.weixin.mp.demo;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.WxMpMessageHandler;
import me.chanjar.weixin.mp.api.WxMpMessageRouter;
import me.chanjar.weixin.mp.api.WxMpService;

View File

@ -1,6 +1,6 @@
package me.chanjar.weixin.mp.demo;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.WxMpMessageRouter;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;