This commit is contained in:
dute7liang
2024-01-27 19:46:21 +08:00
parent 63b2d1f238
commit d0a53c31a5
15 changed files with 290 additions and 22 deletions

View File

@@ -3,10 +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.req.Option;
import com.ruoyi.yunxin.req.SendAttachMsgReq;
import com.ruoyi.yunxin.req.SendBatchMsgReq;
import com.ruoyi.yunxin.req.SendMsgReq;
import com.ruoyi.yunxin.req.*;
import com.ruoyi.yunxin.req.type.YxTextData;
import com.ruoyi.yunxin.resp.SendMsgResp;
import com.ruoyi.yunxin.resp.YxCommonR;
@@ -90,4 +87,22 @@ public class Yunxin {
return messageClient.sendAttachMsg(sendAttachMsgReq);
}
public YxDataR<YxCommonR> sendBatchAttachMsgNotice(List<Long> toUid, Object data){
SendBatchAttachMsgReq req = new SendBatchAttachMsgReq();
req.setFromAccid(SYS_NOTICE_ID);
req.setToAccids(toUid.stream().map(i -> String.valueOf(toUid)).collect(Collectors.toList()));
req.setAttach(JSON.toJSONString(data));
return messageClient.sendBatchAttachMsg(req);
}
public YxDataR<YxCommonR> sendAttachMsgNotice(Long toUid, Object data){
SendAttachMsgReq sendAttachMsgReq = new SendAttachMsgReq();
sendAttachMsgReq.setFrom(SYS_NOTICE_ID);
sendAttachMsgReq.setTo(toUid+"");
sendAttachMsgReq.setAttach(JSON.toJSONString(data));
sendAttachMsgReq.setOption(JSON.toJSONString(new Option()));
return messageClient.sendAttachMsg(sendAttachMsgReq);
}
}

View File

@@ -5,6 +5,7 @@ import com.dtflys.forest.annotation.Body;
import com.dtflys.forest.annotation.Post;
import com.ruoyi.yunxin.interceptor.GlodonTokenInterceptor;
import com.ruoyi.yunxin.req.SendAttachMsgReq;
import com.ruoyi.yunxin.req.SendBatchAttachMsgReq;
import com.ruoyi.yunxin.req.SendBatchMsgReq;
import com.ruoyi.yunxin.req.SendMsgReq;
import com.ruoyi.yunxin.resp.SendMsgResp;
@@ -33,5 +34,8 @@ public interface ImMessageClient {
@Post(url = "/nimserver/msg/sendAttachMsg.action")
YxDataR<YxCommonR> sendAttachMsg(@Body SendAttachMsgReq req);
@Post(url = "/nimserver/msg/sendBatchAttachMsg.action")
YxDataR<YxCommonR> sendBatchAttachMsg(@Body SendBatchAttachMsgReq req);
}

View File

@@ -9,4 +9,5 @@ public class SendAttachMsgReq {
private String to;
private String attach;
private String option;
private int save = 1;
}

View File

@@ -0,0 +1,13 @@
package com.ruoyi.yunxin.req;
import lombok.Data;
import java.util.List;
@Data
public class SendBatchAttachMsgReq {
private String fromAccid;
private List<String> toAccids;
private String attach;
private int save = 1;
}

View File

@@ -8,6 +8,7 @@ import java.io.Serializable;
public class YxDataR<T> implements Serializable {
private Integer code;
private T data;
private String desc;
public boolean isSuccess(){
return code != null && code == 200;