提交 6bab0519 编写于 作者: 孙喜旺

修改群发入参

上级 d5dcedbb
...@@ -33,6 +33,11 @@ public enum GroupMessageType { ...@@ -33,6 +33,11 @@ public enum GroupMessageType {
*/ */
TEXT_IMAGE("4", "text_image"), TEXT_IMAGE("4", "text_image"),
/**
* 视频
*/
VIDEO("5", "video")
; ;
/** /**
* 媒体类型 * 媒体类型
......
...@@ -68,6 +68,11 @@ public class CustomerMessagePushDto { ...@@ -68,6 +68,11 @@ public class CustomerMessagePushDto {
*/ */
private MiniprogramMessageDto miniprogramMessage; private MiniprogramMessageDto miniprogramMessage;
/**
* 视频
*/
private VideoDto videoDto;
/** /**
* 消息内容 * 消息内容
......
package com.linkwechat.wecom.domain.dto.message;
import lombok.Data;
/**
* @author danmo
* @description 视频
* @date 2021/4/24 16:01
**/
@Data
public class VideoDto {
/**
* 视频素材id
*/
private String media_id;
}
...@@ -27,19 +27,23 @@ public class WeCustomerMessagePushDto { ...@@ -27,19 +27,23 @@ public class WeCustomerMessagePushDto {
*/ */
private TextMessageDto text; private TextMessageDto text;
/**
* 附件
*/
private List attachments;
/** /**
* 图片消息 * 图片消息
*/ */
private ImageMessageDto image; //private ImageMessageDto image;
/** /**
* 链接消息 * 链接消息
*/ */
private LinkMessageDto link; //private LinkMessageDto link;
/** /**
* 小程序消息 * 小程序消息
*/ */
private MiniprogramMessageDto miniprogram; //private MiniprogramMessageDto miniprogram;
} }
package com.linkwechat.wecom.service.impl; package com.linkwechat.wecom.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
...@@ -139,46 +140,46 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM ...@@ -139,46 +140,46 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM
* @param customerMessagePushDto 群发消息 * @param customerMessagePushDto 群发消息
*/ */
public void childMessage(WeCustomerMessagePushDto weCustomerMessagePushDto, CustomerMessagePushDto customerMessagePushDto) { public void childMessage(WeCustomerMessagePushDto weCustomerMessagePushDto, CustomerMessagePushDto customerMessagePushDto) {
List list = new ArrayList();
// 消息类型 0 文本消息 1 图片消息 2 链接消息 3 小程序消息 // 消息类型 0 文本消息 1 图片消息 2 链接消息 3 小程序消息
if (customerMessagePushDto.getMessageType().equals(GroupMessageType.TEXT.getType())) { if (customerMessagePushDto.getMessageType().equals(GroupMessageType.TEXT.getType())) {
weCustomerMessagePushDto.setImage(null);
weCustomerMessagePushDto.setLink(null);
weCustomerMessagePushDto.setMiniprogram(null);
weCustomerMessagePushDto.setText(customerMessagePushDto.getTextMessage()); weCustomerMessagePushDto.setText(customerMessagePushDto.getTextMessage());
} }
if (customerMessagePushDto.getMessageType().equals(GroupMessageType.IMAGE.getType())) { if (customerMessagePushDto.getMessageType().equals(GroupMessageType.IMAGE.getType())) {
weCustomerMessagePushDto.setImage(customerMessagePushDto.getImageMessage()); JSONObject jsonObject = new JSONObject();
weCustomerMessagePushDto.setLink(null); jsonObject.put("msgtype","image");
weCustomerMessagePushDto.setMiniprogram(null); jsonObject.put("image",customerMessagePushDto.getImageMessage());
weCustomerMessagePushDto.setText(null); list.add(jsonObject);
} }
if (customerMessagePushDto.getMessageType().equals(GroupMessageType.LINK.getType())) { if (customerMessagePushDto.getMessageType().equals(GroupMessageType.LINK.getType())) {
weCustomerMessagePushDto.setImage(null); JSONObject jsonObject = new JSONObject();
weCustomerMessagePushDto.setLink(customerMessagePushDto.getLinkMessage()); jsonObject.put("msgtype","link");
weCustomerMessagePushDto.setMiniprogram(null); jsonObject.put("link",customerMessagePushDto.getLinkMessage());
weCustomerMessagePushDto.setText(null); list.add(jsonObject);
} }
if (customerMessagePushDto.getMessageType().equals(GroupMessageType.MINIPROGRAM.getType())) { if (customerMessagePushDto.getMessageType().equals(GroupMessageType.MINIPROGRAM.getType())) {
weCustomerMessagePushDto.setImage(null); JSONObject jsonObject = new JSONObject();
weCustomerMessagePushDto.setLink(null); jsonObject.put("msgtype","miniprogram");
weCustomerMessagePushDto.setMiniprogram(customerMessagePushDto.getMiniprogramMessage()); jsonObject.put("miniprogram",customerMessagePushDto.getMiniprogramMessage());
weCustomerMessagePushDto.setText(null); list.add(jsonObject);
} }
if(customerMessagePushDto.getMessageType().equals(GroupMessageType.TEXT_IMAGE.getType())){ if(customerMessagePushDto.getMessageType().equals(GroupMessageType.TEXT_IMAGE.getType())){
weCustomerMessagePushDto.setImage(customerMessagePushDto.getImageMessage()); JSONObject jsonObject = new JSONObject();
weCustomerMessagePushDto.setLink(null); jsonObject.put("msgtype","text_image");
weCustomerMessagePushDto.setMiniprogram(null); jsonObject.put("text_image",customerMessagePushDto.getTextMessage());
weCustomerMessagePushDto.setText(customerMessagePushDto.getTextMessage()); list.add(jsonObject);
} }
if(customerMessagePushDto.getMessageType().equals(GroupMessageType.VIDEO.getType())){
JSONObject jsonObject = new JSONObject();
jsonObject.put("msgtype","video");
jsonObject.put("video",customerMessagePushDto.getVideoDto());
list.add(jsonObject);
}
weCustomerMessagePushDto.setAttachments(list);
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册