diff --git a/epmet-auth/pom.xml b/epmet-auth/pom.xml
index c055af7405..3594bff91f 100644
--- a/epmet-auth/pom.xml
+++ b/epmet-auth/pom.xml
@@ -169,7 +169,7 @@
6379
123456
- false
+ true
122.152.200.70:8848
fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b
diff --git a/epmet-auth/src/main/java/com/epmet/redis/CustomerAppWxServiceUtil.java b/epmet-auth/src/main/java/com/epmet/redis/CustomerAppWxServiceUtil.java
index 7956bea614..4c2a0a0e38 100644
--- a/epmet-auth/src/main/java/com/epmet/redis/CustomerAppWxServiceUtil.java
+++ b/epmet-auth/src/main/java/com/epmet/redis/CustomerAppWxServiceUtil.java
@@ -11,24 +11,26 @@ package com.epmet.redis;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
+import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAppDTO;
-import com.epmet.dto.form.CustomerAppSecretFormDTO;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.google.common.collect.Maps;
-import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.SetOperations;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.stream.Collectors;
/**
@@ -50,6 +52,8 @@ public class CustomerAppWxServiceUtil implements ApplicationRunner {
@Autowired
private RedisUtils redisUtils;
@Autowired
+ private RedisTemplate redisTemplate;
+ @Autowired
private OperCrmOpenFeignClient operCrmOpenFeignClient;
private static Map maServices = Maps.newHashMap();
@@ -64,7 +68,7 @@ public class CustomerAppWxServiceUtil implements ApplicationRunner {
}
return wxMaService;
}
- public String get(String appId) {
+ /*public String get(String appId) {
String key = RedisKeys.getAppSecretKey(appId);
String secret = (String) redisUtils.get(key);
if (StringUtils.isBlank(secret)) {
@@ -79,24 +83,45 @@ public class CustomerAppWxServiceUtil implements ApplicationRunner {
}
}
return secret;
- }
+ }*/
@Override
- public void run(ApplicationArguments args) throws Exception {
- Result> configAllAppResult = operCrmOpenFeignClient.getConfigAllApp();
- if (configAllAppResult != null && configAllAppResult.success() && !CollectionUtils.isEmpty(configAllAppResult.getData())) {
- maServices = configAllAppResult.getData().stream()
- .map(a -> {
- WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
- config.setAppid(a.getAppId());
- config.setSecret(a.getSecret());
- config.setMsgDataFormat(JSON_STR);
+ public void run(ApplicationArguments args) {
+ try {
+ Result> configAllAppResult = operCrmOpenFeignClient.getConfigAllApp();
+ logger.info("initWxMa operCrmOpenFeignClient.getConfigAllApp result:{}", JSON.toJSONString(configAllAppResult));
+ if (configAllAppResult == null || configAllAppResult.success()){
+ logger.info("initWxMa operCrmOpenFeignClient.getConfigAllApp fail");
+ return;
+ }
+ String appKey = RedisKeys.getCustomerAppKey();
+ SetOperations appSet = redisTemplate.opsForSet();
+ Set members = appSet.members(appKey);
+
+ if ( !CollectionUtils.isEmpty(configAllAppResult.getData())) {
+ //if (!CollectionUtils.isEmpty(members) && CollectionUtils.isEmpty()){
+ //todo
+ //}
+ maServices = configAllAppResult.getData().stream()
+ .map(a -> {
+ WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
+ config.setAppid(a.getAppId());
+ config.setSecret(a.getSecret());
+ config.setMsgDataFormat(JSON_STR);
- WxMaService service = new WxMaServiceImpl();
- service.setWxMaConfig(config);
- return service;
- }).collect(Collectors.toMap(s -> s.getWxMaConfig().getAppid(), a -> a));
+ WxMaService service = new WxMaServiceImpl();
+ service.setWxMaConfig(config);
+ redisTemplate.opsForSet().add(appKey,a.getSecret());
+ return service;
+ }).collect(Collectors.toMap(s -> s.getWxMaConfig().getAppid(), a -> a));
+
+
+
+ }
+ } catch (Exception e) {
+ logger.error("init wxMaservice exception",e);
+ } finally {
+ logger.info("init wxMaservice end");
}
- logger.info("initWxMa success");
}
}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
index fc0dc2fe49..655004f8c1 100644
--- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
@@ -256,11 +256,10 @@ public class RedisKeys {
/**
* appId secret 缓存Key
- * @param appId
* @return
*/
- public static String getAppSecretKey(String appId) {
- return rootPrefix.concat("oper:crm:appid:secret").concat(appId);
+ public static String getCustomerAppKey() {
+ return rootPrefix.concat("oper:crm:app");
}
}