This commit is contained in:
dute7liang
2024-01-29 21:29:17 +08:00
parent e200a7bac3
commit ea111d983e
21 changed files with 399 additions and 14 deletions

View File

@@ -3,6 +3,7 @@ package com.ruoyi.yunxin;
import com.alibaba.fastjson2.JSON;
import com.ruoyi.yunxin.client.ImMessageClient;
import com.ruoyi.yunxin.config.YunxinProperties;
import com.ruoyi.yunxin.enums.ImTypeEnum;
import com.ruoyi.yunxin.req.*;
import com.ruoyi.yunxin.req.type.YxTextData;
import com.ruoyi.yunxin.resp.SendMsgResp;
@@ -56,6 +57,18 @@ public class Yunxin {
return messageClient.sendBatchMsg(req);
}
public YxDataR<YxCommonR> batchSendToNotice(List<Long> toUid, Object body, Option option, ImTypeEnum type){
SendBatchMsgReq req = new SendBatchMsgReq();
req.setFromAccid(SYS_NOTICE_ID);
req.setToAccids(toUid.stream().map(i -> String.valueOf(toUid)).collect(Collectors.toList()));
req.setBody(JSON.toJSONString(body));
if(option != null){
req.setOption(JSON.toJSONString(new Option()));
}
req.setType(type.getCode());
return messageClient.sendBatchMsg(req);
}
/**
* 指定用户的自定义消息
*/

View File

@@ -0,0 +1,28 @@
package com.ruoyi.yunxin.enums;
import lombok.Getter;
/**
* 0=文本消息,1=图片消息,2=语音消息,3=视频消息,4=发送地理位置消息,6=发送文件消息,10=发送提示消息,100=发送第三方自定义消息
* <p>created on 2024/1/29 21:10</p>
* @author 77
*/
@Getter
public enum ImTypeEnum {
TXT(0,"文本消息"),
IMAGE(1,"图片消息"),
VOICE(2,"语音消息"),
VIDEO(3,"视频消息"),
GIS(4,"发送地理位置消息"),
FILE(6,"发送文件消息"),
NOTICE(10,"发送提示消息"),
CUSTOM(100,"发送第三方自定义消息"),
;
private final Integer code;
private final String text;
ImTypeEnum(Integer code, String text) {
this.code = code;
this.text = text;
}
}