init
This commit is contained in:
@@ -4,6 +4,7 @@ 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.type.YxTextData;
|
||||
@@ -25,7 +26,6 @@ public class Yunxin {
|
||||
@Resource
|
||||
private ImMessageClient messageClient;
|
||||
|
||||
@Deprecated
|
||||
public YxDataR<SendMsgResp> sendTo(Long toUid,Long fromUid,Object data){
|
||||
SendMsgReq req = new SendMsgReq();
|
||||
req.setFrom(fromUid == null ? yunxinProperties.getDefaultFromUid() : fromUid+"");
|
||||
@@ -44,4 +44,13 @@ public class Yunxin {
|
||||
return messageClient.sendBatchMsg(req);
|
||||
}
|
||||
|
||||
public YxDataR<YxCommonR> sendAttachMsg(Long fromUid, Long toUid, Object data){
|
||||
SendAttachMsgReq sendAttachMsgReq = new SendAttachMsgReq();
|
||||
sendAttachMsgReq.setFrom(fromUid+"");
|
||||
sendAttachMsgReq.setTo(toUid+"");
|
||||
sendAttachMsgReq.setAttach(JSON.toJSONString(data));
|
||||
sendAttachMsgReq.setOption(JSON.toJSONString(new Option()));
|
||||
return messageClient.sendAttachMsg(sendAttachMsgReq);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.ruoyi.yunxin.client;
|
||||
|
||||
import com.dtflys.forest.annotation.BaseRequest;
|
||||
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.SendBatchMsgReq;
|
||||
import com.ruoyi.yunxin.req.SendMsgReq;
|
||||
import com.ruoyi.yunxin.resp.SendMsgResp;
|
||||
@@ -12,14 +14,24 @@ import com.ruoyi.yunxin.resp.YxDataR;
|
||||
@BaseRequest(baseURL = "${baseUrl}", interceptor = GlodonTokenInterceptor.class)
|
||||
public interface ImMessageClient {
|
||||
|
||||
/**
|
||||
* 发送自定义消息
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@Post(url = "/nimserver/msg/sendMsg.action")
|
||||
YxDataR<SendMsgResp> sendMsg(SendMsgReq req);
|
||||
YxDataR<SendMsgResp> sendMsg(@Body SendMsgReq req);
|
||||
|
||||
@Post(url = "/nimserver/msg/sendBatchMsg.action")
|
||||
YxDataR<YxCommonR> sendBatchMsg(SendBatchMsgReq req);
|
||||
YxDataR<YxCommonR> sendBatchMsg(@Body SendBatchMsgReq req);
|
||||
|
||||
// @Post(url = "/nimserver/msg/sendAttachMsg.action")
|
||||
// YxR<SendMsgResp> sendAttachMsg(SendMsgReq req);
|
||||
/**
|
||||
* 发送自定义系统消息
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@Post(url = "/nimserver/msg/sendAttachMsg.action")
|
||||
YxDataR<YxCommonR> sendAttachMsg(@Body SendAttachMsgReq req);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.ruoyi.yunxin.data;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 系统消息通知
|
||||
*/
|
||||
@Data
|
||||
public class SendAttachMsgData {
|
||||
private Long id = 11L;
|
||||
private SendAttachMsgDataMsg data;
|
||||
|
||||
@Data
|
||||
public static class SendAttachMsgDataMsg {
|
||||
private Long amount;
|
||||
private Long callTime = DateUtil.currentSeconds();
|
||||
private Long giftTotal = 0L;
|
||||
private Long id = 0L;
|
||||
private Integer linkType = 0;
|
||||
private Long time = 0L;
|
||||
private Long toid = 0L;
|
||||
private Long roomId;
|
||||
}
|
||||
|
||||
public static SendAttachMsgData init(Long roomId){
|
||||
SendAttachMsgData data = new SendAttachMsgData();
|
||||
SendAttachMsgDataMsg msgDataMsg = new SendAttachMsgDataMsg();
|
||||
msgDataMsg.setRoomId(roomId);
|
||||
data.setData(msgDataMsg);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -4,5 +4,9 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SendAttachMsgReq {
|
||||
|
||||
private String from;
|
||||
private Integer msgType = 0;
|
||||
private String to;
|
||||
private String attach;
|
||||
private String option;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user