Unverified Commit 622e5bf1 authored by Yang Libin's avatar Yang Libin Committed by GitHub

refactor: support multi-type msg (#41)

parent 12e52f86
package io.github.doocs.im.constant;
/**
* 消息元素类别
*
* @author bingo
* @since 2021/10/29 11:19
*/
public class MsgType {
/**
* 文本消息
*/
public static final String TIM_TEXT_ELEM = "TIMTextElem";
/**
* 地理位置消息
*/
public static final String TIM_LOCATION_ELEM = "TIMLocationElem";
/**
* 表情消息
*/
public static final String TIM_FACE_ELEM = "TIMFaceElem";
/**
* 自定义消息,当接收方为 iOS 系统且应用处在后台时,此消息类型可携带除文本以外的字段到 APNs。一条组合消息中只能包含一个 TIMCustomElem 自定义消息元素
*/
public static final String TIM_CUSTOM_ELEM = "TIMCustomElem";
/**
* 语音消息
*/
public static final String TIM_SOUND_ELEM = "TIMSoundElem";
/**
* 图像消息
*/
public static final String TIM_IMAGE_ELEM = "TIMImageElem";
/**
* 文件消息
*/
public static final String TIM_FILE_ELEM = "TIMFileElem";
/**
* 视频消息
*/
public static final String TIM_VIDEO_FILE_ELEM = "TIMVideoFileElem";
}
package io.github.doocs.im.model.message;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.doocs.im.constant.MsgType;
/**
* 自定义消息元素
*
* @author bingo
* @since 2021/10/29 16:42
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TIMCustomMsgElement extends TIMMsgElement {
@JsonProperty("MsgContent")
private CustomMsgContent msgContent;
public TIMCustomMsgElement() {
super(MsgType.TIM_CUSTOM_ELEM);
}
public TIMCustomMsgElement(CustomMsgContent msgContent) {
this();
this.msgContent = msgContent;
}
public TIMCustomMsgElement(String data, String desc, String ext, String sound) {
this(new CustomMsgContent(data, desc, ext, sound));
}
public CustomMsgContent getMsgContent() {
return msgContent;
}
public void setMsgContent(CustomMsgContent msgContent) {
this.msgContent = msgContent;
}
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class CustomMsgContent {
@JsonProperty("Data")
private String data;
@JsonProperty("Desc")
private String desc;
@JsonProperty("Ext")
private String ext;
@JsonProperty("Sound")
private String sound;
public CustomMsgContent() {
}
public CustomMsgContent(String data, String desc, String ext, String sound) {
this.data = data;
this.desc = desc;
this.ext = ext;
this.sound = sound;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getExt() {
return ext;
}
public void setExt(String ext) {
this.ext = ext;
}
public String getSound() {
return sound;
}
public void setSound(String sound) {
this.sound = sound;
}
}
}
package io.github.doocs.im.model.message;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.doocs.im.constant.MsgType;
/**
* 表情消息元素
*
* @author bingo
* @since 2021/10/29 16:39
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TIMFaceMsgElement extends TIMMsgElement {
@JsonProperty("MsgContent")
private FaceMsgContent msgContent;
public TIMFaceMsgElement() {
super(MsgType.TIM_FACE_ELEM);
}
public TIMFaceMsgElement(FaceMsgContent msgContent) {
this();
this.msgContent = msgContent;
}
public TIMFaceMsgElement(Integer index, String data) {
this(new FaceMsgContent(index, data));
}
public FaceMsgContent getMsgContent() {
return msgContent;
}
public void setMsgContent(FaceMsgContent msgContent) {
this.msgContent = msgContent;
}
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class FaceMsgContent {
@JsonProperty("Index")
private Integer index;
@JsonProperty("Data")
private String data;
public FaceMsgContent() {
}
public FaceMsgContent(Integer index, String data) {
this.index = index;
this.data = data;
}
public Integer getIndex() {
return index;
}
public void setIndex(Integer index) {
this.index = index;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
}
}
package io.github.doocs.im.model.message;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.doocs.im.constant.MsgType;
/**
* 文件消息元素
*
* @author bingo
* @since 2021/10/29 16:53
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TIMFileMsgElement extends TIMMsgElement {
@JsonProperty("MsgContent")
private FileMsgContent msgContent;
public TIMFileMsgElement() {
super(MsgType.TIM_FILE_ELEM);
}
public TIMFileMsgElement(FileMsgContent msgContent) {
this();
this.msgContent = msgContent;
}
public TIMFileMsgElement(String url, String uuid, Integer fileSize, String filename, Integer downloadFlag) {
this(new FileMsgContent(url, uuid, fileSize, filename, downloadFlag));
}
public FileMsgContent getMsgContent() {
return msgContent;
}
public void setMsgContent(FileMsgContent msgContent) {
this.msgContent = msgContent;
}
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class FileMsgContent {
@JsonProperty("Url")
private String url;
@JsonProperty("UUID")
private String uuid;
@JsonProperty("FileSize")
private Integer fileSize;
@JsonProperty("FileName")
private String filename;
@JsonProperty("Download_Flag")
private Integer downloadFlag;
public FileMsgContent() {
}
public FileMsgContent(String url, String uuid, Integer fileSize, String filename, Integer downloadFlag) {
this.url = url;
this.uuid = uuid;
this.fileSize = fileSize;
this.filename = filename;
this.downloadFlag = downloadFlag;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public Integer getFileSize() {
return fileSize;
}
public void setFileSize(Integer fileSize) {
this.fileSize = fileSize;
}
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
public Integer getDownloadFlag() {
return downloadFlag;
}
public void setDownloadFlag(Integer downloadFlag) {
this.downloadFlag = downloadFlag;
}
}
}
package io.github.doocs.im.model.message;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.doocs.im.constant.MsgType;
import java.util.List;
/**
* 图像消息元素
*
* @author bingo
* @since 2021/10/29 16:48
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TIMImageMsgElement extends TIMMsgElement {
@JsonProperty("MsgContent")
private ImageMsgContent msgContent;
public TIMImageMsgElement() {
super(MsgType.TIM_IMAGE_ELEM);
}
public TIMImageMsgElement(ImageMsgContent msgContent) {
this();
this.msgContent = msgContent;
}
public TIMImageMsgElement(String uuid, Integer imageFormat, List<ImageInfo> imageInfoArray) {
this(new ImageMsgContent(uuid, imageFormat, imageInfoArray));
}
public ImageMsgContent getMsgContent() {
return msgContent;
}
public void setMsgContent(ImageMsgContent msgContent) {
this.msgContent = msgContent;
}
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class ImageMsgContent {
@JsonProperty("UUID")
private String uuid;
@JsonProperty("ImageFormat")
private Integer imageFormat;
@JsonProperty("ImageInfoArray")
private List<ImageInfo> imageInfoArray;
public ImageMsgContent() {
}
public ImageMsgContent(String uuid, Integer imageFormat, List<ImageInfo> imageInfoArray) {
this.uuid = uuid;
this.imageFormat = imageFormat;
this.imageInfoArray = imageInfoArray;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public Integer getImageFormat() {
return imageFormat;
}
public void setImageFormat(Integer imageFormat) {
this.imageFormat = imageFormat;
}
public List<ImageInfo> getImageInfoArray() {
return imageInfoArray;
}
public void setImageInfoArray(List<ImageInfo> imageInfoArray) {
this.imageInfoArray = imageInfoArray;
}
}
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class ImageInfo {
@JsonProperty("Type")
private Integer type;
@JsonProperty("Size")
private Integer size;
@JsonProperty("Width")
private Integer width;
@JsonProperty("Height")
private Integer height;
@JsonProperty("URL")
private String url;
public ImageInfo() {
}
public ImageInfo(Integer type, Integer size, Integer width, Integer height, String url) {
this.type = type;
this.size = size;
this.width = width;
this.height = height;
this.url = url;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getSize() {
return size;
}
public void setSize(Integer size) {
this.size = size;
}
public Integer getWidth() {
return width;
}
public void setWidth(Integer width) {
this.width = width;
}
public Integer getHeight() {
return height;
}
public void setHeight(Integer height) {
this.height = height;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
}
package io.github.doocs.im.model.message;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.doocs.im.constant.MsgType;
/**
* 地理位置消息元素
*
* @author bingo
* @since 2021/10/29 16:35
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TIMLocationMsgElement extends TIMMsgElement {
@JsonProperty("MsgContent")
private LocationMsgContent msgContent;
public TIMLocationMsgElement() {
super(MsgType.TIM_LOCATION_ELEM);
}
public TIMLocationMsgElement(LocationMsgContent msgContent) {
this();
this.msgContent = msgContent;
}
public TIMLocationMsgElement(String desc, Double latitude, Double longitude) {
this(new LocationMsgContent(desc, latitude, longitude));
}
public LocationMsgContent getMsgContent() {
return msgContent;
}
public void setMsgContent(LocationMsgContent msgContent) {
this.msgContent = msgContent;
}
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class LocationMsgContent {
@JsonProperty("Desc")
private String desc;
@JsonProperty("Latitude")
private Double latitude;
@JsonProperty("Longitude")
private Double longitude;
public LocationMsgContent() {
}
public LocationMsgContent(String desc, Double latitude, Double longitude) {
this.desc = desc;
this.latitude = latitude;
this.longitude = longitude;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public Double getLatitude() {
return latitude;
}
public void setLatitude(Double latitude) {
this.latitude = latitude;
}
public Double getLongitude() {
return longitude;
}
public void setLongitude(Double longitude) {
this.longitude = longitude;
}
}
}
package io.github.doocs.im.model.message;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* 抽象消息元素
*
* @author bingo
* @since 2021/10/29 16:24
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public abstract class TIMMsgElement {
@JsonProperty("MsgType")
private String msgType;
public TIMMsgElement(String msgType) {
this.msgType = msgType;
}
public String getMsgType() {
return msgType;
}
}
package io.github.doocs.im.model.message;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.doocs.im.constant.MsgType;
/**
* 语音消息元素
*
* @author bingo
* @since 2021/10/29 16:44
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TIMSoundMsgElement extends TIMMsgElement {
@JsonProperty("MsgContent")
private SoundMsgContent msgContent;
public TIMSoundMsgElement() {
super(MsgType.TIM_SOUND_ELEM);
}
public TIMSoundMsgElement(SoundMsgContent msgContent) {
this();
this.msgContent = msgContent;
}
public TIMSoundMsgElement(String url, String uuid, Integer size, Integer second, Integer downloadFlag) {
this(new SoundMsgContent(url, uuid, size, second, downloadFlag));
}
public SoundMsgContent getMsgContent() {
return msgContent;
}
public void setMsgContent(SoundMsgContent msgContent) {
this.msgContent = msgContent;
}
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class SoundMsgContent {
@JsonProperty("Url")
private String url;
@JsonProperty("UUID")
private String uuid;
@JsonProperty("Size")
private Integer size;
@JsonProperty("Second")
private Integer second;
@JsonProperty("Download_Flag")
private Integer downloadFlag;
public SoundMsgContent() {
}
public SoundMsgContent(String url, String uuid, Integer size, Integer second, Integer downloadFlag) {
this.url = url;
this.uuid = uuid;
this.size = size;
this.second = second;
this.downloadFlag = downloadFlag;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public Integer getSize() {
return size;
}
public void setSize(Integer size) {
this.size = size;
}
public Integer getSecond() {
return second;
}
public void setSecond(Integer second) {
this.second = second;
}
public Integer getDownloadFlag() {
return downloadFlag;
}
public void setDownloadFlag(Integer downloadFlag) {
this.downloadFlag = downloadFlag;
}
}
}
package io.github.doocs.im.model.message;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.doocs.im.constant.MsgType;
/**
* 文本消息元素
*
* @author bingo
* @since 2021/10/29 16:25
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TIMTextMsgElement extends TIMMsgElement {
@JsonProperty("MsgContent")
private TextMsgContent msgContent;
public TIMTextMsgElement() {
super(MsgType.TIM_TEXT_ELEM);
}
public TIMTextMsgElement(TextMsgContent msgContent) {
this();
this.msgContent = msgContent;
}
public TIMTextMsgElement(String text) {
this(new TextMsgContent(text));
}
public TextMsgContent getMsgContent() {
return msgContent;
}
public void setMsgContent(TextMsgContent msgContent) {
this.msgContent = msgContent;
}
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class TextMsgContent {
@JsonProperty("Text")
private String text;
public TextMsgContent() {
}
public TextMsgContent(String text) {
this.text = text;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
}
package io.github.doocs.im.model.message;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.doocs.im.constant.MsgType;
/**
* 视频消息元素
*
* @author bingo
* @since 2021/10/29 16:56
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TIMVideoFileMsgElement extends TIMMsgElement {
@JsonProperty("MsgContent")
private VideoFileMsgContent msgContent;
public TIMVideoFileMsgElement() {
super(MsgType.TIM_VIDEO_FILE_ELEM);
}
public TIMVideoFileMsgElement(VideoFileMsgContent msgContent) {
this();
this.msgContent = msgContent;
}
public TIMVideoFileMsgElement(String videoUrl, String videoUuid, Integer videoSize, Integer videoSecond, String videoFormat, Integer videoDownloadFlag, String thumbUrl, String thumbUuid, Integer thumbSize, Integer thumbWidth, Integer thumbHeight, String thumbFormat, Integer thumbDownloadFlag) {
this(new VideoFileMsgContent(videoUrl, videoUuid, videoSize, videoSecond, videoFormat, videoDownloadFlag, thumbUrl, thumbUuid, thumbSize, thumbWidth, thumbHeight, thumbFormat, thumbDownloadFlag));
}
public VideoFileMsgContent getMsgContent() {
return msgContent;
}
public void setMsgContent(VideoFileMsgContent msgContent) {
this.msgContent = msgContent;
}
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class VideoFileMsgContent {
@JsonProperty("VideoUrl")
private String videoUrl;
@JsonProperty("VideoUUID")
private String videoUuid;
@JsonProperty("VideoSize")
private Integer videoSize;
@JsonProperty("VideoSecond")
private Integer videoSecond;
@JsonProperty("VideoFormat")
private String videoFormat;
@JsonProperty("VideoDownloadFlag")
private Integer videoDownloadFlag;
@JsonProperty("ThumbUrl")
private String thumbUrl;
@JsonProperty("ThumbUUID")
private String thumbUuid;
@JsonProperty("ThumbSize")
private Integer thumbSize;
@JsonProperty("ThumbWidth")
private Integer thumbWidth;
@JsonProperty("ThumbHeight")
private Integer thumbHeight;
@JsonProperty("ThumbFormat")
private String thumbFormat;
@JsonProperty("ThumbDownloadFlag")
private Integer thumbDownloadFlag;
public VideoFileMsgContent() {
}
public VideoFileMsgContent(String videoUrl, String videoUuid, Integer videoSize, Integer videoSecond, String videoFormat, Integer videoDownloadFlag, String thumbUrl, String thumbUuid, Integer thumbSize, Integer thumbWidth, Integer thumbHeight, String thumbFormat, Integer thumbDownloadFlag) {
this.videoUrl = videoUrl;
this.videoUuid = videoUuid;
this.videoSize = videoSize;
this.videoSecond = videoSecond;
this.videoFormat = videoFormat;
this.videoDownloadFlag = videoDownloadFlag;
this.thumbUrl = thumbUrl;
this.thumbUuid = thumbUuid;
this.thumbSize = thumbSize;
this.thumbWidth = thumbWidth;
this.thumbHeight = thumbHeight;
this.thumbFormat = thumbFormat;
this.thumbDownloadFlag = thumbDownloadFlag;
}
public String getVideoUrl() {
return videoUrl;
}
public void setVideoUrl(String videoUrl) {
this.videoUrl = videoUrl;
}
public String getVideoUuid() {
return videoUuid;
}
public void setVideoUuid(String videoUuid) {
this.videoUuid = videoUuid;
}
public Integer getVideoSize() {
return videoSize;
}
public void setVideoSize(Integer videoSize) {
this.videoSize = videoSize;
}
public Integer getVideoSecond() {
return videoSecond;
}
public void setVideoSecond(Integer videoSecond) {
this.videoSecond = videoSecond;
}
public String getVideoFormat() {
return videoFormat;
}
public void setVideoFormat(String videoFormat) {
this.videoFormat = videoFormat;
}
public Integer getVideoDownloadFlag() {
return videoDownloadFlag;
}
public void setVideoDownloadFlag(Integer videoDownloadFlag) {
this.videoDownloadFlag = videoDownloadFlag;
}
public String getThumbUrl() {
return thumbUrl;
}
public void setThumbUrl(String thumbUrl) {
this.thumbUrl = thumbUrl;
}
public String getThumbUuid() {
return thumbUuid;
}
public void setThumbUuid(String thumbUuid) {
this.thumbUuid = thumbUuid;
}
public Integer getThumbSize() {
return thumbSize;
}
public void setThumbSize(Integer thumbSize) {
this.thumbSize = thumbSize;
}
public Integer getThumbWidth() {
return thumbWidth;
}
public void setThumbWidth(Integer thumbWidth) {
this.thumbWidth = thumbWidth;
}
public Integer getThumbHeight() {
return thumbHeight;
}
public void setThumbHeight(Integer thumbHeight) {
this.thumbHeight = thumbHeight;
}
public String getThumbFormat() {
return thumbFormat;
}
public void setThumbFormat(String thumbFormat) {
this.thumbFormat = thumbFormat;
}
public Integer getThumbDownloadFlag() {
return thumbDownloadFlag;
}
public void setThumbDownloadFlag(Integer thumbDownloadFlag) {
this.thumbDownloadFlag = thumbDownloadFlag;
}
}
}
......@@ -2,7 +2,7 @@ package io.github.doocs.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.doocs.im.model.response.MsgBodyItem;
import io.github.doocs.im.model.message.TIMMsgElement;
import java.util.List;
......@@ -28,7 +28,7 @@ public class BatchSendMsgRequest {
private Integer msgRandom;
@JsonProperty("MsgBody")
private List<MsgBodyItem> msgBody;
private List<TIMMsgElement> msgBody;
@JsonProperty("CloudCustomData")
private String cloudCustomData;
......@@ -42,7 +42,7 @@ public class BatchSendMsgRequest {
public BatchSendMsgRequest() {
}
public BatchSendMsgRequest(Integer syncOtherMachine, String fromAccount, List<String> toAccount, Integer msgSeq, Integer msgRandom, List<MsgBodyItem> msgBody, String cloudCustomData, List<String> sendMsgControl, OfflinePushInfo offlinePushInfo) {
public BatchSendMsgRequest(Integer syncOtherMachine, String fromAccount, List<String> toAccount, Integer msgSeq, Integer msgRandom, List<TIMMsgElement> msgBody, String cloudCustomData, List<String> sendMsgControl, OfflinePushInfo offlinePushInfo) {
this.syncOtherMachine = syncOtherMachine;
this.fromAccount = fromAccount;
this.toAccount = toAccount;
......@@ -94,11 +94,11 @@ public class BatchSendMsgRequest {
this.msgRandom = msgRandom;
}
public List<MsgBodyItem> getMsgBody() {
public List<TIMMsgElement> getMsgBody() {
return msgBody;
}
public void setMsgBody(List<MsgBodyItem> msgBody) {
public void setMsgBody(List<TIMMsgElement> msgBody) {
this.msgBody = msgBody;
}
......
......@@ -2,7 +2,7 @@ package io.github.doocs.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.doocs.im.model.response.MsgBodyItem;
import io.github.doocs.im.model.message.TIMMsgElement;
import java.util.List;
import java.util.Map;
......@@ -20,7 +20,7 @@ public class IMPushRequest extends GenericRequest {
private Integer msgRandom;
@JsonProperty("MsgBody")
private List<MsgBodyItem> msgBody;
private List<TIMMsgElement> msgBody;
@JsonProperty("MsgLifeTime")
private Integer msgLifeTime;
......@@ -31,6 +31,18 @@ public class IMPushRequest extends GenericRequest {
@JsonProperty("OfflinePushInfo")
private OfflinePushInfo offlinePushInfo;
public IMPushRequest() {
}
public IMPushRequest(Map<String, Object> condition, Integer msgRandom, List<TIMMsgElement> msgBody, Integer msgLifeTime, String fromAccount, OfflinePushInfo offlinePushInfo) {
this.condition = condition;
this.msgRandom = msgRandom;
this.msgBody = msgBody;
this.msgLifeTime = msgLifeTime;
this.fromAccount = fromAccount;
this.offlinePushInfo = offlinePushInfo;
}
public Map<String, Object> getCondition() {
return condition;
}
......@@ -47,11 +59,11 @@ public class IMPushRequest extends GenericRequest {
this.msgRandom = msgRandom;
}
public List<MsgBodyItem> getMsgBody() {
public List<TIMMsgElement> getMsgBody() {
return msgBody;
}
public void setMsgBody(List<MsgBodyItem> msgBody) {
public void setMsgBody(List<TIMMsgElement> msgBody) {
this.msgBody = msgBody;
}
......
......@@ -2,7 +2,7 @@ package io.github.doocs.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.doocs.im.model.response.MsgBodyItem;
import io.github.doocs.im.model.message.TIMMsgElement;
import java.util.List;
......@@ -22,7 +22,17 @@ public class ImportGroupMsgListItem {
private Integer random;
@JsonProperty("MsgBody")
private List<MsgBodyItem> msgBody;
private List<TIMMsgElement> msgBody;
public ImportGroupMsgListItem() {
}
public ImportGroupMsgListItem(String fromAccount, Integer sendTime, Integer random, List<TIMMsgElement> msgBody) {
this.fromAccount = fromAccount;
this.sendTime = sendTime;
this.random = random;
this.msgBody = msgBody;
}
public String getFromAccount() {
return fromAccount;
......@@ -48,11 +58,11 @@ public class ImportGroupMsgListItem {
this.random = random;
}
public List<MsgBodyItem> getMsgBody() {
public List<TIMMsgElement> getMsgBody() {
return msgBody;
}
public void setMsgBody(List<MsgBodyItem> msgBody) {
public void setMsgBody(List<TIMMsgElement> msgBody) {
this.msgBody = msgBody;
}
}
......@@ -2,7 +2,7 @@ package io.github.doocs.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.doocs.im.model.response.MsgBodyItem;
import io.github.doocs.im.model.message.TIMMsgElement;
import java.util.List;
......@@ -31,7 +31,7 @@ public class ImportMsgRequest extends GenericRequest {
private Integer msgTimeStamp;
@JsonProperty("MsgBody")
private List<MsgBodyItem> msgBody;
private List<TIMMsgElement> msgBody;
@JsonProperty("CloudCustomData")
private String cloudCustomData;
......@@ -39,7 +39,7 @@ public class ImportMsgRequest extends GenericRequest {
public ImportMsgRequest() {
}
public ImportMsgRequest(Integer syncFromOldSystem, String fromAccount, String toAccount, Integer msgSeq, Integer msgRandom, Integer msgTimeStamp, List<MsgBodyItem> msgBody, String cloudCustomData) {
public ImportMsgRequest(Integer syncFromOldSystem, String fromAccount, String toAccount, Integer msgSeq, Integer msgRandom, Integer msgTimeStamp, List<TIMMsgElement> msgBody, String cloudCustomData) {
this.syncFromOldSystem = syncFromOldSystem;
this.fromAccount = fromAccount;
this.toAccount = toAccount;
......@@ -98,11 +98,11 @@ public class ImportMsgRequest extends GenericRequest {
this.msgTimeStamp = msgTimeStamp;
}
public List<MsgBodyItem> getMsgBody() {
public List<TIMMsgElement> getMsgBody() {
return msgBody;
}
public void setMsgBody(List<MsgBodyItem> msgBody) {
public void setMsgBody(List<TIMMsgElement> msgBody) {
this.msgBody = msgBody;
}
......
......@@ -2,7 +2,7 @@ package io.github.doocs.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.doocs.im.model.response.MsgBodyItem;
import io.github.doocs.im.model.message.TIMMsgElement;
import java.util.List;
......@@ -22,12 +22,12 @@ public class MsgGroupItem {
private Integer random;
@JsonProperty("MsgBody")
private List<MsgBodyItem> msgBody;
private List<TIMMsgElement> msgBody;
public MsgGroupItem() {
}
public MsgGroupItem(String fromAccount, Integer sendTime, Integer random, List<MsgBodyItem> msgBody) {
public MsgGroupItem(String fromAccount, Integer sendTime, Integer random, List<TIMMsgElement> msgBody) {
this.fromAccount = fromAccount;
this.sendTime = sendTime;
this.random = random;
......@@ -58,11 +58,11 @@ public class MsgGroupItem {
this.random = random;
}
public List<MsgBodyItem> getMsgBody() {
public List<TIMMsgElement> getMsgBody() {
return msgBody;
}
public void setMsgBody(List<MsgBodyItem> msgBody) {
public void setMsgBody(List<TIMMsgElement> msgBody) {
this.msgBody = msgBody;
}
}
......
......@@ -2,7 +2,7 @@ package io.github.doocs.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.doocs.im.model.response.MsgBodyItem;
import io.github.doocs.im.model.message.TIMMsgElement;
import java.util.List;
......@@ -22,7 +22,7 @@ public class SendGroupMsgRequest extends GenericRequest {
private String msgPriority;
@JsonProperty("MsgBody")
private List<MsgBodyItem> msgBody;
private List<TIMMsgElement> msgBody;
@JsonProperty("From_Account")
private String fromAccount;
......@@ -45,7 +45,7 @@ public class SendGroupMsgRequest extends GenericRequest {
public SendGroupMsgRequest() {
}
public SendGroupMsgRequest(String groupId, Integer random, String msgPriority, List<MsgBodyItem> msgBody, String fromAccount, OfflinePushInfo offlinePushInfo, List<String> forbidCallbackControl, Integer onlineOnlyFlag, List<String> sendMsgControl, String cloudCustomData) {
public SendGroupMsgRequest(String groupId, Integer random, String msgPriority, List<TIMMsgElement> msgBody, String fromAccount, OfflinePushInfo offlinePushInfo, List<String> forbidCallbackControl, Integer onlineOnlyFlag, List<String> sendMsgControl, String cloudCustomData) {
this.groupId = groupId;
this.random = random;
this.msgPriority = msgPriority;
......@@ -82,11 +82,11 @@ public class SendGroupMsgRequest extends GenericRequest {
this.msgPriority = msgPriority;
}
public List<MsgBodyItem> getMsgBody() {
public List<TIMMsgElement> getMsgBody() {
return msgBody;
}
public void setMsgBody(List<MsgBodyItem> msgBody) {
public void setMsgBody(List<TIMMsgElement> msgBody) {
this.msgBody = msgBody;
}
......
......@@ -2,7 +2,7 @@ package io.github.doocs.im.model.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.doocs.im.model.response.MsgBodyItem;
import io.github.doocs.im.model.message.TIMMsgElement;
import java.util.List;
......@@ -40,7 +40,7 @@ public class SendMsgRequest extends GenericRequest {
private List<String> sendMsgControl;
@JsonProperty("MsgBody")
private List<MsgBodyItem> msgBody;
private List<TIMMsgElement> msgBody;
@JsonProperty("CloudCustomData")
private String cloudCustomData;
......@@ -51,7 +51,7 @@ public class SendMsgRequest extends GenericRequest {
public SendMsgRequest() {
}
public SendMsgRequest(Integer syncOtherMachine, String fromAccount, String toAccount, Integer msgLifeTime, Integer msgSeq, Integer msgRandom, Integer msgTimeStamp, List<String> forbidCallbackControl, List<String> sendMsgControl, List<MsgBodyItem> msgBody, String cloudCustomData, OfflinePushInfo offlinePushInfo) {
public SendMsgRequest(Integer syncOtherMachine, String fromAccount, String toAccount, Integer msgLifeTime, Integer msgSeq, Integer msgRandom, Integer msgTimeStamp, List<String> forbidCallbackControl, List<String> sendMsgControl, List<TIMMsgElement> msgBody, String cloudCustomData, OfflinePushInfo offlinePushInfo) {
this.syncOtherMachine = syncOtherMachine;
this.fromAccount = fromAccount;
this.toAccount = toAccount;
......@@ -138,11 +138,11 @@ public class SendMsgRequest extends GenericRequest {
this.sendMsgControl = sendMsgControl;
}
public List<MsgBodyItem> getMsgBody() {
public List<TIMMsgElement> getMsgBody() {
return msgBody;
}
public void setMsgBody(List<MsgBodyItem> msgBody) {
public void setMsgBody(List<TIMMsgElement> msgBody) {
this.msgBody = msgBody;
}
......
package io.github.doocs.im.model.response;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author hyh
* @since 2021/07/28 20:42
*/
public class MsgBodyItem {
@JsonProperty("MsgType")
private String msgType;
@JsonProperty("MsgContent")
private Object msgContent;
public String getMsgType() {
return msgType;
}
public void setMsgType(String msgType) {
this.msgType = msgType;
}
public Object getMsgContent() {
return msgContent;
}
public void setMsgContent(Object msgContent) {
this.msgContent = msgContent;
}
@Override
public String toString() {
return "MsgBodyItem{" +
"msgType='" + msgType + '\'' +
", msgContent=" + msgContent +
'}';
}
}
package io.github.doocs.im.model.response;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author hyh
* @since 2021/07/28 20:52
*/
public class MsgContentItem {
@JsonProperty("Text")
private String text;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
package io.github.doocs.im.model.response;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.doocs.im.model.message.TIMMsgElement;
import java.util.List;
......@@ -31,11 +32,26 @@ public class MsgListItem {
private String msgKey;
@JsonProperty("MsgBody")
private List<MsgBodyItem> msgBody;
private List<TIMMsgElement> msgBody;
@JsonProperty("CloudCustomData")
private String cloudCustomData;
public MsgListItem() {
}
public MsgListItem(String fromAccount, String toAccount, Integer msgSeq, Integer msgRandom, Integer msgTimeStamp, Integer msgFlagBits, String msgKey, List<TIMMsgElement> msgBody, String cloudCustomData) {
this.fromAccount = fromAccount;
this.toAccount = toAccount;
this.msgSeq = msgSeq;
this.msgRandom = msgRandom;
this.msgTimeStamp = msgTimeStamp;
this.msgFlagBits = msgFlagBits;
this.msgKey = msgKey;
this.msgBody = msgBody;
this.cloudCustomData = cloudCustomData;
}
public String getFromAccount() {
return fromAccount;
}
......@@ -92,11 +108,11 @@ public class MsgListItem {
this.msgKey = msgKey;
}
public List<MsgBodyItem> getMsgBody() {
public List<TIMMsgElement> getMsgBody() {
return msgBody;
}
public void setMsgBody(List<MsgBodyItem> msgBody) {
public void setMsgBody(List<TIMMsgElement> msgBody) {
this.msgBody = msgBody;
}
......
package io.github.doocs.im.model.response;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.doocs.im.model.message.TIMMsgElement;
import java.util.List;
......@@ -16,7 +17,7 @@ public class RspMsgItem {
private Integer isPlaceMsg;
@JsonProperty("MsgBody")
private List<MsgBodyItem> msgBody;
private List<TIMMsgElement> msgBody;
@JsonProperty("MsgPriority")
private Integer msgPriority;
......@@ -30,6 +31,19 @@ public class RspMsgItem {
@JsonProperty("MsgTimeStamp")
private Integer msgTimeStamp;
public RspMsgItem() {
}
public RspMsgItem(String fromAccount, Integer isPlaceMsg, List<TIMMsgElement> msgBody, Integer msgPriority, Integer msgRandom, Integer msgSeq, Integer msgTimeStamp) {
this.fromAccount = fromAccount;
this.isPlaceMsg = isPlaceMsg;
this.msgBody = msgBody;
this.msgPriority = msgPriority;
this.msgRandom = msgRandom;
this.msgSeq = msgSeq;
this.msgTimeStamp = msgTimeStamp;
}
public String getFromAccount() {
return fromAccount;
}
......@@ -46,11 +60,11 @@ public class RspMsgItem {
this.isPlaceMsg = isPlaceMsg;
}
public List<MsgBodyItem> getMsgBody() {
public List<TIMMsgElement> getMsgBody() {
return msgBody;
}
public void setMsgBody(List<MsgBodyItem> msgBody) {
public void setMsgBody(List<TIMMsgElement> msgBody) {
this.msgBody = msgBody;
}
......@@ -85,17 +99,4 @@ public class RspMsgItem {
public void setMsgTimeStamp(Integer msgTimeStamp) {
this.msgTimeStamp = msgTimeStamp;
}
@Override
public String toString() {
return "RspMsgItem{" +
"fromAccount='" + fromAccount + '\'' +
", isPlaceMsg=" + isPlaceMsg +
", msgBody=" + msgBody +
", msgPriority=" + msgPriority +
", msgRandom=" + msgRandom +
", msgSeq=" + msgSeq +
", msgTimeStamp=" + msgTimeStamp +
'}';
}
}
package io.github.doocs.im;
import io.github.doocs.im.model.message.TIMTextMsgElement;
import io.github.doocs.im.model.request.*;
import io.github.doocs.im.model.response.*;
import org.junit.Assert;
......@@ -185,13 +186,12 @@ public class GroupTest {
SendGroupMsgRequest request = new SendGroupMsgRequest();
request.setRandom(1212);
request.setGroupId("MyFirstGroup");
MsgBodyItem item = new MsgBodyItem();
item.setMsgType("TIMTextElem");
MsgContentItem contentItem = new MsgContentItem();
contentItem.setText("red packet");
item.setMsgContent(contentItem);
request.setMsgBody(Collections.singletonList(item));
TIMTextMsgElement msg = new TIMTextMsgElement("red packet");
request.setMsgBody(Collections.singletonList(msg));
SendGroupMsgResult result = client.group.sendGroupMsg(request);
System.out.println(result);
Assert.assertEquals(0, (int) result.getErrorCode());
}
......@@ -249,12 +249,8 @@ public class GroupTest {
item.setFromAccount("bingo");
item.setSendTime(1628062005);
MsgBodyItem bodyItem = new MsgBodyItem();
MsgContentItem contentItem = new MsgContentItem();
contentItem.setText("hello world");
bodyItem.setMsgContent(contentItem);
bodyItem.setMsgType("TIMTextElem");
item.setMsgBody(Collections.singletonList(bodyItem));
TIMTextMsgElement msg = new TIMTextMsgElement("hello world");
item.setMsgBody(Collections.singletonList(msg));
request.setMsgList(Collections.singletonList(item));
ImportGroupMsgResult result = client.group.importGroupMsg(request);
......
package io.github.doocs.im;
import io.github.doocs.im.model.message.TIMTextMsgElement;
import io.github.doocs.im.model.request.*;
import io.github.doocs.im.model.response.*;
import org.junit.Assert;
......@@ -36,11 +37,8 @@ public class MemberTest {
request.setFromAccount("admin");
request.setMsgRandom(9312457);
request.setMsgLifeTime(120);
MsgBodyItem item = new MsgBodyItem();
MsgContentItem contentItem = new MsgContentItem();
contentItem.setText("hi, beauty");
item.setMsgContent(contentItem);
request.setMsgBody(Collections.singletonList(item));
TIMTextMsgElement msg = new TIMTextMsgElement("hi, beauty");
request.setMsgBody(Collections.singletonList(msg));
IMPushResult result = client.member.imPush(request);
System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus());
......
package io.github.doocs.im;
import io.github.doocs.im.model.message.TIMTextMsgElement;
import io.github.doocs.im.model.request.*;
import io.github.doocs.im.model.response.*;
import org.junit.Assert;
......@@ -41,12 +42,8 @@ public class MessageTest {
request.setMsgRandom(123);
request.setMsgTimeStamp(1631934058);
request.setMsgLifeTime(604800);
MsgBodyItem item = new MsgBodyItem();
item.setMsgType("TIMTextElem");
MsgContentItem contentItem = new MsgContentItem();
contentItem.setText("hello world");
item.setMsgContent(contentItem);
request.setMsgBody(Collections.singletonList(item));
TIMTextMsgElement msg = new TIMTextMsgElement("hello world");
request.setMsgBody(Collections.singletonList(msg));
SendMsgResult result = client.message.sendMsg(request);
System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus());
......@@ -59,12 +56,8 @@ public class MessageTest {
request.setToAccount(Arrays.asList("test1", "test2"));
request.setMsgSeq(28460);
request.setMsgRandom(1992121);
MsgBodyItem item = new MsgBodyItem();
item.setMsgType("TIMTextElem");
MsgContentItem contentItem = new MsgContentItem();
contentItem.setText("hi bingo");
item.setMsgContent(contentItem);
request.setMsgBody(Collections.singletonList(item));
TIMTextMsgElement msg = new TIMTextMsgElement("hi bingo");
request.setMsgBody(Collections.singletonList(msg));
BatchSendMsgResult result = client.message.batchSendMsg(request);
System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus());
......@@ -79,12 +72,8 @@ public class MessageTest {
request.setMsgSeq(123);
request.setMsgRandom(122);
request.setMsgTimeStamp(1557387418);
MsgBodyItem item = new MsgBodyItem();
item.setMsgType("TIMTextElem");
MsgContentItem contentItem = new MsgContentItem();
contentItem.setText("hello bingo");
item.setMsgContent(contentItem);
request.setMsgBody(Collections.singletonList(item));
TIMTextMsgElement msg = new TIMTextMsgElement("hello bingo");
request.setMsgBody(Collections.singletonList(msg));
ImportMsgResult result = client.message.importMsg(request);
System.out.println(result);
Assert.assertEquals("OK", result.getActionStatus());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment