|
@@ -2,8 +2,10 @@ package com.book.push.service.wx.impl;
|
|
|
|
|
|
import com.book.dao.cps.pojo.Platform;
|
|
import com.book.dao.cps.pojo.Platform;
|
|
import com.book.push.config.RedisProperties;
|
|
import com.book.push.config.RedisProperties;
|
|
|
|
+import com.book.push.config.WxOpenInRedisBookConfigStorage;
|
|
import com.book.push.handler.*;
|
|
import com.book.push.handler.*;
|
|
import com.book.push.service.dao.PlatformService;
|
|
import com.book.push.service.dao.PlatformService;
|
|
|
|
+import com.book.push.service.redis.RedisService;
|
|
import com.book.push.service.wx.WxThirdPartService;
|
|
import com.book.push.service.wx.WxThirdPartService;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
@@ -40,7 +42,7 @@ import static me.chanjar.weixin.mp.constant.WxMpEventConstants.POI_CHECK_NOTIFY;
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
@EnableConfigurationProperties(RedisProperties.class)
|
|
@EnableConfigurationProperties(RedisProperties.class)
|
|
public class WxThirdPartServiceImpl implements WxThirdPartService {
|
|
public class WxThirdPartServiceImpl implements WxThirdPartService {
|
|
-// private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
private final LogHandler logHandler;
|
|
private final LogHandler logHandler;
|
|
private final NullHandler nullHandler;
|
|
private final NullHandler nullHandler;
|
|
@@ -58,24 +60,33 @@ public class WxThirdPartServiceImpl implements WxThirdPartService {
|
|
@Autowired
|
|
@Autowired
|
|
private PlatformService platformService;
|
|
private PlatformService platformService;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private RedisService redisService;
|
|
|
|
+ @Autowired
|
|
private JedisPool jedisPool;
|
|
private JedisPool jedisPool;
|
|
|
|
|
|
private WxThirdPartMessageRouter wxThirdPartMessageRouter;
|
|
private WxThirdPartMessageRouter wxThirdPartMessageRouter;
|
|
-public static final String KEY_PREFIX = "platformId_%d" ;
|
|
|
|
|
|
+ public static final String PLATFORM_KEY_PREFIX = "platformId_%d";
|
|
|
|
+
|
|
|
|
+
|
|
@PostConstruct
|
|
@PostConstruct
|
|
public void load() {
|
|
public void load() {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
Map<Integer, Platform> integerPlatformMap = platformService.selectAll();
|
|
Map<Integer, Platform> integerPlatformMap = platformService.selectAll();
|
|
Set<Integer> platFormIdSet = integerPlatformMap.keySet();
|
|
Set<Integer> platFormIdSet = integerPlatformMap.keySet();
|
|
ConcurrentHashMap newWxOpenServiceMap = new ConcurrentHashMap<Integer, WxOpenService>();
|
|
ConcurrentHashMap newWxOpenServiceMap = new ConcurrentHashMap<Integer, WxOpenService>();
|
|
platFormIdSet.stream().forEach(id -> {
|
|
platFormIdSet.stream().forEach(id -> {
|
|
Platform platform = integerPlatformMap.get(id);
|
|
Platform platform = integerPlatformMap.get(id);
|
|
WxOpenService wxOpenService = new WxOpenServiceImpl();
|
|
WxOpenService wxOpenService = new WxOpenServiceImpl();
|
|
- WxOpenInRedisConfigStorage inRedisConfigStorage = new WxOpenInRedisConfigStorage(jedisPool,String.format(KEY_PREFIX, id));
|
|
|
|
|
|
+ WxOpenInRedisBookConfigStorage inRedisConfigStorage = new WxOpenInRedisBookConfigStorage(jedisPool, String.format(PLATFORM_KEY_PREFIX, id));
|
|
inRedisConfigStorage.setComponentAppId(platform.getAppid());
|
|
inRedisConfigStorage.setComponentAppId(platform.getAppid());
|
|
inRedisConfigStorage.setComponentAppSecret(platform.getSecret());
|
|
inRedisConfigStorage.setComponentAppSecret(platform.getSecret());
|
|
|
|
|
|
//FIXME 这里有错误,请注意修改
|
|
//FIXME 这里有错误,请注意修改
|
|
- inRedisConfigStorage.setComponentToken(platform.getToken());//错误位置
|
|
|
|
|
|
+ inRedisConfigStorage.setComponentVerifyTicket(redisService.get(inRedisConfigStorage.getVerifyTicketCacheKey()));
|
|
|
|
+ inRedisConfigStorage.setComponentToken(redisService.get(inRedisConfigStorage.getComponentTokenCacheKey()));//错误位置
|
|
inRedisConfigStorage.setComponentAesKey(platform.getAesKey());
|
|
inRedisConfigStorage.setComponentAesKey(platform.getAesKey());
|
|
wxOpenService.setWxOpenConfigStorage(inRedisConfigStorage);
|
|
wxOpenService.setWxOpenConfigStorage(inRedisConfigStorage);
|
|
wxOpenServiceMap.put(id, wxOpenService);
|
|
wxOpenServiceMap.put(id, wxOpenService);
|