feat:feature-REQ/2129 恢复旧的发送消息接口,保持不报错,后面去掉
This commit is contained in:
parent
eef5273948
commit
2d582c7c01
@ -1,14 +1,20 @@
|
||||
package cn.axzo.im.center.api.feign;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.im.center.api.vo.req.CustomMessageInfo;
|
||||
import cn.axzo.im.center.api.vo.req.MessageInfo;
|
||||
import cn.axzo.im.center.api.vo.req.SendCustomMessageParam;
|
||||
import cn.axzo.im.center.api.vo.req.SendMessageParam;
|
||||
import cn.axzo.im.center.api.vo.resp.MessageCustomResp;
|
||||
import cn.axzo.im.center.api.vo.resp.MessageDispatchResp;
|
||||
import cn.axzo.im.center.api.vo.resp.MessageTaskResp;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* IM消息管理API
|
||||
*
|
||||
@ -42,4 +48,25 @@ public interface MessageApi {
|
||||
@PostMapping("/api/im/custom-message/send")
|
||||
ApiResult<MessageTaskResp> sendCustomMessage(@RequestBody @Validated SendCustomMessageParam messageInfo);
|
||||
|
||||
/**
|
||||
* 发送消息,单条消息、批量发送消息统一入口
|
||||
* 1.该接口一次请求,接收人支持最大2000人
|
||||
* 2.网易云信一分钟支持120次调用,每次调用IM中心设置100个账户(能返回msgId最大支持100人)
|
||||
* 3.IM中心接收人有工人端和管理端账户,故当接收人最大2000人时,需要调用网易云信发送4000条消息
|
||||
* 4.按照每批次发送100条消息,需要发送40次。
|
||||
* 5.因此该接口一分钟内最大支持3次接收人为2000人的请求
|
||||
*
|
||||
* @param messageInfo 发送消息请求参数
|
||||
* @return 发送消息请求响应
|
||||
*/
|
||||
@PostMapping("api/im/message/dispatch")
|
||||
ApiResult<List<MessageDispatchResp>> sendMessage(@RequestBody @Validated MessageInfo messageInfo);
|
||||
|
||||
/**
|
||||
* 发送自定义消息
|
||||
*/
|
||||
@PostMapping("api/im/custom-message/send")
|
||||
ApiResult<List<MessageCustomResp>> sendCustomMessage(@RequestBody @Validated CustomMessageInfo messageInfo);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
package cn.axzo.im.center.api.vo.req;
|
||||
|
||||
import cn.axzo.im.center.common.enums.AppTypeEnum;
|
||||
import cn.axzo.im.center.common.enums.BizTypeEnum;
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author syl
|
||||
* @date 2023/12/21
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CustomMessageInfo {
|
||||
|
||||
/**
|
||||
* 发送消息到App端
|
||||
* 工人端、企业端、服务器
|
||||
* CM、CMP、SYSTEM
|
||||
*
|
||||
* @See cn.axzo.im.center.common.enums.AppTypeEnum
|
||||
*/
|
||||
@NotEmpty(message = "消息接收端类型appTypeList不能为空")
|
||||
private List<AppTypeEnum> appTypeList;
|
||||
|
||||
/**
|
||||
* 接收用户自然人Id
|
||||
*/
|
||||
@NotBlank(message = "接收用户自然人Id不能为空")
|
||||
private String toPersonId;
|
||||
|
||||
/**
|
||||
* 业务类型
|
||||
*/
|
||||
@NotNull(message = "业务类型不能为空")
|
||||
private BizTypeEnum bizType;
|
||||
|
||||
/**
|
||||
* 推送内容 - 业务数据,json格式
|
||||
*/
|
||||
private String payload;
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
package cn.axzo.im.center.api.vo.req;
|
||||
|
||||
import cn.axzo.im.center.common.enums.AppTypeEnum;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* IM消息信息
|
||||
*
|
||||
* @author zuoqinbo
|
||||
* @version V1.0
|
||||
* @date 2023/10/9 16:01
|
||||
*/
|
||||
@Data
|
||||
public class MessageInfo {
|
||||
|
||||
/**
|
||||
* 发送消息到App端
|
||||
* 工人端、企业端、服务器
|
||||
* CM、CMP、SYSTEM
|
||||
*
|
||||
* @See cn.axzo.im.center.common.enums.AppTypeEnum
|
||||
*/
|
||||
@NotNull(message = "消息接收端类型appTypeList不能为空")
|
||||
private List<AppTypeEnum> appTypeList;
|
||||
|
||||
|
||||
/**
|
||||
* 发送用户Id,目前暂不支持非机器人发送消息
|
||||
*/
|
||||
private String personId;
|
||||
|
||||
/**
|
||||
* 消息接收用户Id列表
|
||||
*/
|
||||
@NotNull(message = "接收消息用户personIdList不能为空")
|
||||
private Set<String> toPersonIdList;
|
||||
|
||||
/**
|
||||
* 消息标题
|
||||
*/
|
||||
@NotNull(message = "消息标题不能为空")
|
||||
private String msgHeader;
|
||||
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
@NotNull(message = "消息内容不能为空")
|
||||
private String msgContent;
|
||||
|
||||
/**
|
||||
* 消息模板ID
|
||||
*/
|
||||
@NotNull(message = "消息模板ID不能为空")
|
||||
private String msgTemplateId;
|
||||
|
||||
/**
|
||||
* 消息模板内容
|
||||
*/
|
||||
@NotNull(message = "消息模板内容不能为空")
|
||||
private String msgTemplateContent;
|
||||
|
||||
/**
|
||||
* 消息扩展信息
|
||||
*/
|
||||
private Map<String, String> extendsInfo = Maps.newHashMap();
|
||||
}
|
||||
@ -5,8 +5,12 @@ import cn.axzo.basics.common.util.AssertUtil;
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.im.center.api.feign.MessageApi;
|
||||
import cn.axzo.im.center.api.vo.req.AccountQuery;
|
||||
import cn.axzo.im.center.api.vo.req.CustomMessageInfo;
|
||||
import cn.axzo.im.center.api.vo.req.MessageInfo;
|
||||
import cn.axzo.im.center.api.vo.req.SendCustomMessageParam;
|
||||
import cn.axzo.im.center.api.vo.req.SendMessageParam;
|
||||
import cn.axzo.im.center.api.vo.resp.MessageCustomResp;
|
||||
import cn.axzo.im.center.api.vo.resp.MessageDispatchResp;
|
||||
import cn.axzo.im.center.api.vo.resp.MessageTaskResp;
|
||||
import cn.axzo.im.center.api.vo.resp.UserAccountResp;
|
||||
import cn.axzo.im.center.common.enums.AccountTypeEnum;
|
||||
@ -15,19 +19,23 @@ import cn.axzo.im.channel.IMChannelProvider;
|
||||
import cn.axzo.im.entity.AccountRegister;
|
||||
import cn.axzo.im.entity.MessageTask;
|
||||
import cn.axzo.im.service.AccountService;
|
||||
import cn.axzo.im.service.MessageService;
|
||||
import cn.axzo.im.service.MessageTaskService;
|
||||
import cn.axzo.im.service.RobotMsgTemplateService;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.github.resilience4j.ratelimiter.RequestNotPermitted;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ -52,6 +60,28 @@ public class MessageController implements MessageApi {
|
||||
private AccountService accountService;
|
||||
@Autowired
|
||||
private RobotMsgTemplateService robotMsgTemplateService;
|
||||
@Autowired
|
||||
private MessageService messageService;
|
||||
|
||||
|
||||
@Override
|
||||
public ApiResult<List<MessageDispatchResp>> sendMessage(MessageInfo messageInfo) {
|
||||
// List<MessageDispatchResp> messageRespList = messageService.sendMessage(messageInfo);
|
||||
return ApiResult.ok(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<List<MessageCustomResp>> sendCustomMessage(CustomMessageInfo customMessage) {
|
||||
// List<MessageCustomResp> messageRespList = messageService.sendCustomMessage(customMessage);
|
||||
return ApiResult.ok(null);
|
||||
}
|
||||
|
||||
@ExceptionHandler({ RequestNotPermitted.class })
|
||||
@ResponseStatus(HttpStatus.TOO_MANY_REQUESTS)
|
||||
public ApiResult<String> handleRequestNotPermitted() {
|
||||
return ApiResult.err("服务器资源繁忙,请求被拒绝!");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送消息时只是存储在messageTask中,通过xxlJob或者mq异步去处理
|
||||
|
||||
@ -104,9 +104,9 @@ ALTER TABLE im_account_register ADD COLUMN `ou_id` bigint null comment 'organiza
|
||||
CREATE TABLE IF NOT EXISTS im_message_task
|
||||
(
|
||||
id bigint auto_increment comment '主键',
|
||||
biz_id varchar(50) null comment '业务请求时可以带的排查问题的id',
|
||||
biz_id varchar(50) not null default '' comment '业务请求时可以带的排查问题的id',
|
||||
send_im_account varchar(100) not null comment '发送者的三方平台账号id',
|
||||
send_person_id varchar(100) null comment 'IM消息发送personId,自定义消息没有personId',
|
||||
send_person_id varchar(100) not null default '' comment 'IM消息发送personId,自定义消息没有personId',
|
||||
receive_persons json not null comment 'IM消息接收人person列表',
|
||||
status varchar(32) not null default 'PENDING' comment '消息状态:PENDING、SUCCEED、FAILED',
|
||||
title VARCHAR(128) NOT NULL DEFAULT '' COMMENT '标题',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user