zhibo/android-app/后端接口TODO清单-消息聊天.md

136 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 后端接口 TODO 清单 - 消息聊天模块
## 1. 获取会话列表
**文件**: `MessagesActivity.java`
**接口路径**: `GET /api/conversations`
**请求参数**:
- userId: 当前用户ID从token中获取
- page (可选): 页码
- pageSize (可选): 每页数量
**返回数据**:
```json
{
"code": 200,
"data": [
{
"id": "string",
"title": "string",
"lastMessage": "string",
"timeText": "string",
"unreadCount": "number",
"isMuted": "boolean",
"avatarUrl": "string"
}
]
}
```
## 2. 获取会话消息列表
**文件**: `ConversationActivity.java`
**接口路径**: `GET /api/conversations/{conversationId}/messages`
**请求参数**:
- conversationId: 会话ID路径参数
- page (可选): 页码
- pageSize (可选): 每页数量默认20
- beforeMessageId (可选): 获取指定消息ID之前的消息
**返回数据**:
```json
{
"code": 200,
"data": [
{
"messageId": "string",
"userId": "string",
"username": "string",
"avatarUrl": "string",
"message": "string",
"timestamp": "number",
"status": "sent|read"
}
]
}
```
## 3. 发送私信消息
**文件**: `ConversationActivity.java`
**接口路径**: `POST /api/conversations/{conversationId}/messages`
**请求参数**:
```json
{
"conversationId": "string",
"message": "string",
"userId": "string"
}
```
**返回数据**: 返回创建的 ChatMessage 对象
## 4. 删除消息
**文件**: `ConversationActivity.java`
**接口路径**: `DELETE /api/messages/{messageId}`
**请求参数**: messageId (路径参数)
**返回数据**:
```json
{
"code": 200,
"data": {
"success": true
}
}
```
## 5. 标记会话为已读
**文件**: `MessagesActivity.java`, `ConversationActivity.java`
**接口路径**: `POST /api/conversations/{conversationId}/read`
**请求参数**:
```json
{
"conversationId": "string",
"userId": "string"
}
```
**返回数据**:
```json
{
"code": 200,
"data": {
"success": true
}
}
```
## 6. 删除会话
**文件**: `MessagesActivity.java`
**接口路径**: `DELETE /api/conversations/{conversationId}`
**请求参数**: conversationId (路径参数)
**返回数据**:
```json
{
"code": 200,
"data": {
"success": true
}
}
```
## 7. 搜索会话
**文件**: `MessagesActivity.java`
**接口路径**: `GET /api/conversations/search`
**请求参数**:
- keyword: 搜索关键词
- userId: 当前用户ID从token中获取
**返回数据**: 同获取会话列表接口
## 8. 获取未读消息总数
**文件**: `MainActivity.java`
**接口路径**: `GET /api/messages/unread/count`
**请求参数**: userId从token中获取
**返回数据**:
```json
{
"code": 200,
"data": {
"unreadCount": "number"
}
}
```