mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 12:18:42 +08:00 
			
		
		
		
	【新增】SYSTEM: 发送微信小程序订阅消息测试接口
This commit is contained in:
		@@ -0,0 +1,5 @@
 | 
			
		||||
### 请求 /system/social-client/send-subscribe-message 接口 => 发送测试订阅消息
 | 
			
		||||
POST {{baseUrl}}/system/social-client/send-subscribe-message
 | 
			
		||||
Authorization: Bearer {{token}}
 | 
			
		||||
#Authorization: Bearer test100
 | 
			
		||||
tenant-id: {{adminTenentId}}
 | 
			
		||||
@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.controller.admin.socail;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 | 
			
		||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxSubscribeMessageReqDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientRespVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO;
 | 
			
		||||
@@ -11,13 +12,12 @@ import cn.iocoder.yudao.module.system.service.social.SocialClientService;
 | 
			
		||||
import io.swagger.v3.oas.annotations.Operation;
 | 
			
		||||
import io.swagger.v3.oas.annotations.Parameter;
 | 
			
		||||
import io.swagger.v3.oas.annotations.tags.Tag;
 | 
			
		||||
import jakarta.annotation.Resource;
 | 
			
		||||
import jakarta.validation.Valid;
 | 
			
		||||
import org.springframework.security.access.prepost.PreAuthorize;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
import org.springframework.web.bind.annotation.*;
 | 
			
		||||
 | 
			
		||||
import jakarta.annotation.Resource;
 | 
			
		||||
import jakarta.validation.Valid;
 | 
			
		||||
 | 
			
		||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 | 
			
		||||
 | 
			
		||||
@Tag(name = "管理后台 - 社交客户端")
 | 
			
		||||
@@ -70,4 +70,16 @@ public class SocialClientController {
 | 
			
		||||
        return success(BeanUtils.toBean(pageResult, SocialClientRespVO.class));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //======================= TODO 测试发送订阅消息 =======================
 | 
			
		||||
 | 
			
		||||
    @PostMapping("/send-subscribe-message")
 | 
			
		||||
    public void testSendSubscribeMessage() {
 | 
			
		||||
        SocialWxSubscribeMessageReqDTO reqDTO = new SocialWxSubscribeMessageReqDTO().setLang("zh_CN")
 | 
			
		||||
                .setMiniprogramState("developer").setTemplateId("W4ybDTIwCfKHtMKR7fSfx83DtmVKEeXQo3Ti7GCw4_4")
 | 
			
		||||
                .setToUser("oKNkb4xxw2H135-MVPKtEMkumK08");
 | 
			
		||||
        reqDTO.addData("character_string1", "11111111").addData("amount2", "6666").addData("time3", "2024-01-01 10:10:10")
 | 
			
		||||
                .addData("phrase4", "成功");
 | 
			
		||||
        socialClientService.sendSubscribeMessage(reqDTO);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -278,7 +278,7 @@ public class SocialClientServiceImpl implements SocialClientService {
 | 
			
		||||
        try {
 | 
			
		||||
            WxMaSubscribeService subscribeService = service.getSubscribeService();
 | 
			
		||||
            WxMaSubscribeMessage message = BeanUtils.toBean(reqDTO, WxMaSubscribeMessage.class);
 | 
			
		||||
            reqDTO.getData().forEach(item-> message.addData(new WxMaSubscribeMessage.MsgData(item.getKey(), item.getValue())));
 | 
			
		||||
            reqDTO.getMessages().forEach(item-> message.addData(new WxMaSubscribeMessage.MsgData(item.getKey(), item.getValue())));
 | 
			
		||||
            subscribeService.sendSubscribeMsg(message);
 | 
			
		||||
        }catch (WxErrorException e) {
 | 
			
		||||
            log.error("[sendSubscribeMessage][发送小程序订阅消息]", e);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user