zhibo/android-app/后端接口TODO清单-搜索功能.md

126 lines
2.1 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. 搜索直播间/用户
**文件**: `MainActivity.java`, `SearchActivity.java`
**接口路径**: `GET /api/search`
**请求参数**:
- keyword: 搜索关键词
- type (可选): 搜索类型room/user/all
- page (可选): 页码
**返回数据**:
```json
{
"code": 200,
"data": {
"rooms": [
{
"id": "string",
"title": "string",
"streamerName": "string",
"isLive": "boolean",
"coverUrl": "string",
"viewerCount": "number"
}
],
"users": [
{
"userId": "string",
"username": "string",
"avatarUrl": "string",
"bio": "string"
}
]
}
}
```
## 2. 获取搜索历史
**文件**: `SearchActivity.java`
**接口路径**: `GET /api/search/history`
**请求参数**: userId从token中获取
**返回数据**:
```json
{
"code": 200,
"data": [
{
"keyword": "string",
"timestamp": "number"
}
]
}
```
## 3. 保存搜索历史
**文件**: `SearchActivity.java`
**接口路径**: `POST /api/search/history`
**请求参数**:
```json
{
"keyword": "string"
}
```
**返回数据**:
```json
{
"code": 200,
"data": {
"success": true
}
}
```
## 4. 删除搜索历史
**文件**: `SearchActivity.java`
**接口路径**: `DELETE /api/search/history`
**请求参数**:
- keyword (可选): 删除指定关键词,不传则删除全部
**返回数据**:
```json
{
"code": 200,
"data": {
"success": true
}
}
```
## 5. 获取热门搜索
**文件**: `SearchActivity.java`
**接口路径**: `GET /api/search/hot`
**返回数据**:
```json
{
"code": 200,
"data": [
{
"keyword": "string",
"count": "number"
}
]
}
```
## 6. 获取搜索建议(实时)
**文件**: `SearchActivity.java`
**接口路径**: `GET /api/search/suggestions`
**请求参数**:
- keyword: 搜索关键词(必填)
- limit (可选): 返回数量限制默认10
**返回数据**:
```json
{
"code": 200,
"data": [
{
"type": "room|user",
"id": "string",
"title": "string",
"subtitle": "string",
"avatarUrl": "string"
}
]
}
```