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 @@