|
@@ -1,11 +1,14 @@
|
|
|
package com.book.push.config;
|
|
|
|
|
|
+import com.book.dao.cps.pojo.Platform;
|
|
|
import com.book.push.service.wx.WxThirdPartService;
|
|
|
import com.book.push.utils.JsonUtils;
|
|
|
import com.book.push.utils.Md5Util;
|
|
|
import com.book.push.vo.AuthorizerInfo;
|
|
|
import com.book.push.vo.ComponentInfo;
|
|
|
+import lombok.Getter;
|
|
|
import lombok.NonNull;
|
|
|
+import lombok.Setter;
|
|
|
import me.chanjar.weixin.open.api.impl.WxOpenInRedisConfigStorage;
|
|
|
import redis.clients.jedis.Jedis;
|
|
|
import redis.clients.jedis.util.Pool;
|
|
@@ -18,11 +21,17 @@ import redis.clients.jedis.util.Pool;
|
|
|
*/
|
|
|
|
|
|
public class WxOpenInRedisBookConfigStorage extends WxOpenInRedisConfigStorage {
|
|
|
-
|
|
|
+ @Getter
|
|
|
+ @Setter
|
|
|
+ private Platform platform;
|
|
|
|
|
|
public WxOpenInRedisBookConfigStorage(@NonNull Pool<Jedis> jedisPool, String keyPrefix) {
|
|
|
super(jedisPool, keyPrefix);
|
|
|
}
|
|
|
+ public WxOpenInRedisBookConfigStorage(Platform platform,@NonNull Pool<Jedis> jedisPool, String keyPrefix) {
|
|
|
+ super(jedisPool, keyPrefix);
|
|
|
+ this.platform = platform;
|
|
|
+ }
|
|
|
|
|
|
public String getVerifyTicketCacheKey(String appid) {
|
|
|
return WxThirdPartService.VERIFY_TICKET_KEY_PREFIX + appid;
|
|
@@ -38,7 +47,7 @@ public class WxOpenInRedisBookConfigStorage extends WxOpenInRedisConfigStorage {
|
|
|
|
|
|
public String getComponentTokenCacheKey(ComponentInfo componentInfo) {
|
|
|
|
|
|
- return WxThirdPartService.TOKEN_KEY_PREFIX + Md5Util.md5(JsonUtils.toJsonString(componentInfo));
|
|
|
+ return WxThirdPartService.COMPONENT_TOKEN_KEY_PREFIX + Md5Util.md5(JsonUtils.toJsonString(componentInfo));
|
|
|
}
|
|
|
|
|
|
public String getComponentTokenCacheKey() {
|
|
@@ -50,32 +59,34 @@ public class WxOpenInRedisBookConfigStorage extends WxOpenInRedisConfigStorage {
|
|
|
if (this.getComponentAppSecret() == null) {
|
|
|
System.out.println("ComponentAppSecret is null, please set ComponentAppSecret");
|
|
|
}
|
|
|
- if(this.getComponentVerifyTicket() == null){
|
|
|
+ if (this.getComponentVerifyTicket() == null) {
|
|
|
System.out.println("ComponentVerifyTicket is null, please set ComponentVerifyTicket");
|
|
|
}
|
|
|
ComponentInfo componentInfo = new ComponentInfo(getComponentAppId(), getComponentAppSecret(), getComponentVerifyTicket());
|
|
|
- return WxThirdPartService.TOKEN_KEY_PREFIX + Md5Util.md5(JsonUtils.toJsonString(componentInfo));
|
|
|
+ return WxThirdPartService.COMPONENT_TOKEN_KEY_PREFIX + Md5Util.md5(JsonUtils.toJsonString(componentInfo));
|
|
|
}
|
|
|
|
|
|
|
|
|
public String getAuthorizerTokenCacheKey(AuthorizerInfo authorizerInfo) {
|
|
|
|
|
|
- return WxThirdPartService.TOKEN_KEY_PREFIX + Md5Util.md5(JsonUtils.toJsonString(authorizerInfo));
|
|
|
+ return WxThirdPartService.COMPONENT_TOKEN_KEY_PREFIX + Md5Util.md5(JsonUtils.toJsonString(authorizerInfo));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void setComponentVerifyTicket(String componentVerifyTicket) {
|
|
|
- if (componentVerifyTicket==null){
|
|
|
- throw new NullPointerException("componentVerifyTicket is null " );
|
|
|
+ if (componentVerifyTicket == null) {
|
|
|
+ throw new NullPointerException("componentVerifyTicket is null ");
|
|
|
}
|
|
|
super.setComponentVerifyTicket(componentVerifyTicket);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void setComponentAccessToken(String componentAccessToken) {
|
|
|
- if (componentAccessToken==null){
|
|
|
- throw new NullPointerException("componentAccessToken is null " );
|
|
|
+ if (componentAccessToken == null) {
|
|
|
+ throw new NullPointerException("componentAccessToken is null ");
|
|
|
}
|
|
|
super.setComponentAccessToken(componentAccessToken);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|