From 541ee81300b745dbe3d345519017955e75d7eadd Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 10 Jan 2023 23:24:08 +0800 Subject: [PATCH] =?UTF-8?q?mp=EF=BC=9A=E5=89=8D=E7=AB=AF=E6=8E=A5=E5=85=A5?= =?UTF-8?q?=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/message/MpMessageController.java | 9 +-- .../mp/service/message/MpMessageService.java | 4 +- .../service/message/MpMessageServiceImpl.java | 9 ++- yudao-ui-admin/src/api/mp/message.js | 28 +++----- .../src/views/mp/components/wx-msg/main.vue | 66 +++++++++++-------- yudao-ui-admin/src/views/mp/message/index.vue | 2 +- 6 files changed, 59 insertions(+), 59 deletions(-) diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.java index 9c83172aa..911bddc8a 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.java @@ -37,10 +37,11 @@ public class MpMessageController { } @PostMapping("/send") -// @ApiOperation("获得粉丝消息表分页") -// @PreAuthorize("@ss.hasPermission('mp:message:query')") - public CommonResult sendMessage(@Valid @RequestBody MpMessageSendReqVO reqVO) { - return success(mpMessageService.sendKefuMessage(reqVO)); + @ApiOperation("给粉丝发送消息") + @PreAuthorize("@ss.hasPermission('mp:message:send')") + public CommonResult sendMessage(@Valid @RequestBody MpMessageSendReqVO reqVO) { + MpMessageDO message = mpMessageService.sendKefuMessage(reqVO); + return success(MpMessageConvert.INSTANCE.convert(message)); } } diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageService.java index c997cae1d..b72f264df 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageService.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageService.java @@ -52,8 +52,8 @@ public interface MpMessageService { * 注意,该方法会真实发送消息 * * @param sendReqVO 消息内容 - * @return 消息编号 + * @return 消息 */ - Long sendKefuMessage(MpMessageSendReqVO sendReqVO); + MpMessageDO sendKefuMessage(MpMessageSendReqVO sendReqVO); } diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java index a71bc64a8..229cc52c0 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java @@ -104,7 +104,7 @@ public class MpMessageServiceImpl implements MpMessageService { } @Override - public Long sendKefuMessage(MpMessageSendReqVO sendReqVO) { + public MpMessageDO sendKefuMessage(MpMessageSendReqVO sendReqVO) { // 校验消息格式 MpUtils.validateMessage(validator, sendReqVO.getType(), sendReqVO); @@ -116,18 +116,17 @@ public class MpMessageServiceImpl implements MpMessageService { WxMpKefuMessage wxMessage = MpMessageConvert.INSTANCE.convert(sendReqVO, user); WxMpService mpService = mpServiceFactory.getRequiredMpService(user.getAppId()); try { - boolean result = mpService.getKefuService().sendKefuMessage(wxMessage); - System.out.println(result); + mpService.getKefuService().sendKefuMessageWithResponse(wxMessage); } catch (WxErrorException e) { throw new RuntimeException(e); } // 记录消息 MpMessageDO message = MpMessageConvert.INSTANCE.convert(wxMessage, account, user); - message.setSendFrom(MpMessageSendFromEnum.USER_TO_MP.getFrom()); + message.setSendFrom(MpMessageSendFromEnum.MP_TO_USER.getFrom()); downloadMessageMedia(mpService, message); mpMessageMapper.insert(message); - return message.getId(); + return message; } /** diff --git a/yudao-ui-admin/src/api/mp/message.js b/yudao-ui-admin/src/api/mp/message.js index 2eef1a044..022f9a876 100644 --- a/yudao-ui-admin/src/api/mp/message.js +++ b/yudao-ui-admin/src/api/mp/message.js @@ -1,23 +1,6 @@ import request from '@/utils/request' -// 创建粉丝消息表 -export function createMessage(data) { - return request({ - url: '/mp/message/create', - method: 'post', - data: data - }) -} - -// 获得粉丝消息表 -export function getMessage(id) { - return request({ - url: '/mp/message/get?id=' + id, - method: 'get' - }) -} - -// 获得粉丝消息表 分页 +// 获得粉丝消息表分页 export function getMessagePage(query) { return request({ url: '/mp/message/page', @@ -25,3 +8,12 @@ export function getMessagePage(query) { params: query }) } + +// 给粉丝发送消息 +export function sendMessage(data) { + return request({ + url: '/mp/message/send', + method: 'post', + data: data + }) +} diff --git a/yudao-ui-admin/src/views/mp/components/wx-msg/main.vue b/yudao-ui-admin/src/views/mp/components/wx-msg/main.vue index 72daaac91..4dd3d1f25 100644 --- a/yudao-ui-admin/src/views/mp/components/wx-msg/main.vue +++ b/yudao-ui-admin/src/views/mp/components/wx-msg/main.vue @@ -88,7 +88,7 @@