Commit 272e0a20 by 18356073052

消息推送任务接口修改

1 parent 0d20299b
package com.linkwechat.wecom.domain.dto; package com.linkwechat.wecom.domain.dto;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
import java.util.Map;
@SuppressWarnings("all") @SuppressWarnings("all")
@Data @Data
@Builder
public class WeMessagePushDto { public class WeMessagePushDto {
/** /**
...@@ -63,303 +60,6 @@ public class WeMessagePushDto { ...@@ -63,303 +60,6 @@ public class WeMessagePushDto {
/** /**
* 根据msgtype的值不同添加一个属性和对应的属性值 * 根据msgtype的值不同添加一个属性和对应的属性值
*/ */
/**
* 文本消息
*/
private Text text;
/**
* 图片消息
*/
private Image image;
/**
* 语音消息
*/
private Voice voice;
/**
* 视频消息
*/
private Video video;
/**
* 文件消息
*/
private File file;
/**
* 文本卡片消息
*/
private TextCard textcard;
/**
* 图文消息
*/
private News news;
/**
* 图文消息(mpnews)
*/
private MpNews mpnews;
/**
* markdown消息
*/
private Markdown markdown;
/**
* miniprogram_notice小程序通知
*/
private MiniprogramNotice miniprogram_notice;
/**
* 任务卡片通知
*/
private TaskCard taskcard;
/**
* 文本消息
*/
@Data
@Builder
public static class Text {
/**
* 消息内容,最长不超过2048个字节,超过将截断(支持id转译)
*/
private String content;
}
/**
* 图片消息
*/
@Data
@Builder
public static class Image {
/**
* 图片媒体文件id,可以调用上传临时素材接口获取
*/
private String media_id;
}
/**
* 语音消息
*/
@Data
@Builder
public static class Voice {
/**
* 语音文件id,可以调用上传临时素材接口获取
*/
private String media_id;
}
/**
* 视频消息
*/
@Data
@Builder
public static class Video {
/**
* 视频媒体文件id,可以调用上传临时素材接口获取
*/
private String media_id;
/**
* 视频消息的标题,不超过128个字节,超过会自动截断
*/
private String title;
/**
* 视频消息的描述,不超过512个字节,超过会自动截断
*/
private String description;
}
/**
* 文件消息
*/
@Data
@Builder
public static class File {
/**
* 文件id,可以调用上传临时素材接口获取
*/
private String media_id;
}
/**
* 文本卡片消息
*/
@Data
@Builder
public static class TextCard {
/**
* 标题,不超过128个字节,超过会自动截断(支持id转译)
*/
private String title;
/**
* 描述,不超过512个字节,超过会自动截断(支持id转译)
*/
private String description;
/**
* 点击后跳转的链接。
*/
private String url;
/**
* 按钮文字。 默认为“详情”, 不超过4个文字,超过自动截断。
*/
private String btntxt;
}
/**
* 图文消息
*/
@Data
@Builder
public static class News {
/**
* 图文消息,一个图文消息支持1到8条图文
*/
private List<Article> articles;
}
/**
* 图文消息(mpnews)
*/
@Data
@Builder
public static class MpNews {
/**
* 图文消息,一个图文消息支持1到8条图文
*/
private List<Article> articles;
}
@Data
@Builder
public static class Article {
/**
* 标题,不超过128个字节,超过会自动截断(支持id转译)
*/
private String title;
/**
* 描述,不超过512个字节,超过会自动截断(支持id转译)
*/
private String description;
/**
* 点击后跳转的链接。
*/
private String url;
/**
* 图文消息的图片链接,支持JPG、PNG格式,较好的效果为大图 1068*455,小图150*150。
*/
private String picurl;
/**
* 图文消息缩略图的media_id, 可以通过素材管理接口获得。此处thumb_media_id即上传接口返回的media_id
*/
private String thumb_media_id;
/**
* 图文消息的作者,不超过64个字节
*/
private String author;
/**
* 图文消息点击“阅读原文”之后的页面链接
*/
private String content_source_url;
/**
* 图文消息的内容,支持html标签,不超过666 K个字节(支持id转译)
*/
private String content;
/**
* 图文消息的描述,不超过512个字节,超过会自动截断(支持id转译)
*/
private String digest;
}
/**
* markdown消息
*/
@Data
@Builder
public static class Markdown {
/**
* markdown内容,最长不超过2048个字节,必须是utf8编码
*/
private String content;
}
/**
* 小程序通知消息
*/
@Data
@Builder
public static class MiniprogramNotice {
/**
* 小程序appid,必须是与当前小程序应用关联的小程序
*/
private String appid;
/**
* 击消息卡片后的小程序页面,仅限本小程序内的页面。该字段不填则消息点击后不跳转。
*/
private String page;
/**
* 消息标题,长度限制4-12个汉字(支持id转译)
*/
private String title;
/**
* 消息描述,长度限制4-12个汉字(支持id转译)
*/
private String description;
/**
* 是否放大第一个content_item
*/
private String emphasis_first_item;
/**
* 消息内容键值对,最多允许10个item {长度10个汉字以内key,长度10个汉字以内value}
*/
private List<Map<String, Object>> content_item;
}
/**
* 任务卡片消息
*/
@Data
@Builder
public static class TaskCard {
/**
* 标题,不超过128个字节,超过会自动截断(支持id转译)
*/
private String title;
/**
* 描述,不超过512个字节,超过会自动截断(支持id转译)
*/
private String description;
/**
* 点击后跳转的链接。最长2048字节,请确保包含了协议头(http/https)
*/
private String url;
/**
* 任务id,同一个应用发送的任务卡片消息的任务id不能重复,只能由数字、字母和“_-@”组成,最长支持128字节
*/
private String task_id;
/**
* 按钮列表,按钮个数为1~2个
*/
private List<Button> btn;
}
@Data
@Builder
public static class Button {
/**
* 按钮key值,用户点击后,会产生任务卡片回调事件,回调事件会带上该key值,只能由数字、字母和“_-@”组成,最长支持128字节
*/
private String key;
/**
* 按钮名称
*/
private String name;
/**
* 点击按钮后显示的名称,默认为“已处理”
*/
private String replace_name;
/**
* 按钮字体颜色,可选“red”或者“blue”,默认为“blue”
*/
private String color;
/**
* 按钮字体是否加粗,默认false
*/
private Boolean is_bold;
}
} }
...@@ -12,9 +12,12 @@ import com.linkwechat.wecom.domain.WeMessagePush; ...@@ -12,9 +12,12 @@ import com.linkwechat.wecom.domain.WeMessagePush;
import com.linkwechat.wecom.domain.dto.WeMessagePushDto; import com.linkwechat.wecom.domain.dto.WeMessagePushDto;
import com.linkwechat.wecom.domain.dto.WeMessagePushResultDto; import com.linkwechat.wecom.domain.dto.WeMessagePushResultDto;
import com.linkwechat.wecom.mapper.WeMessagePushMapper; import com.linkwechat.wecom.mapper.WeMessagePushMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Optional; import java.util.Optional;
...@@ -39,9 +42,9 @@ public class SendMessageToUserStrategy implements Strategy { ...@@ -39,9 +42,9 @@ public class SendMessageToUserStrategy implements Strategy {
of.ifPresent(messageType -> map.put(messageType.getMessageType(), jsonObject)); of.ifPresent(messageType -> map.put(messageType.getMessageType(), jsonObject));
//发送消息 //发送消息
WeMessagePushDto weMessagePushDto = new WeMessagePushDto(); WeMessagePushDto weMessagePushDto = new WeMessagePushDto();
weMessagePushDto.setTouser(weMessagePush.getToUser()); weMessagePushDto.setTouser(StringUtils.isNotBlank(weMessagePush.getToUser()) ? Arrays.asList(weMessagePush.getToUser().split(",")) : new ArrayList<>());
weMessagePushDto.setToparty(weMessagePush.getToParty()); weMessagePushDto.setToparty(StringUtils.isNotBlank(weMessagePush.getToUser()) ? Arrays.asList(weMessagePush.getToParty().split(",")) : new ArrayList<>());
weMessagePushDto.setTotag(weMessagePush.getToTag()); weMessagePushDto.setTotag(StringUtils.isNotBlank(weMessagePush.getToUser()) ? Arrays.asList(weMessagePush.getToTag().split(",")) : new ArrayList<>());
weMessagePushDto.setMsgtype(weMessagePush.getMessageType()); weMessagePushDto.setMsgtype(weMessagePush.getMessageType());
//这个先写在配置文件中 //这个先写在配置文件中
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!