From 7de546385a2c09c59eb6e23d7cffb37fe4c0b1b9 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 1 Aug 2024 23:21:14 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=91SYSTEM=EF=BC=9A=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E7=9A=84=E8=AE=A2=E9=98=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/social/AppSocialUserController.java | 6 +++--- ...odeReqVO.java => AppSocialWxaQrcodeReqVO.java} | 2 +- ...a => AppSocialWxaSubscribeTemplateRespVO.java} | 2 +- .../system/api/social/SocialClientApiImpl.java | 15 ++++++++------- 4 files changed, 13 insertions(+), 12 deletions(-) rename yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/{AppSocialWxQrcodeReqVO.java => AppSocialWxaQrcodeReqVO.java} (97%) rename yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/{AppSocialWxSubscribeTemplateRespVO.java => AppSocialWxaSubscribeTemplateRespVO.java} (95%) diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java index e8de23c2b6..f2de7efdcc 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java @@ -63,16 +63,16 @@ public class AppSocialUserController { @PostMapping("/wxa-qrcode") @Operation(summary = "获得微信小程序码(base64 image)") - public CommonResult getWxaQrcode(@RequestBody @Valid AppSocialWxQrcodeReqVO reqVO) { + public CommonResult getWxaQrcode(@RequestBody @Valid AppSocialWxaQrcodeReqVO reqVO) { byte[] wxQrcode = socialClientApi.getWxaQrcode(BeanUtils.toBean(reqVO, SocialWxQrcodeReqDTO.class)); return success(Base64.encode(wxQrcode)); } @GetMapping("/get-subscribe-template-list") @Operation(summary = "获得微信小程订阅模板列表") - public CommonResult> getSubscribeTemplateList() { + public CommonResult> getSubscribeTemplateList() { List template = socialClientApi.getWxaSubscribeTemplateList(UserTypeEnum.MEMBER.getValue()); - return success(BeanUtils.toBean(template, AppSocialWxSubscribeTemplateRespVO.class)); + return success(BeanUtils.toBean(template, AppSocialWxaSubscribeTemplateRespVO.class)); } } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxQrcodeReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxaQrcodeReqVO.java similarity index 97% rename from yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxQrcodeReqVO.java rename to yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxaQrcodeReqVO.java index 8927a34c98..c12bfd7008 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxQrcodeReqVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxaQrcodeReqVO.java @@ -7,7 +7,7 @@ import lombok.Data; @Schema(description = "用户 APP - 获得获取小程序码 Request VO") @Data -public class AppSocialWxQrcodeReqVO { +public class AppSocialWxaQrcodeReqVO { /** * 页面路径不能携带参数(参数请放在scene字段里) diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxSubscribeTemplateRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxaSubscribeTemplateRespVO.java similarity index 95% rename from yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxSubscribeTemplateRespVO.java rename to yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxaSubscribeTemplateRespVO.java index 3fdc38b698..445122d3f6 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxSubscribeTemplateRespVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxaSubscribeTemplateRespVO.java @@ -5,7 +5,7 @@ import lombok.Data; @Schema(description = "用户 APP - 获得小程序订阅模版 Response VO") @Data -public class AppSocialWxSubscribeTemplateRespVO { +public class AppSocialWxaSubscribeTemplateRespVO { @Schema(description = "模版编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9Aw5ZV1j9xdWTFEkqCpZ7mIBbSC34khK55OtzUPl0rU") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java index b69221a0c6..08fa53b845 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java @@ -8,6 +8,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.system.api.social.dto.*; import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; import cn.iocoder.yudao.module.system.service.social.SocialClientService; +import cn.iocoder.yudao.module.system.service.social.SocialUserService; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.bean.WxJsapiSignature; @@ -33,7 +34,7 @@ public class SocialClientApiImpl implements SocialClientApi { @Resource private SocialClientService socialClientService; @Resource - public SocialUserApi socialUserApi; + private SocialUserService socialUserService; @Override public String getAuthorizeUrl(Integer socialType, Integer userType, String redirectUri) { @@ -68,29 +69,29 @@ public class SocialClientApiImpl implements SocialClientApi { @Override public void sendWxaSubscribeMessage(SocialWxaSubscribeMessageSendReqDTO reqDTO) { // 1.1 获得订阅模版列表 - List templateList = getWxaSubscribeTemplateList(reqDTO.getUserType()); + List templateList = socialClientService.getSubscribeTemplateList(reqDTO.getUserType()); if (CollUtil.isEmpty(templateList)) { log.warn("[sendSubscribeMessage][reqDTO({}) 发送订阅消息失败,原因:没有找到订阅模板]", reqDTO); return; } // 1.2 获得需要使用的模版 - SocialWxaSubscribeTemplateRespDTO template = findOne(templateList, item -> + TemplateInfo template = findOne(templateList, item -> ObjUtil.equal(item.getTitle(), reqDTO.getTemplateTitle())); if (template == null) { - log.warn("[sendSubscribeMessage][reqDTO({}) 发送订阅消息失败,原因:没有找到订阅模板]", reqDTO); + log.warn("[sendWxaSubscribeMessage][reqDTO({}) 发送订阅消息失败,原因:没有找到订阅模板]", reqDTO); return; } // 2. 获得社交用户 - SocialUserRespDTO socialUser = socialUserApi.getSocialUserByUserId(reqDTO.getUserType(), reqDTO.getUserId(), + SocialUserRespDTO socialUser = socialUserService.getSocialUserByUserId(reqDTO.getUserType(), reqDTO.getUserId(), SocialTypeEnum.WECHAT_MINI_APP.getType()); if (StrUtil.isBlankIfStr(socialUser.getOpenid())) { - log.warn("[sendSubscribeMessage][reqDTO({}) 发送订阅消息失败,原因:会员 openid 缺失]", reqDTO); + log.warn("[sendWxaSubscribeMessage][reqDTO({}) 发送订阅消息失败,原因:会员 openid 缺失]", reqDTO); return; } // 3. 发送订阅消息 - socialClientService.sendSubscribeMessage(reqDTO, template.getId(), socialUser.getOpenid()); + socialClientService.sendSubscribeMessage(reqDTO, template.getPriTmplId(), socialUser.getOpenid()); } }