- 实现了Android SDK的完整IM功能接口,包括消息、群组、好友、会话等核心功能 - 添加了消息收发、历史记录、撤回编辑等完整的消息操作能力 - 实现了群组管理功能,包括创建、成员管理、权限设置等操作 - 添加了好友关系链管理,支持添加、删除、分组等操作 - 实现了会话管理功能,包括置顶、免打扰、已读状态等 - 添加了黑名单、资料管理、搜索等辅助功能 - 补齐了批量操作接口,提升客户端操作效率 - 实现了WebSocket连接管理和事件监听机制 - 添加了离线消息同步和状态管理功能
64 行
2.4 KiB
Java
64 行
2.4 KiB
Java
package com.xuqm.push.controller;
|
|
|
|
import com.xuqm.common.model.ApiResponse;
|
|
import com.xuqm.push.entity.DeviceTokenEntity;
|
|
import com.xuqm.push.service.PushDispatcher;
|
|
import jakarta.validation.constraints.NotBlank;
|
|
import jakarta.validation.constraints.NotNull;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
@RestController
|
|
@RequestMapping("/api/push")
|
|
public class PushController {
|
|
|
|
private final PushDispatcher pushDispatcher;
|
|
|
|
public PushController(PushDispatcher pushDispatcher) {
|
|
this.pushDispatcher = pushDispatcher;
|
|
}
|
|
|
|
@PostMapping("/register")
|
|
public ResponseEntity<ApiResponse<Void>> register(
|
|
@RequestParam @NotBlank String appId,
|
|
@RequestParam @NotBlank String userId,
|
|
@RequestParam @NotNull DeviceTokenEntity.Vendor vendor,
|
|
@RequestParam @NotBlank String token) {
|
|
pushDispatcher.registerToken(appId, userId, vendor, token);
|
|
return ResponseEntity.ok(ApiResponse.ok());
|
|
}
|
|
|
|
@PostMapping("/receive-push")
|
|
public ResponseEntity<ApiResponse<Void>> receivePush(
|
|
@RequestParam @NotBlank String appId,
|
|
@RequestParam @NotBlank String userId,
|
|
@RequestParam boolean enabled) {
|
|
pushDispatcher.setReceivePush(appId, userId, enabled);
|
|
return ResponseEntity.ok(ApiResponse.ok());
|
|
}
|
|
|
|
@PostMapping("/send")
|
|
public ResponseEntity<ApiResponse<Void>> send(
|
|
@RequestParam @NotBlank String appId,
|
|
@RequestParam @NotBlank String userId,
|
|
@RequestParam @NotBlank String title,
|
|
@RequestParam @NotBlank String body,
|
|
@RequestParam(required = false) String payload) {
|
|
pushDispatcher.pushToUser(appId, userId, title, body, payload);
|
|
return ResponseEntity.ok(ApiResponse.ok());
|
|
}
|
|
|
|
@DeleteMapping("/unregister")
|
|
public ResponseEntity<ApiResponse<Void>> unregister(
|
|
@RequestParam @NotBlank String appId,
|
|
@RequestParam @NotBlank String userId,
|
|
@RequestParam @NotNull DeviceTokenEntity.Vendor vendor) {
|
|
pushDispatcher.unregisterToken(appId, userId, vendor);
|
|
return ResponseEntity.ok(ApiResponse.ok());
|
|
}
|
|
}
|