OpenIMApiClient 替换

This commit is contained in:
wells
2026-08-08 15:20:45 +08:00
parent aa48225d85
commit 1f93719ee5
10 changed files with 176 additions and 40 deletions
@@ -5,7 +5,7 @@ import com.tailbet.mapper.UserMapper;
import com.tailbet.mapper.DigitWhiteMapper;
import com.tailbet.model.entity.DigitWhite;
import com.tailbet.model.entity.User;
import com.tailbet.openim.OpenIMClient;
import com.tailbet.openim.OpenIMApiClient;
import com.tailbet.service.IPushService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
@@ -24,7 +24,8 @@ public class PushServiceImpl implements IPushService {
private final UserMapper userMapper;
private final DigitWhiteMapper digitWhiteMapper;
private final OpenIMClient openIMClient;
private final OpenIMApiClient openIMApiClient;
private final com.tailbet.config.OpenIMProperties openIMProperties;
/**
* 推送尾数试算完成通知给白名单用户
@@ -94,8 +95,13 @@ public class PushServiceImpl implements IPushService {
}
// 通过OpenIM单聊发送(生产环境可扩展FCM/APNs离线推送)
openIMClient.sendUserMessage(String.valueOf(user.getId()),
message.getTitle() + " - " + message.getContent());
openIMApiClient.sendMsg(
openIMProperties.getAdminUserId(),
String.valueOf(user.getId()),
1, // sessionType 1=单聊
101, // contentType 101=文本
java.util.Map.of("content", message.getTitle() + " - " + message.getContent())
);
log.info("推送发送成功: userId={}, type={}", message.getUserId(), message.getType());
} catch (Exception e) {
@@ -110,9 +116,14 @@ public class PushServiceImpl implements IPushService {
@Override
public void broadcastToGroup(Long groupId, IPushService.PushMessage message) {
try {
// 通过OpenIM群消息发送
openIMClient.sendGroupMessage(String.valueOf(groupId),
message.getContent());
// 通过OpenIM群消息发送(使用管理员身份发送)
openIMApiClient.sendMsg(
openIMProperties.getAdminUserId(),
String.valueOf(groupId),
3, // sessionType 3=群聊
101, // contentType 101=文本
java.util.Map.of("content", message.getContent())
);
log.info("群广播发送成功: groupId={}, type={}", groupId, message.getType());
} catch (Exception e) {
log.error("群广播发送失败: groupId={}, type={}, error={}",