2.1 KiB
2.1 KiB
后端接口 TODO 清单 - 搜索功能模块
1. 搜索直播间/用户
文件: MainActivity.java, SearchActivity.java
接口路径: GET /api/search
请求参数:
- keyword: 搜索关键词
- type (可选): 搜索类型(room/user/all)
- page (可选): 页码 返回数据:
{
"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中获取)
返回数据:
{
"code": 200,
"data": [
{
"keyword": "string",
"timestamp": "number"
}
]
}
3. 保存搜索历史
文件: SearchActivity.java
接口路径: POST /api/search/history
请求参数:
{
"keyword": "string"
}
返回数据:
{
"code": 200,
"data": {
"success": true
}
}
4. 删除搜索历史
文件: SearchActivity.java
接口路径: DELETE /api/search/history
请求参数:
- keyword (可选): 删除指定关键词,不传则删除全部 返回数据:
{
"code": 200,
"data": {
"success": true
}
}
5. 获取热门搜索
文件: SearchActivity.java
接口路径: GET /api/search/hot
返回数据:
{
"code": 200,
"data": [
{
"keyword": "string",
"count": "number"
}
]
}
6. 获取搜索建议(实时)
文件: SearchActivity.java
接口路径: GET /api/search/suggestions
请求参数:
- keyword: 搜索关键词(必填)
- limit (可选): 返回数量限制,默认10 返回数据:
{
"code": 200,
"data": [
{
"type": "room|user",
"id": "string",
"title": "string",
"subtitle": "string",
"avatarUrl": "string"
}
]
}