From ded817c802bbc9a9cb5a59cb794a7a329fc191ac Mon Sep 17 00:00:00 2001 From: yujintao Date: Mon, 25 Nov 2019 16:15:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=92=8C=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E7=9A=84=E5=B7=A5=E5=85=B7=E5=8C=85=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E5=8D=87=E5=88=B03.6.0=E7=89=88=E6=9C=AC=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE=E7=9A=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epdc-commons-tools-wx-ma/pom.xml | 2 +- .../com/elink/esua/epdc/wx/ma/WxMaConfig.java | 91 +++++++++++++------ .../elink/esua/epdc/wx/ma/WxMaProperties.java | 55 ++++++----- .../epdc-commons-tools-wx-mp/pom.xml | 2 +- .../epdc-api/epdc-api-server/pom.xml | 11 ++- .../esua/epdc/async/WxMaSecCheckTask.java | 17 +++- .../epdc/service/impl/AppUserServiceImpl.java | 9 +- .../epdc/service/impl/MessageServiceImpl.java | 6 +- .../service/impl/WorkUserServiceImpl.java | 12 +-- .../esua/epdc/utils/WxMaServiceUtils.java | 44 +++++++++ .../src/main/resources/application.yml | 23 ++++- 11 files changed, 193 insertions(+), 79 deletions(-) create mode 100644 esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/utils/WxMaServiceUtils.java diff --git a/esua-epdc/epdc-commons/epdc-commons-tools-wx-ma/pom.xml b/esua-epdc/epdc-commons/epdc-commons-tools-wx-ma/pom.xml index f800d575d..b427bed4b 100644 --- a/esua-epdc/epdc-commons/epdc-commons-tools-wx-ma/pom.xml +++ b/esua-epdc/epdc-commons/epdc-commons-tools-wx-ma/pom.xml @@ -27,7 +27,7 @@ com.github.binarywang weixin-java-miniapp - 3.4.0 + 3.6.0 diff --git a/esua-epdc/epdc-commons/epdc-commons-tools-wx-ma/src/main/java/com/elink/esua/epdc/wx/ma/WxMaConfig.java b/esua-epdc/epdc-commons/epdc-commons-tools-wx-ma/src/main/java/com/elink/esua/epdc/wx/ma/WxMaConfig.java index eec648118..79af52f61 100644 --- a/esua-epdc/epdc-commons/epdc-commons-tools-wx-ma/src/main/java/com/elink/esua/epdc/wx/ma/WxMaConfig.java +++ b/esua-epdc/epdc-commons/epdc-commons-tools-wx-ma/src/main/java/com/elink/esua/epdc/wx/ma/WxMaConfig.java @@ -5,18 +5,22 @@ import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; import cn.binarywang.wx.miniapp.bean.WxMaKefuMessage; import cn.binarywang.wx.miniapp.bean.WxMaTemplateData; import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage; -import cn.binarywang.wx.miniapp.config.WxMaInMemoryConfig; +import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl; import cn.binarywang.wx.miniapp.message.WxMaMessageHandler; import cn.binarywang.wx.miniapp.message.WxMaMessageRouter; import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; import me.chanjar.weixin.common.error.WxErrorException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import javax.annotation.PostConstruct; import java.io.File; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; /** * @author Binary Wang @@ -27,31 +31,51 @@ public class WxMaConfig { private WxMaProperties properties; + private static Map routers = Maps.newHashMap(); + private static Map maServices = Maps.newHashMap(); + @Autowired public WxMaConfig(WxMaProperties properties) { this.properties = properties; } - @Bean - public WxMaService wxMaService() { - WxMaProperties wxMaProperties = this.properties; - if (wxMaProperties == null) { + public static WxMaService getMaService(String appid) { + WxMaService wxService = maServices.get(appid); + if (wxService == null) { + throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", appid)); + } + + return wxService; + } + + public static WxMaMessageRouter getRouter(String appid) { + return routers.get(appid); + } + + @PostConstruct + public void init() { + List configs = this.properties.getConfigs(); + if (configs == null) { throw new RuntimeException("大哥,拜托先看下项目首页的说明(readme文件),添加下相关配置,注意别配错了!"); } - WxMaInMemoryConfig config = new WxMaInMemoryConfig(); - config.setAppid(wxMaProperties.getAppid()); - config.setSecret(wxMaProperties.getSecret()); - config.setToken(wxMaProperties.getToken()); - config.setAesKey(wxMaProperties.getAesKey()); - config.setMsgDataFormat(wxMaProperties.getMsgDataFormat()); - - WxMaService maService = new WxMaServiceImpl(); - maService.setWxMaConfig(config); - return maService; + + maServices = configs.stream() + .map(a -> { + WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); + config.setAppid(a.getAppid()); + config.setSecret(a.getSecret()); + config.setToken(a.getToken()); + config.setAesKey(a.getAesKey()); + config.setMsgDataFormat(a.getMsgDataFormat()); + + WxMaService service = new WxMaServiceImpl(); + service.setWxMaConfig(config); + routers.put(a.getAppid(), this.newRouter(service)); + return service; + }).collect(Collectors.toMap(s -> s.getWxMaConfig().getAppid(), a -> a)); } - @Bean - public WxMaMessageRouter newRouter(WxMaService service) { + private WxMaMessageRouter newRouter(WxMaService service) { final WxMaMessageRouter router = new WxMaMessageRouter(service); router .rule().handler(logHandler).next() @@ -62,24 +86,29 @@ public class WxMaConfig { return router; } - private final WxMaMessageHandler templateMsgHandler = (wxMessage, context, service, sessionManager) -> - service.getMsgService().sendTemplateMsg(WxMaTemplateMessage.builder() - .templateId("此处更换为自己的模板id") - .formId("自己替换可用的formid") - .data(Lists.newArrayList( - new WxMaTemplateData("keyword1", "339208499", "#173177"))) - .toUser(wxMessage.getFromUser()) - .build()); + private final WxMaMessageHandler templateMsgHandler = (wxMessage, context, service, sessionManager) -> { + service.getMsgService().sendTemplateMsg(WxMaTemplateMessage.builder() + .templateId("此处更换为自己的模板id") + .formId("自己替换可用的formid") + .data(Lists.newArrayList( + new WxMaTemplateData("keyword1", "339208499", "#173177"))) + .toUser(wxMessage.getFromUser()) + .build()); + return null; + }; private final WxMaMessageHandler logHandler = (wxMessage, context, service, sessionManager) -> { System.out.println("收到消息:" + wxMessage.toString()); service.getMsgService().sendKefuMsg(WxMaKefuMessage.newTextBuilder().content("收到信息为:" + wxMessage.toJson()) .toUser(wxMessage.getFromUser()).build()); + return null; }; - private final WxMaMessageHandler textHandler = (wxMessage, context, service, sessionManager) -> - service.getMsgService().sendKefuMsg(WxMaKefuMessage.newTextBuilder().content("回复文本消息") - .toUser(wxMessage.getFromUser()).build()); + private final WxMaMessageHandler textHandler = (wxMessage, context, service, sessionManager) -> { + service.getMsgService().sendKefuMsg(WxMaKefuMessage.newTextBuilder().content("回复文本消息") + .toUser(wxMessage.getFromUser()).build()); + return null; + }; private final WxMaMessageHandler picHandler = (wxMessage, context, service, sessionManager) -> { try { @@ -95,6 +124,8 @@ public class WxMaConfig { } catch (WxErrorException e) { e.printStackTrace(); } + + return null; }; private final WxMaMessageHandler qrcodeHandler = (wxMessage, context, service, sessionManager) -> { @@ -110,6 +141,8 @@ public class WxMaConfig { } catch (WxErrorException e) { e.printStackTrace(); } + + return null; }; } diff --git a/esua-epdc/epdc-commons/epdc-commons-tools-wx-ma/src/main/java/com/elink/esua/epdc/wx/ma/WxMaProperties.java b/esua-epdc/epdc-commons/epdc-commons-tools-wx-ma/src/main/java/com/elink/esua/epdc/wx/ma/WxMaProperties.java index cbf030a62..f00ab8c37 100644 --- a/esua-epdc/epdc-commons/epdc-commons-tools-wx-ma/src/main/java/com/elink/esua/epdc/wx/ma/WxMaProperties.java +++ b/esua-epdc/epdc-commons/epdc-commons-tools-wx-ma/src/main/java/com/elink/esua/epdc/wx/ma/WxMaProperties.java @@ -3,6 +3,8 @@ package com.elink.esua.epdc.wx.ma; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; +import java.util.List; + /** * 微信小程序框架配置类 * @@ -13,29 +15,34 @@ import org.springframework.boot.context.properties.ConfigurationProperties; @ConfigurationProperties(prefix = "wx.ma") public class WxMaProperties { - /** - * 设置微信小程序的appid - */ - private String appid; - - /** - * 设置微信小程序的Secret - */ - private String secret; - - /** - * 设置微信小程序消息服务器配置的token - */ - private String token; - - /** - * 设置微信小程序消息服务器配置的EncodingAESKey - */ - private String aesKey; - - /** - * 消息格式,XML或者JSON - */ - private String msgDataFormat; + private List configs; + + @Data + public static class Config { + /** + * 设置微信小程序的appid + */ + private String appid; + + /** + * 设置微信小程序的Secret + */ + private String secret; + + /** + * 设置微信小程序消息服务器配置的token + */ + private String token; + + /** + * 设置微信小程序消息服务器配置的EncodingAESKey + */ + private String aesKey; + + /** + * 消息格式,XML或者JSON + */ + private String msgDataFormat; + } } diff --git a/esua-epdc/epdc-commons/epdc-commons-tools-wx-mp/pom.xml b/esua-epdc/epdc-commons/epdc-commons-tools-wx-mp/pom.xml index f40db5718..e9824ae86 100644 --- a/esua-epdc/epdc-commons/epdc-commons-tools-wx-mp/pom.xml +++ b/esua-epdc/epdc-commons/epdc-commons-tools-wx-mp/pom.xml @@ -17,7 +17,7 @@ - 3.5.0 + 3.6.0 1.8 1.8 UTF-8 diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/pom.xml b/esua-epdc/epdc-module/epdc-api/epdc-api-server/pom.xml index 22846cd75..bb7e8ce3f 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/pom.xml +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/pom.xml @@ -13,7 +13,7 @@ jar - 3.5.0 + @@ -159,6 +159,9 @@ wxdd8530c5f4926766 5bf4fb813145431b3493a10aa7e041e9 + + wx29b074840ef4bfd9 + 4adb1afccc69f205cdf5b521d74e2aca @@ -190,6 +193,9 @@ wxdd8530c5f4926766 5bf4fb813145431b3493a10aa7e041e9 + + wx29b074840ef4bfd9 + 4adb1afccc69f205cdf5b521d74e2aca @@ -221,6 +227,9 @@ wxdd8530c5f4926766 5bf4fb813145431b3493a10aa7e041e9 + + wx29b074840ef4bfd9 + 4adb1afccc69f205cdf5b521d74e2aca diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/async/WxMaSecCheckTask.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/async/WxMaSecCheckTask.java index cf42160a7..e04f8535c 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/async/WxMaSecCheckTask.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/async/WxMaSecCheckTask.java @@ -2,6 +2,8 @@ package com.elink.esua.epdc.async; import cn.binarywang.wx.miniapp.api.WxMaSecCheckService; import cn.binarywang.wx.miniapp.api.WxMaService; +import com.elink.esua.epdc.utils.WxMaServiceUtils; +import com.elink.esua.epdc.wx.ma.WxMaConfig; import me.chanjar.weixin.common.error.WxErrorException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; @@ -11,6 +13,7 @@ import java.io.File; /** * 微信内容安全检查 + * * @Author LC * @Date 2019/9/18 9:58 */ @@ -18,10 +21,11 @@ import java.io.File; public class WxMaSecCheckTask { @Autowired - private WxMaService wxMaService; + private WxMaServiceUtils wxMaServiceUtils; /** * 微信上传文本安全检查 + * * @Params: [message] * @Return: void * @Author: liuchuang @@ -29,12 +33,17 @@ public class WxMaSecCheckTask { */ @Async public void checkMessage(String message) { - WxMaSecCheckService wxMaSecCheckService = wxMaService.getSecCheckService(); - wxMaSecCheckService.checkMessage(message); + WxMaSecCheckService wxMaSecCheckService = wxMaServiceUtils.normalWxMaService().getSecCheckService(); + try { + wxMaSecCheckService.checkMessage(message); + } catch (WxErrorException e) { + e.printStackTrace(); + } } /** * 微信上传图片安全检查 + * * @Params: [file] * @Return: void * @Author: liuchuang @@ -42,7 +51,7 @@ public class WxMaSecCheckTask { */ @Async public void checkImage(File file) { - WxMaSecCheckService wxMaSecCheckService = wxMaService.getSecCheckService(); + WxMaSecCheckService wxMaSecCheckService = wxMaServiceUtils.normalWxMaService().getSecCheckService(); try { wxMaSecCheckService.checkImage(file); } catch (WxErrorException e) { diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/AppUserServiceImpl.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/AppUserServiceImpl.java index 89429162e..e9f0a7c66 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/AppUserServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/AppUserServiceImpl.java @@ -36,6 +36,7 @@ import com.elink.esua.epdc.jwt.JwtTokenProperties; import com.elink.esua.epdc.jwt.JwtTokenUtils; import com.elink.esua.epdc.redis.AppUserRedis; import com.elink.esua.epdc.service.AppUserService; +import com.elink.esua.epdc.utils.WxMaServiceUtils; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.mp.api.WxMpService; @@ -69,7 +70,7 @@ public class AppUserServiceImpl implements AppUserService { private WxMpService wxMpService; @Autowired - private WxMaService wxMaService; + private WxMaServiceUtils wxMaServiceUtils; @Autowired private AdminFeignClient adminFeignClient; @@ -473,7 +474,7 @@ public class AppUserServiceImpl implements AppUserService { private WxMaJscode2SessionResult getWxMaUser(String wxCode) { WxMaJscode2SessionResult wxMaJscode2SessionResult = null; try { - wxMaJscode2SessionResult = wxMaService.jsCode2SessionInfo(wxCode); + wxMaJscode2SessionResult = wxMaServiceUtils.normalWxMaService().jsCode2SessionInfo(wxCode); } catch (WxErrorException e) { log.error("->[getMaOpenId]::error[{}]", "解析微信code失败"); } @@ -836,7 +837,7 @@ public class AppUserServiceImpl implements AppUserService { return new Result().error("获取用户信息失败"); } String sessionKey = this.getUserSessionKey(formDto.getWxCode()); - WxMaUserInfo wxMaUserInfo = wxMaService.getUserService().getUserInfo(sessionKey, formDto.getEncryptedData(), formDto.getIv()); + WxMaUserInfo wxMaUserInfo = wxMaServiceUtils.normalWxMaService().getUserService().getUserInfo(sessionKey, formDto.getEncryptedData(), formDto.getIv()); UserDTO userDTO = new UserDTO(); userDTO.setId(userDetail.getUserId()); userDTO.setNickname(wxMaUserInfo.getNickName()); @@ -871,7 +872,7 @@ public class AppUserServiceImpl implements AppUserService { */ private String getUserSessionKey(String code) { try { - WxMaJscode2SessionResult wxMaJscode2SessionResult = wxMaService.jsCode2SessionInfo(code); + WxMaJscode2SessionResult wxMaJscode2SessionResult = wxMaServiceUtils.normalWxMaService().jsCode2SessionInfo(code); if (wxMaJscode2SessionResult != null) { return wxMaJscode2SessionResult.getSessionKey(); } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/MessageServiceImpl.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/MessageServiceImpl.java index db135db9a..d1f27ad95 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/MessageServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/MessageServiceImpl.java @@ -1,6 +1,5 @@ package com.elink.esua.epdc.service.impl; -import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.WxMaTemplateData; import cn.binarywang.wx.miniapp.bean.WxMaUniformMessage; import com.elink.esua.epdc.commons.tools.utils.Result; @@ -10,6 +9,7 @@ import com.elink.esua.epdc.enums.AppUserAuditStateEnum; import com.elink.esua.epdc.feign.MessageFeignClient; import com.elink.esua.epdc.feign.UserFeignClient; import com.elink.esua.epdc.service.MessageService; +import com.elink.esua.epdc.utils.WxMaServiceUtils; import com.google.common.collect.Lists; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; @@ -35,7 +35,7 @@ public class MessageServiceImpl implements MessageService { private UserFeignClient userFeignClient; @Autowired - private WxMaService wxMaService; + private WxMaServiceUtils wxMaServiceUtils; /** * 注册审核失败服务消息模版 @@ -118,7 +118,7 @@ public class MessageServiceImpl implements MessageService { .emphasisKeyword(success ? "keyword5.DATA" : "keyword6.DATA") .build(); try { - wxMaService.getMsgService().sendUniformMsg(message); + wxMaServiceUtils.normalWxMaService().getMsgService().sendUniformMsg(message); } catch (WxErrorException e) { log.error("->sendRegisterResult::发送注册{}服务消息失败::userId::{}::errorMsg::{}", success ? "成功" : "失败", registerAuditResultDto.getUserId(), e.getMessage()); diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/WorkUserServiceImpl.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/WorkUserServiceImpl.java index a6e7b03af..2dc9c6a28 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/WorkUserServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/WorkUserServiceImpl.java @@ -1,6 +1,5 @@ package com.elink.esua.epdc.service.impl; -import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import com.elink.esua.epdc.common.token.dto.WorkUserAuthorizationDTO; import com.elink.esua.epdc.common.token.dto.WorkUserLoginDTO; @@ -16,17 +15,15 @@ import com.elink.esua.epdc.common.token.dto.TokenDto; import com.elink.esua.epdc.dto.form.EpdcWorkAppUserMaTokenFormDTO; import com.elink.esua.epdc.feign.AdminFeignClient; import com.elink.esua.epdc.feign.ResourceFeignClient; -import com.elink.esua.epdc.feign.AdminFeignClient; import com.elink.esua.epdc.feign.UserFeignClient; import com.elink.esua.epdc.service.WorkUserService; +import com.elink.esua.epdc.utils.WxMaServiceUtils; import me.chanjar.weixin.common.error.WxErrorException; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; -import java.util.Map; /** * 工作端,用户登录、用户管理 相关业务实现 @@ -38,14 +35,15 @@ import java.util.Map; public class WorkUserServiceImpl implements WorkUserService { @Autowired private UserFeignClient userFeignClient; + @Autowired private AdminFeignClient adminFeignClient; @Autowired - private WxMaService wxMaService; + private ResourceFeignClient resourceFeignClient; @Autowired - private ResourceFeignClient resourceFeignClient; + private WxMaServiceUtils wxMaServiceUtils; @Override public Result getMaToken(EpdcWorkAppUserMaTokenFormDTO formDto) { @@ -141,7 +139,7 @@ public class WorkUserServiceImpl implements WorkUserService { private WxMaJscode2SessionResult getWxMaUser(String wxCode) { WxMaJscode2SessionResult wxMaJscode2SessionResult = null; try { - wxMaJscode2SessionResult = wxMaService.jsCode2SessionInfo(wxCode); + wxMaJscode2SessionResult = wxMaServiceUtils.workWxMaService().jsCode2SessionInfo(wxCode); } catch (WxErrorException e) { e.printStackTrace(); } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/utils/WxMaServiceUtils.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/utils/WxMaServiceUtils.java new file mode 100644 index 000000000..e384f75c0 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/utils/WxMaServiceUtils.java @@ -0,0 +1,44 @@ +package com.elink.esua.epdc.utils; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import com.elink.esua.epdc.wx.ma.WxMaConfig; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/** + * @author work@yujt.net.cn + * @date 1 1 + */ +@Component +public class WxMaServiceUtils { + + @Value("${wx.ma.appId.normal}") + private String APPID_NORMAL; + + @Value("${wx.ma.appId.work}") + private String APPID_WORK; + + /** + * 获取党群e家 普通居民端配置 + * + * @return cn.binarywang.wx.miniapp.api.WxMaService + * @author work@yujt.net.cn + * @date 2019/11/25 16:09 + */ + public final WxMaService normalWxMaService() { + final WxMaService wxMaService = WxMaConfig.getMaService(APPID_NORMAL); + return wxMaService; + } + + /** + * 获取党群e家 工作端配置 + * + * @return cn.binarywang.wx.miniapp.api.WxMaService + * @author work@yujt.net.cn + * @date 2019/11/25 16:10 + */ + public final WxMaService workWxMaService() { + final WxMaService wxMaService = WxMaConfig.getMaService(APPID_WORK); + return wxMaService; + } +} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/resources/application.yml b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/resources/application.yml index 0e57f3fb3..507eed358 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/resources/application.yml +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/resources/application.yml @@ -94,11 +94,24 @@ wx: token: @wx.mp.configs.token@ aesKey: @wx.mp.configs.aesKey@ ma: - appid: @wx.ma.appId@ - secret: @wx.ma.secret@ - token: #微信小程序消息服务器配置的token - aesKey: #微信小程序消息服务器配置的EncodingAESKey - msgDataFormat: JSON + configs: + - appid: @wx.ma.appId@ + secret: @wx.ma.secret@ + token: #微信小程序消息服务器配置的token + aesKey: #微信小程序消息服务器配置的EncodingAESKey + msgDataFormat: JSON + - appid: @work.wx.ma.appId@ + secret: @work.wx.ma.secret@ + token: #微信小程序消息服务器配置的token + aesKey: #微信小程序消息服务器配置的EncodingAESKey + msgDataFormat: JSON + appId: + # 普通居民端的appId + normal: @wx.ma.appId@ + # 工作端的appId + work: @work.wx.ma.appId@ + + token: expire: 21600