Commit 373df364 by Future

Merge remote-tracking branch 'origin/xiaohudou_20220427' into xiaohudou_20220427

parents cc8701fb 229eeaf5
...@@ -29,6 +29,12 @@ public class GroupChatStatusMessageParam { ...@@ -29,6 +29,12 @@ public class GroupChatStatusMessageParam {
private String toGroupIds; private String toGroupIds;
/** /**
* 指定一个或多个用户
*/
@ApiModelProperty("指定一个或多个用户")
private String toUserIds;
/**
* 消息类型 * 消息类型
*/ */
@NotEmpty(message = "消息类型不能为空") @NotEmpty(message = "消息类型不能为空")
......
...@@ -164,10 +164,6 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -164,10 +164,6 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
throw new BusinessException(ApiCode.PARAMETER_EXCEPTION); throw new BusinessException(ApiCode.PARAMETER_EXCEPTION);
} }
if (CollectionUtils.isEmpty(imConversationCreate.getClientIds())) {
log.info("未找到群成员信息");
throw new BusinessException(ApiCode.PARAMETER_EXCEPTION);
}
Integer chatType = imConversationCreate.getChatType(); Integer chatType = imConversationCreate.getChatType();
String name = imConversationCreate.getName(); String name = imConversationCreate.getName();
String attributes = imConversationCreate.getAttributes(); String attributes = imConversationCreate.getAttributes();
...@@ -1304,6 +1300,11 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -1304,6 +1300,11 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
List<String> memberUserIds, List<String> memberUserIds,
String name, String name,
String attributes) { String attributes) {
if (CollectionUtils.isEmpty(memberUserIds)) {
log.info("未找到群成员信息");
throw new BusinessException(ApiCode.PARAMETER_EXCEPTION);
}
// 判断client是否都存在 // 判断client是否都存在
List<ImClient> memberClients = List<ImClient> memberClients =
imClientService.list(Wrappers.<ImClient>lambdaQuery() imClientService.list(Wrappers.<ImClient>lambdaQuery()
......
...@@ -22,6 +22,7 @@ import java.util.function.Function; ...@@ -22,6 +22,7 @@ import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
...@@ -604,17 +605,25 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes ...@@ -604,17 +605,25 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
if (conversationList.size() <= 0) { if (conversationList.size() <= 0) {
throw new BusinessException("群聊ids为 " + conversationIdsStr + " 的群聊列表不存在"); throw new BusinessException("群聊ids为 " + conversationIdsStr + " 的群聊列表不存在");
} }
// 是否指定用户
conversationList.forEach(conversation -> { List<String> toUserIds = Collections.emptyList();
boolean isToUser = false;
if (StringUtils.isNotBlank(param.getToUserIds())) {
isToUser = true;
toUserIds = Arrays.asList(param.getToUserIds().split(","));
}
for (ImConversation conversation : conversationList) {
// 获取群成员 // 获取群成员
List<ImConversationMembers> membersList = imConversationMembersService.list( List<ImConversationMembers> membersList = Collections.emptyList();
if (isToUser) {
// 指定群成员
membersList = imConversationMembersService.list(
new QueryWrapper<ImConversationMembers>().lambda()
.eq(ImConversationMembers::getFkConversationId, conversation.getId()).in(ImConversationMembers::getClientId, toUserIds));
} else {
membersList = imConversationMembersService.list(
new QueryWrapper<ImConversationMembers>().lambda() new QueryWrapper<ImConversationMembers>().lambda()
.eq(ImConversationMembers::getFkConversationId, conversation.getId())); .eq(ImConversationMembers::getFkConversationId, conversation.getId()));
if (param.getToUserIds() != null && !param.getToUserIds().isEmpty()) {
// 定向发送
membersList =
membersList.stream().filter(members -> param.getToUserIds().contains(members.getClientId())).collect(Collectors.toList());
} }
// 组装消息 // 组装消息
...@@ -640,8 +649,8 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes ...@@ -640,8 +649,8 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
// 离线消息推送 // 离线消息推送
pushMsgToOfflineMembers(application, members, param.getPushContent(), param.getPushExt()); pushMsgToOfflineMembers(application, members, param.getPushContent(), param.getPushExt());
} }
}
});
return true; return true;
} }
...@@ -663,12 +672,27 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes ...@@ -663,12 +672,27 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
if (conversationList.size() <= 0) { if (conversationList.size() <= 0) {
throw new BusinessException("群聊ids为 " + conversationIdsStr + " 的群聊列表不存在"); throw new BusinessException("群聊ids为 " + conversationIdsStr + " 的群聊列表不存在");
} }
// 是否指定用户
conversationList.forEach(conversation -> { List<String> toUserIds = Collections.emptyList();
boolean isToUser = false;
if (StringUtils.isNotBlank(param.getToUserIds())) {
isToUser = true;
toUserIds = Arrays.asList(param.getToUserIds().split(","));
}
// 开始发送
for (ImConversation conversation : conversationList) {
// 获取群成员 // 获取群成员
List<ImConversationMembers> membersList = imConversationMembersService.list( List<ImConversationMembers> membersList = Collections.emptyList();
if (isToUser) {
// 指定群成员
membersList = imConversationMembersService.list(
new QueryWrapper<ImConversationMembers>().lambda()
.eq(ImConversationMembers::getFkConversationId, conversation.getId()).in(ImConversationMembers::getClientId, toUserIds));
} else {
membersList = imConversationMembersService.list(
new QueryWrapper<ImConversationMembers>().lambda() new QueryWrapper<ImConversationMembers>().lambda()
.eq(ImConversationMembers::getFkConversationId, conversation.getId())); .eq(ImConversationMembers::getFkConversationId, conversation.getId()));
}
// 组装消息 // 组装消息
ImMessage message = assembleImMessage(appId, sender, conversation.getId(), param.getMessageType(), true, ImMessage message = assembleImMessage(appId, sender, conversation.getId(), param.getMessageType(), true,
...@@ -687,8 +711,7 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes ...@@ -687,8 +711,7 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
// 在线用户直接发消息 // 在线用户直接发消息
sendMsgForOnline(members.getFkClientId(), imMessageOnlineSend); sendMsgForOnline(members.getFkClientId(), imMessageOnlineSend);
} }
}
});
return true; return true;
} }
......
...@@ -22,6 +22,11 @@ public class GroupChatStatusMessage { ...@@ -22,6 +22,11 @@ public class GroupChatStatusMessage {
private String toGroupIds; private String toGroupIds;
/** /**
* 指定一个或多个用户
*/
private String toUserIds;
/**
* 消息类型 * 消息类型
*/ */
private String messageType; private String messageType;
......
...@@ -24,6 +24,11 @@ public class PublishGroupChatStatusMessageRequest extends WebServiceRequest { ...@@ -24,6 +24,11 @@ public class PublishGroupChatStatusMessageRequest extends WebServiceRequest {
private String toGroupIds; private String toGroupIds;
/** /**
* 指定一个或多个用户
*/
private String toUserIds;
/**
* 消息类型 * 消息类型
*/ */
private String messageType; private String messageType;
......
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