diff --git a/epmet-auth/pom.xml b/epmet-auth/pom.xml index 3594bff91f..c055af7405 100644 --- a/epmet-auth/pom.xml +++ b/epmet-auth/pom.xml @@ -169,7 +169,7 @@ 6379 123456 - true + false 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 a9f5f4901a..7956bea614 100644 --- a/epmet-auth/src/main/java/com/epmet/redis/CustomerAppWxServiceUtil.java +++ b/epmet-auth/src/main/java/com/epmet/redis/CustomerAppWxServiceUtil.java @@ -11,7 +11,6 @@ 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; @@ -23,10 +22,11 @@ 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.stereotype.Component; import org.springframework.util.CollectionUtils; -import javax.annotation.PostConstruct; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -38,7 +38,7 @@ import java.util.stream.Collectors; * @since 1.0.0 */ @Component -public class CustomerAppWxServiceUtil { +public class CustomerAppWxServiceUtil implements ApplicationRunner { private Logger logger = LogManager.getLogger(CustomerAppWxServiceUtil.class); /** @@ -53,23 +53,9 @@ public class CustomerAppWxServiceUtil { private OperCrmOpenFeignClient operCrmOpenFeignClient; private static Map maServices = Maps.newHashMap(); - @PostConstruct + private void initWxMa() { - 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); - WxMaService service = new WxMaServiceImpl(); - service.setWxMaConfig(config); - return service; - }).collect(Collectors.toMap(s -> s.getWxMaConfig().getAppid(), a -> a)); - } - logger.info("initWxMa success:{}", JSON.toJSONString(maServices)); } public WxMaService getWxMaService(String appId) { WxMaService wxMaService = maServices.get(appId); @@ -95,4 +81,22 @@ public class CustomerAppWxServiceUtil { 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); + + WxMaService service = new WxMaServiceImpl(); + service.setWxMaConfig(config); + return service; + }).collect(Collectors.toMap(s -> s.getWxMaConfig().getAppid(), a -> a)); + } + logger.info("initWxMa success"); + } } diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java index 71cc77831d..59a01476e7 100644 --- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java @@ -40,5 +40,5 @@ public interface OperCrmOpenFeignClient { * @return */ @PostMapping("/oper/crm/customerapp/getconfigallapp") - Result getConfigAllApp(); + Result> getConfigAllApp(); } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerAppController.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerAppController.java index 90bdfd56c4..4403ea0120 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerAppController.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerAppController.java @@ -81,7 +81,8 @@ public class CustomerAppController { } @PostMapping("getconfigallapp") public Result> getConfigAllApp(){ - return new Result>().ok(customerAppIdService.list(null)); + List configAllApp = customerAppIdService.getConfigAllApp(); + return new Result>().ok(configAllApp); } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerAppIdService.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerAppIdService.java index 3da3da447d..f8036db8cd 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerAppIdService.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerAppIdService.java @@ -89,4 +89,6 @@ public interface CustomerAppIdService extends BaseService { * @return */ String selectSecretByAppId(String appId); + + List getConfigAllApp(); } \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerAppIdServiceImpl.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerAppIdServiceImpl.java index 44dfa97eb9..86c5689b64 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerAppIdServiceImpl.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerAppIdServiceImpl.java @@ -93,4 +93,11 @@ public class CustomerAppIdServiceImpl extends BaseServiceImpl getConfigAllApp() { + List entities = baseDao.selectList(null); + List customerAppDTOS = ConvertUtils.sourceToTarget(entities, CustomerAppDTO.class); + return customerAppDTOS; + } + } \ No newline at end of file