From bedd0a1cef215538df64470df6b8d4a022189136 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期三, 28 八月 2024 14:05:16 +0800
Subject: [PATCH] 代码提交
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/WeChatController.java | 33 ++++++++++-----------------------
1 files changed, 10 insertions(+), 23 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/WeChatController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/WeChatController.java
index ecbc125..60fb6be 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/WeChatController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/WeChatController.java
@@ -3,7 +3,9 @@
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
import com.smartor.domain.WeChatSendVo;
+import com.smartor.service.WeChatService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import me.chanjar.weixin.common.exception.WxErrorException;
@@ -42,6 +44,9 @@
@Value("${appSecret}")
private String appSecret;
+ @Autowired
+ private WeChatService weChatService;
+
/**
* 鑾峰彇妯℃澘淇℃伅
@@ -71,29 +76,11 @@
* @param weChatSendVo
* @return
*/
- @ApiOperation("寰俊鍏紬鍙蜂俊鎭彂閫�")
- @PostMapping("/sendMessageToFollowers")
- public Boolean sendMessageToFollowers(@RequestBody WeChatSendVo weChatSendVo) {
- WxMpService wxMpService;
- wxMpService = new WxMpServiceImpl();
- wxMpService.setWxMpConfigStorage(new WxMpInMemoryConfigStorage());
- WxMpInMemoryConfigStorage wxMpConfigStorage = (WxMpInMemoryConfigStorage) wxMpService.getWxMpConfigStorage();
- wxMpConfigStorage.setAppId(appid);
- wxMpConfigStorage.setSecret(appSecret);
- try {
- List<String> openIdList = wxMpService.getUserService().userList(null).getOpenids();
- for (String openId : openIdList) {
- WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder().toUser(openId).templateId(weChatSendVo.getTemplateId()).url(weChatSendVo.getUrl()).build();
- for (String key : weChatSendVo.getContent().keySet()) {
- templateMessage.addData(new WxMpTemplateData(key, weChatSendVo.getContent().get(key).toString()));
- }
- wxMpService.getTemplateMsgService().sendTemplateMsg(templateMessage);
- }
- } catch (WxErrorException e) {
- e.printStackTrace();
- }
- return true;
- }
+// @ApiOperation("寰俊鍏紬鍙蜂俊鎭彂閫�")
+// @PostMapping("/sendMessageToFollowers")
+// public AjaxResult sendMessageToFollowers(@RequestBody WeChatSendVo weChatSendVo) {
+// return toAjax(weChatService.sendMessageToFollowers(weChatSendVo));
+// }
/**
--
Gitblit v1.9.3