48 KiB
Android应用接口参数详细文档
📋 文档说明
本文档详细列出了Android应用中真实调用的所有接口的请求参数和响应参数示例。
文档版本: v1.0
更新时间: 2024-12-30
接口总数: 73个真实调用的接口
基础URL: http://your-server:port
📑 目录
1. 用户认证模块
1.1 账号密码登录
接口地址: POST /api/front/login
请求参数:
{
"account": "18888888888",
"password": "123456"
}
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| account | String | 是 | 手机号(账号) |
| password | String | 是 | 密码,6-18位 |
响应示例:
{
"code": 200,
"message": null,
"data": {
"token": "98c65b9c67894f7f8989166d49239c6be",
"type": null,
"key": null,
"uid": 120,
"nikeName": "新用户",
"phone": "18888888888"
}
}
响应字段说明:
| 字段名 | 类型 | 说明 |
|---|---|---|
| token | String | 用户登录密钥,后续请求需携带 |
| type | String | 状态:login-登录,register-注册,start-注册起始页,登录时为null |
| key | String | 注册key,登录时为null |
| uid | Integer | 登录用户ID |
| nikeName | String | 登录用户昵称 |
| phone | String | 登录用户手机号 |
1.2 用户注册
接口地址: POST /api/front/register
请求参数:
{
"phone": "18888888888",
"password": "123456",
"verificationCode": "123456",
"nickname": "新用户"
}
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| phone | String | 是 | 手机号 |
| password | String | 是 | 密码,6-18位 |
| verificationCode | String | 否 | 短信验证码 |
| nickname | String | 否 | 用户昵称 |
响应示例:
{
"code": 200,
"message": null,
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"type": "register",
"key": null,
"uid": 121,
"nikeName": "新用户",
"phone": "18888888889"
}
}
响应字段说明:
| 字段名 | 类型 | 说明 |
|---|---|---|
| token | String | 用户登录密钥 |
| type | String | 状态:register表示注册成功 |
| key | String | 注册key |
| uid | Integer | 新注册用户ID |
| nikeName | String | 用户昵称 |
| phone | String | 用户手机号 |
1.3 发送验证码
接口地址: POST /api/front/sendCode
请求参数:
phone=18888888888
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| phone | String | 是 | 手机号 |
响应示例:
{
"code": 200,
"message": "发送成功",
"data": "发送成功"
}
1.4 退出登录
接口地址: GET /api/front/logout
请求头:
Authori-zation: TOKEN_USER:<token>
重要说明:
- 请求头名称是
Authori-zation(注意:Authori和zation之间有连字符-) - Token值需要加上前缀
TOKEN_USER: - 例如:
Authori-zation: TOKEN_USER:98c65b9c67894f7f8989166d49239c6be
请求参数: 无
响应示例:
{
"code": 200,
"message": null,
"data": null
}
1.5 获取用户信息
接口地址: GET /api/front/user
请求头:
Authorization: Bearer <token>
请求参数: 无
响应示例:
{
"code": 200,
"message": null,
"data": {
"uid": 120,
"nickname": "新用户",
"avatar": "https://example.com/avatar.jpg",
"phone": "18888888888",
"nowMoney": 100.50,
"integral": 500,
"experience": 1000,
"brokeragePrice": 50.00,
"level": 1,
"isPromoter": false,
"couponCount": 5,
"vip": false,
"vipIcon": "",
"vipName": "",
"rechargeSwitch": true,
"collectCount": 10
}
}
响应字段说明:
| 字段名 | 类型 | 说明 |
|---|---|---|
| uid | Integer | 用户ID |
| nickname | String | 用户昵称 |
| avatar | String | 用户头像URL |
| phone | String | 手机号码 |
| nowMoney | BigDecimal | 用户余额 |
| integral | Integer | 用户剩余积分 |
| experience | Integer | 用户剩余经验 |
| brokeragePrice | BigDecimal | 佣金金额 |
| level | Integer | 用户等级 |
| isPromoter | Boolean | 是否为推广员 |
| couponCount | Integer | 用户优惠券数量 |
| vip | Boolean | 是否为会员 |
| vipIcon | String | 会员图标 |
| vipName | String | 会员名称 |
| rechargeSwitch | Boolean | 小程序充值开关 |
| collectCount | Integer | 用户收藏数量 |
2. 直播间模块
2.1 获取直播间列表
接口地址: GET /api/front/live/public/rooms
请求参数: 无(可选登录)
响应示例:
{
"code": 200,
"message": "success",
"data": [
{
"id": "1",
"title": "精彩直播间",
"streamerName": "主播昵称",
"streamerId": 1001,
"streamerAvatar": "https://example.com/avatar.jpg",
"streamerLevel": 5,
"streamKey": "live_stream_key_123",
"isLive": true,
"viewerCount": 1234,
"likeCount": 5678,
"shareCount": 100,
"description": "直播间描述",
"coverImage": "https://example.com/cover.jpg",
"categoryId": 1,
"categoryName": "娱乐",
"type": "video",
"notice": "直播间公告",
"tags": ["热门", "推荐"],
"isFollowing": false,
"createTime": "2024-12-30T10:00:00",
"startTime": "2024-12-30T10:30:00",
"streamUrls": {
"rtmp": "rtmp://server:25002/live/stream_key",
"flv": "http://server:25003/live/stream_key.flv",
"hls": "http://server:25003/live/stream_key.m3u8"
}
}
]
}
2.2 创建直播间
接口地址: POST /api/front/live/rooms
请求头:
Authorization: Bearer <token>
请求参数:
{
"title": "我的直播间",
"streamerName": "主播昵称",
"type": "video",
"categoryId": 1,
"description": "直播间描述",
"coverImage": "https://example.com/cover.jpg",
"tags": "热门,推荐",
"notice": "欢迎来到我的直播间"
}
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| title | String | 是 | 直播间标题 |
| streamerName | String | 是 | 主播名称 |
| type | String | 否 | 直播类型,默认video |
| categoryId | Integer | 否 | 分类ID |
| description | String | 否 | 直播间描述 |
| coverImage | String | 否 | 封面图片URL |
| tags | String | 否 | 标签,逗号分隔 |
| notice | String | 否 | 直播间公告 |
响应示例:
{
"code": 200,
"message": "创建成功",
"data": {
"id": "10",
"title": "我的直播间",
"streamKey": "live_stream_key_456",
"streamUrls": {
"rtmp": "rtmp://server:25002/live/stream_key_456",
"flv": "http://server:25003/live/stream_key_456.flv",
"hls": "http://server:25003/live/stream_key_456.m3u8"
},
"isLive": false,
"createTime": "2024-12-30T11:00:00"
}
}
2.3 获取直播间详情
接口地址: GET /api/front/live/public/rooms/{id}
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| id | Integer | 是 | 直播间ID |
响应示例: 同2.1中的单个直播间对象
2.4 删除直播间
接口地址: DELETE /api/front/live/rooms/{id}
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| id | Integer | 是 | 直播间ID |
响应示例:
{
"code": 200,
"message": "删除成功",
"data": null
}
2.5 开始直播
接口地址: POST /api/front/live/room/{id}/start
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| id | Integer | 是 | 直播间ID |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"success": true,
"message": "直播已开始"
}
}
2.6 结束直播
接口地址: POST /api/front/live/room/{id}/stop
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| id | Integer | 是 | 直播间ID |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"success": true,
"message": "直播已结束"
}
}
2.7 关注/取消关注主播
接口地址: POST /api/front/live/follow
请求头:
Authorization: Bearer <token>
请求参数:
{
"streamerId": 1001,
"action": "follow"
}
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| streamerId | Integer | 是 | 主播用户ID |
| action | String | 是 | 操作类型:follow(关注) / unfollow(取消关注) |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"success": true,
"message": "关注成功",
"isFollowing": true
}
}
2.8 广播在线人数
接口地址: POST /api/live/online/broadcast/{roomId}
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| roomId | String | 是 | 直播间ID |
响应示例:
{
"code": 200,
"message": "广播成功",
"data": {
"roomId": "1",
"onlineCount": 1234
}
}
2.9 获取直播间弹幕消息
接口地址: GET /api/front/live/public/rooms/{roomId}/messages
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| roomId | Integer | 是 | 直播间ID |
查询参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| limit | Integer | 否 | 获取数量,默认50 |
响应示例:
{
"code": 200,
"message": "success",
"data": [
{
"id": 1001,
"roomId": 1,
"userId": 2001,
"nickname": "用户昵称",
"avatar": "https://example.com/avatar.jpg",
"content": "主播好棒!",
"type": "text",
"createTime": "2024-12-30T12:00:00",
"timestamp": 1735542000000
}
]
}
2.10 赠送礼物
接口地址: POST /api/front/live/rooms/{roomId}/gift
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| roomId | Integer | 是 | 直播间ID |
请求参数:
{
"giftId": 1,
"count": 1,
"streamerId": 1001,
"receiverId": 1001
}
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| giftId | Integer | 是 | 礼物ID |
| count | Integer | 是 | 赠送数量 |
| streamerId | Integer | 是 | 主播ID(接收者) |
| receiverId | Integer | 是 | 接收者ID(同streamerId) |
响应示例:
{
"code": 200,
"message": "赠送成功",
"data": {
"success": true,
"giftRecordId": 10001,
"giftId": 1,
"giftName": "玫瑰花",
"count": 1,
"totalPrice": 10.00,
"newBalance": 90.50,
"sendTime": 1735542000000,
"message": "赠送成功"
}
}
3. 礼物打赏模块
3.1 获取礼物列表
接口地址: GET /api/front/gift/list
请求参数: 无
响应示例:
{
"code": 200,
"message": "success",
"data": [
{
"id": "1",
"name": "玫瑰花",
"price": 10,
"iconUrl": "https://example.com/gift/rose.png",
"description": "浪漫的玫瑰花",
"level": 1,
"animation": "https://example.com/animation/rose.svga",
"sort": 1
},
{
"id": "2",
"name": "跑车",
"price": 1000,
"iconUrl": "https://example.com/gift/car.png",
"description": "豪华跑车",
"level": 5,
"animation": "https://example.com/animation/car.svga",
"sort": 2
}
]
}
3.2 获取用户金币余额
接口地址: GET /api/front/gift/balance
请求头:
Authorization: Bearer <token>
响应示例:
{
"code": 200,
"message": "success",
"data": {
"userId": 1001,
"coinBalance": 100.50,
"totalRecharge": 500.00,
"totalConsume": 399.50,
"vipLevel": 3
}
}
3.3 赠送礼物
接口地址: POST /api/front/gift/send
请求头:
Authorization: Bearer <token>
请求参数:
{
"roomId": 1,
"giftId": 1,
"count": 5,
"streamerId": 1001
}
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| roomId | Integer | 是 | 直播间ID |
| giftId | Integer | 是 | 礼物ID |
| count | Integer | 是 | 赠送数量 |
| streamerId | Integer | 是 | 主播ID(接收者) |
响应示例:
{
"code": 200,
"message": "赠送成功",
"data": {
"success": true,
"giftRecordId": 10002,
"giftId": 1,
"giftName": "玫瑰花",
"count": 5,
"totalPrice": 50.00,
"newBalance": 50.50,
"sendTime": 1735542100000,
"message": "赠送成功"
}
}
3.4 获取充值选项列表
接口地址: GET /api/front/gift/recharge/options
响应示例:
{
"code": 200,
"message": "success",
"data": [
{
"id": "1",
"coinAmount": 60,
"price": 6.00,
"discountLabel": "首充优惠",
"isHot": true,
"sort": 1
},
{
"id": "2",
"coinAmount": 300,
"price": 30.00,
"discountLabel": "热门",
"isHot": true,
"sort": 2
}
]
}
3.5 创建充值订单
接口地址: POST /api/front/gift/recharge/create
请求头:
Authorization: Bearer <token>
请求参数:
{
"optionId": 1,
"coinAmount": 60,
"price": 6.00
}
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| optionId | Integer | 是 | 充值选项ID |
| coinAmount | BigDecimal | 是 | 金币数量 |
| price | BigDecimal | 是 | 支付金额 |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"orderId": "RCH1735542200ABC123",
"orderNo": "RO1735542200",
"coinAmount": 60,
"price": 6.00,
"paymentUrl": "https://pay.example.com/pay?orderId=RCH1735542200ABC123",
"createTime": 1735542200000
}
}
3.6 支付订单
接口地址: POST /api/front/pay/payment
请求头:
Authorization: Bearer <token>
请求参数:
{
"orderId": "RCH1735542200ABC123",
"paymentMethod": "alipay"
}
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| orderId | String | 是 | 订单ID |
| paymentMethod | String | 是 | 支付方式:alipay/wechat |
响应示例:
{
"code": 200,
"message": "支付成功",
"data": {
"success": true,
"orderId": "RCH1735542200ABC123",
"paymentStatus": "paid",
"newBalance": 110.50
}
}
4. 私聊会话模块
4.1 获取会话列表
接口地址: GET /api/front/conversations
请求头:
Authorization: Bearer <token>
响应示例:
{
"code": 200,
"message": "success",
"data": [
{
"id": 1001,
"otherUserId": 2001,
"otherUserNickname": "好友昵称",
"otherUserAvatar": "https://example.com/avatar.jpg",
"lastMessage": "最后一条消息内容",
"lastMessageTime": "2024-12-30T12:00:00",
"unreadCount": 3,
"isOnline": true,
"createTime": "2024-12-29T10:00:00",
"updateTime": "2024-12-30T12:00:00"
}
]
}
4.2 搜索会话
接口地址: GET /api/front/conversations/search
请求头:
Authorization: Bearer <token>
查询参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| keyword | String | 否 | 搜索关键词 |
响应示例: 同4.1
4.3 获取或创建会话
接口地址: POST /api/front/conversations/with/{otherUserId}
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| otherUserId | Integer | 是 | 对方用户ID |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"conversationId": 1001,
"created": false
}
}
4.4 标记会话已读
接口地址: POST /api/front/conversations/{id}/read
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| id | Long | 是 | 会话ID |
响应示例:
{
"code": 200,
"message": "success",
"data": true
}
4.5 删除会话
接口地址: DELETE /api/front/conversations/{id}
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| id | Long | 是 | 会话ID |
响应示例:
{
"code": 200,
"message": "删除成功",
"data": true
}
4.6 获取消息列表
接口地址: GET /api/front/conversations/{id}/messages
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| id | Long | 是 | 会话ID |
查询参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | Integer | 否 | 页码,默认1 |
| pageSize | Integer | 否 | 每页数量,默认20 |
响应示例:
{
"code": 200,
"message": "success",
"data": [
{
"id": 10001,
"conversationId": 1001,
"senderId": 1001,
"senderNickname": "发送者昵称",
"senderAvatar": "https://example.com/avatar.jpg",
"receiverId": 2001,
"content": "你好,在吗?",
"contentType": "text",
"status": "sent",
"isRead": false,
"createTime": "2024-12-30T12:00:00",
"timestamp": 1735542000000
}
]
}
4.7 发送私信
接口地址: POST /api/front/conversations/{id}/messages
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| id | Long | 是 | 会话ID |
请求参数:
{
"content": "你好,在吗?",
"contentType": "text"
}
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| content | String | 是 | 消息内容 |
| contentType | String | 否 | 消息类型:text/image/video,默认text |
响应示例:
{
"code": 200,
"message": "发送成功",
"data": {
"id": 10002,
"conversationId": 1001,
"senderId": 1001,
"senderNickname": "我的昵称",
"senderAvatar": "https://example.com/my-avatar.jpg",
"receiverId": 2001,
"content": "你好,在吗?",
"contentType": "text",
"status": "sent",
"isRead": false,
"createTime": "2024-12-30T12:01:00",
"timestamp": 1735542060000
}
}
5. 好友管理模块
5.1 搜索用户
接口地址: GET /api/front/users/search
查询参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| keyword | String | 是 | 搜索关键词(用户名/手机号) |
| page | Integer | 否 | 页码,默认1 |
| pageSize | Integer | 否 | 每页数量,默认20 |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"pageNum": 1,
"pageSize": 20,
"total": 5,
"list": [
{
"userId": 2001,
"nickname": "用户昵称",
"avatar": "https://example.com/avatar.jpg",
"phone": "188****8888",
"level": 3,
"signature": "个性签名",
"isFriend": false,
"isFollowing": false
}
]
}
}
5.2 发送好友请求
接口地址: POST /api/front/friends/request
请求头:
Authorization: Bearer <token>
请求参数:
{
"targetUserId": 2001,
"message": "你好,我想加你为好友"
}
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| targetUserId | Integer | 是 | 目标用户ID |
| message | String | 否 | 验证消息 |
响应示例:
{
"code": 200,
"message": "好友请求已发送",
"data": true
}
5.3 获取好友请求列表
接口地址: GET /api/front/friends/requests
请求头:
Authorization: Bearer <token>
查询参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | Integer | 否 | 页码,默认1 |
| pageSize | Integer | 否 | 每页数量,默认20 |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"pageNum": 1,
"pageSize": 20,
"total": 3,
"list": [
{
"requestId": 1001,
"fromUserId": 2001,
"fromUserNickname": "申请者昵称",
"fromUserAvatar": "https://example.com/avatar.jpg",
"message": "你好,我想加你为好友",
"status": "pending",
"createTime": "2024-12-30T10:00:00"
}
]
}
}
5.4 处理好友请求
接口地址: POST /api/front/friends/requests/{requestId}/handle
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| requestId | Long | 是 | 好友请求ID |
请求参数:
{
"accept": true
}
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| accept | Boolean | 是 | true=接受,false=拒绝 |
响应示例:
{
"code": 200,
"message": "已接受好友请求",
"data": true
}
5.5 获取好友列表
接口地址: GET /api/front/friends
请求头:
Authorization: Bearer <token>
查询参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | Integer | 否 | 页码,默认1 |
| pageSize | Integer | 否 | 每页数量,默认20 |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"pageNum": 1,
"pageSize": 20,
"total": 10,
"list": [
{
"friendId": 2001,
"nickname": "好友昵称",
"avatar": "https://example.com/avatar.jpg",
"level": 3,
"signature": "个性签名",
"isOnline": true,
"lastOnlineTime": 1735542000000,
"createTime": "2024-12-29T10:00:00"
}
]
}
}
5.6 删除好友
接口地址: DELETE /api/front/friends/{friendId}
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| friendId | Integer | 是 | 好友用户ID |
响应示例:
{
"code": 200,
"message": "删除成功",
"data": true
}
5.7 拉黑好友
接口地址: POST /api/front/friends/block/{friendId}
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| friendId | Integer | 是 | 好友用户ID |
响应示例:
{
"code": 200,
"message": "拉黑成功",
"data": true
}
5.8 取消拉黑
接口地址: POST /api/front/friends/unblock/{friendId}
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| friendId | Integer | 是 | 好友用户ID |
响应示例:
{
"code": 200,
"message": "取消拉黑成功",
"data": true
}
5.9 获取黑名单列表
接口地址: GET /api/front/friends/blocked
请求头:
Authorization: Bearer <token>
查询参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | Integer | 否 | 页码,默认1 |
| pageSize | Integer | 否 | 每页数量,默认20 |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"pageNum": 1,
"pageSize": 20,
"total": 2,
"list": [
{
"userId": 3001,
"nickname": "被拉黑用户",
"avatar": "https://example.com/avatar.jpg",
"blockTime": "2024-12-30T10:00:00"
}
]
}
}
6. 关注功能模块
6.1 关注用户
接口地址: POST /api/front/follow/follow
请求头:
Authorization: Bearer <token>
请求参数:
{
"userId": 2001
}
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| userId | Integer | 是 | 被关注用户ID |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"success": true,
"message": "关注成功",
"isFollowing": true
}
}
6.2 取消关注
接口地址: POST /api/front/follow/unfollow
请求头:
Authorization: Bearer <token>
请求参数:
{
"userId": 2001
}
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| userId | Integer | 是 | 被取消关注用户ID |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"success": true,
"message": "取消关注成功",
"isFollowing": false
}
}
6.3 检查关注状态
接口地址: GET /api/front/follow/status/{userId}
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| userId | Integer | 是 | 目标用户ID |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"isFollowing": true,
"userId": 2001
}
}
6.4 批量检查关注状态
接口地址: POST /api/front/follow/status/batch
请求头:
Authorization: Bearer <token>
请求参数:
{
"userIds": [2001, 2002, 2003]
}
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| userIds | List | 是 | 用户ID列表 |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"statusMap": {
"2001": true,
"2002": false,
"2003": true
}
}
}
6.5 获取关注列表
接口地址: GET /api/front/follow/following
请求头:
Authorization: Bearer <token>
查询参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | Integer | 否 | 页码,默认1 |
| pageSize | Integer | 否 | 每页数量,默认20 |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"pageNum": 1,
"pageSize": 20,
"total": 15,
"list": [
{
"userId": 2001,
"nickname": "关注的用户",
"avatar": "https://example.com/avatar.jpg",
"level": 5,
"signature": "个性签名",
"isOnline": true,
"followTime": "2024-12-29T10:00:00",
"mutualFollow": true
}
]
}
}
6.6 获取粉丝列表
接口地址: GET /api/front/follow/followers
请求头:
Authorization: Bearer <token>
查询参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | Integer | 否 | 页码,默认1 |
| pageSize | Integer | 否 | 每页数量,默认20 |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"pageNum": 1,
"pageSize": 20,
"total": 50,
"list": [
{
"userId": 3001,
"nickname": "粉丝昵称",
"avatar": "https://example.com/avatar.jpg",
"level": 2,
"signature": "个性签名",
"isOnline": false,
"followTime": "2024-12-28T15:00:00",
"mutualFollow": false
}
]
}
}
6.7 获取关注统计
接口地址: GET /api/front/follow/stats
请求头:
Authorization: Bearer <token>
查询参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| userId | Integer | 否 | 用户ID,不传则查询当前用户 |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"userId": 1001,
"followingCount": 15,
"followersCount": 50,
"mutualFollowCount": 8
}
}
7. 作品管理模块
7.1 发布作品
接口地址: POST /api/front/works/publish
请求头:
Authorization: Bearer <token>
请求参数:
{
"title": "我的作品标题",
"description": "作品描述内容",
"type": "VIDEO",
"coverUrl": "https://example.com/cover.jpg",
"videoUrl": "https://example.com/video.mp4",
"categoryId": 1,
"tags": "热门,推荐",
"location": "北京市",
"isPublic": true
}
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| title | String | 是 | 作品标题 |
| description | String | 否 | 作品描述 |
| coverUrl | String | 是 | 封面图片URL |
| videoUrl | String | 是 | 视频URL |
| categoryId | Integer | 否 | 分类ID |
| tags | String | 否 | 标签,逗号分隔 |
| location | String | 否 | 地理位置 |
| isPublic | Boolean | 否 | 是否公开,默认true |
响应示例:
{
"code": 200,
"message": "发布成功",
"data": 10001
}
7.2 编辑作品
接口地址: POST /api/front/works/update
请求头:
Authorization: Bearer <token>
请求参数:
{
"id": 10001,
"title": "修改后的标题",
"type": "VIDEO",
"description": "修改后的描述",
"coverUrl": "https://example.com/new-cover.jpg",
"categoryId": 2,
"tags": "热门,精选",
"isPublic": true
}
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| id | Long | 是 | 作品ID |
| title | String | 否 | 作品标题 |
| description | String | 否 | 作品描述 |
| coverUrl | String | 否 | 封面图片URL |
| categoryId | Integer | 否 | 分类ID |
| tags | String | 否 | 标签 |
| isPublic | Boolean | 否 | 是否公开 |
响应示例:
{
"code": 200,
"message": "更新成功",
"data": true
}
7.3 删除作品
接口地址: POST /api/front/works/delete/{worksId}
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| worksId | Long | 是 | 作品ID |
响应示例:
{
"code": 200,
"message": "删除成功",
"data": true
}
7.4 获取作品详情
接口地址: GET /api/front/works/detail/{worksId}
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| worksId | Long | 是 | 作品ID |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"id": 10001,
"title": "作品标题",
"description": "作品描述",
"coverUrl": "https://example.com/cover.jpg",
"videoUrl": "https://example.com/video.mp4",
"authorId": 1001,
"authorNickname": "作者昵称",
"authorAvatar": "https://example.com/avatar.jpg",
"categoryId": 1,
"categoryName": "娱乐",
"tags": ["热门", "推荐"],
"location": "北京市",
"viewCount": 1234,
"likeCount": 567,
"commentCount": 89,
"shareCount": 45,
"collectCount": 123,
"isLiked": false,
"isCollected": false,
"isPublic": true,
"createTime": "2024-12-30T10:00:00",
"updateTime": "2024-12-30T11:00:00"
}
}
7.5 搜索作品
接口地址: POST /api/front/works/search
请求参数:
{
"keyword": "搜索关键词",
"categoryId": 1,
"sortBy": "hot",
"page": 1,
"pageSize": 20
}
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| keyword | String | 否 | 搜索关键词 |
| categoryId | Integer | 否 | 分类ID |
| sortBy | String | 否 | 排序方式:hot(热门)/new(最新)/like(点赞) |
| page | Integer | 否 | 页码,默认1 |
| pageSize | Integer | 否 | 每页数量,默认20 |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"pageNum": 1,
"pageSize": 20,
"total": 100,
"list": [
{
"id": 10001,
"title": "作品标题",
"coverUrl": "https://example.com/cover.jpg",
"authorId": 1001,
"authorNickname": "作者昵称",
"authorAvatar": "https://example.com/avatar.jpg",
"viewCount": 1234,
"likeCount": 567,
"isLiked": false,
"createTime": "2024-12-30T10:00:00"
}
]
}
}
7.6 获取用户作品列表
接口地址: GET /api/front/works/user/{userId}
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| userId | Integer | 是 | 用户ID |
查询参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | Integer | 否 | 页码,默认1 |
| pageSize | Integer | 否 | 每页数量,默认20 |
响应示例: 同7.5
7.7 点赞作品
接口地址: POST /api/front/works/like/{worksId}
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| worksId | Long | 是 | 作品ID |
响应示例:
{
"code": 200,
"message": "点赞成功",
"data": true
}
7.8 取消点赞
接口地址: POST /api/front/works/unlike/{worksId}
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| worksId | Long | 是 | 作品ID |
响应示例:
{
"code": 200,
"message": "取消点赞成功",
"data": true
}
7.9 收藏作品
接口地址: POST /api/front/works/collect/{worksId}
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| worksId | Long | 是 | 作品ID |
响应示例:
{
"code": 200,
"message": "收藏成功",
"data": true
}
7.10 取消收藏
接口地址: POST /api/front/works/uncollect/{worksId}
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| worksId | Long | 是 | 作品ID |
响应示例:
{
"code": 200,
"message": "取消收藏成功",
"data": true
}
7.11 获取我点赞的作品
接口地址: GET /api/front/works/my/liked
请求头:
Authorization: Bearer <token>
查询参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | Integer | 否 | 页码,默认1 |
| pageSize | Integer | 否 | 每页数量,默认20 |
响应示例: 同7.5
7.12 获取我收藏的作品
接口地址: GET /api/front/works/my/collected
请求头:
Authorization: Bearer <token>
查询参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | Integer | 否 | 页码,默认1 |
| pageSize | Integer | 否 | 每页数量,默认20 |
响应示例: 同7.5
8. 文件上传模块
8.1 上传图片
接口地址: POST /api/front/user/upload/image
请求头:
Authorization: Bearer <token>
Content-Type: multipart/form-data
请求参数:
file: (binary)
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| file | File | 是 | 图片文件 |
响应示例:
{
"code": 200,
"message": "上传成功",
"data": {
"url": "https://example.com/uploads/images/20241230/abc123.jpg",
"fileName": "abc123.jpg",
"fileSize": 102400,
"fileType": "image/jpeg",
"uploadTime": 1735542000000
}
}
8.2 上传视频
接口地址: POST /api/front/upload/work/video
请求头:
Authorization: Bearer <token>
Content-Type: multipart/form-data
请求参数:
file: (binary)
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| file | File | 是 | 视频文件 |
响应示例:
{
"code": 200,
"message": "上传成功",
"data": {
"url": "https://example.com/uploads/videos/20241230/video123.mp4",
"fileName": "video123.mp4",
"fileSize": 10485760,
"fileType": "video/mp4",
"duration": 120,
"uploadTime": 1735542000000
}
}
9. 在线状态模块
9.1 检查用户是否在线
接口地址: GET /api/front/online/status/{userId}
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| userId | Integer | 是 | 用户ID |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"userId": 2001,
"isOnline": true,
"lastOnlineTime": 1735542000000,
"status": "online"
}
}
9.2 批量检查用户在线状态
接口地址: POST /api/front/online/status/batch
请求参数:
[2001, 2002, 2003]
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| - | List | 是 | 用户ID列表 |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"2001": {
"userId": 2001,
"isOnline": true,
"lastOnlineTime": 1735542000000,
"status": "online"
},
"2002": {
"userId": 2002,
"isOnline": false,
"lastOnlineTime": 1735540000000,
"status": "offline"
}
}
}
9.3 获取直播间在线人数
接口地址: GET /api/front/online/room/{roomId}/count
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| roomId | String | 是 | 直播间ID |
响应示例:
{
"code": 200,
"message": "success",
"data": {
"roomId": "1",
"onlineCount": 1234
}
}
10. 离线消息模块
10.1 获取离线消息数量
接口地址: GET /api/front/online/offline/count/{userId}
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| userId | Integer | 是 | 用户ID |
响应示例:
{
"code": 200,
"message": null,
"data": {
"totalCount": 10,
"unreadCount": 8
}
}
10.2 获取离线消息列表
接口地址: GET /api/front/online/offline/messages/{userId}
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| userId | Integer | 是 | 用户ID |
查询参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | Integer | 否 | 页码,默认1 |
| pageSize | Integer | 否 | 每页数量,默认50 |
响应示例:
{
"code": 200,
"message": null,
"data": {
"pageNum": 1,
"pageSize": 50,
"total": 10,
"list": [
{
"id": 10001,
"conversationId": 1001,
"senderId": 2001,
"senderNickname": "发送者昵称",
"senderAvatar": "https://example.com/avatar.jpg",
"content": "你好,在吗?",
"contentType": "text",
"createTime": "2024-12-30T10:00:00",
"timestamp": 1735538400000,
"isRead": false
}
]
}
}
10.3 清空离线消息
接口地址: DELETE /api/front/online/offline/messages/{userId}
请求头:
Authorization: Bearer <token>
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| userId | Integer | 是 | 用户ID |
响应示例:
{
"code": 200,
"message": "清空成功",
"data": true
}
11. 搜索功能模块
11.1 搜索直播间
接口地址: GET /api/front/search/live-rooms
查询参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| keyword | String | 是 | 搜索关键词 |
| page | Integer | 否 | 页码,默认1 |
| pageSize | Integer | 否 | 每页数量,默认20 |
响应示例:
{
"code": 200,
"message": null,
"data": {
"pageNum": 1,
"pageSize": 20,
"total": 10,
"list": [
{
"id": "1",
"title": "直播间标题",
"streamerName": "主播昵称",
"streamerId": 1001,
"streamerAvatar": "https://example.com/avatar.jpg",
"streamerLevel": 5,
"isLive": true,
"viewerCount": 1234,
"likeCount": 5678,
"coverImage": "https://example.com/cover.jpg",
"categoryName": "娱乐",
"isFollowing": false
}
]
}
}
11.2 获取热门搜索词
接口地址: GET /api/front/search/hot
查询参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| limit | Integer | 否 | 返回数量,默认10 |
响应示例:
{
"code": 200,
"message": null,
"data": [
{
"keyword": "热门关键词1",
"searchCount": 10000,
"rank": 1,
"isHot": true
},
{
"keyword": "热门关键词2",
"searchCount": 8000,
"rank": 2,
"isHot": true
}
]
}
11.3 获取搜索建议
接口地址: GET /api/front/search/suggestions
查询参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| keyword | String | 是 | 搜索关键词 |
| limit | Integer | 否 | 返回数量,默认10 |
响应示例:
{
"code": 200,
"message": null,
"data": [
"搜索建议1",
"搜索建议2",
"搜索建议3"
]
}
11.4 获取搜索历史
接口地址: GET /api/front/search/history
请求头:
Authorization: Bearer <token>
查询参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| limit | Integer | 否 | 返回数量,默认20 |
响应示例:
{
"code": 200,
"message": null,
"data": [
{
"keyword": "搜索词1",
"searchTime": "2024-12-30T12:00:00",
"timestamp": 1735542000000
},
{
"keyword": "搜索词2",
"searchTime": "2024-12-30T11:00:00",
"timestamp": 1735538400000
}
]
}
11.5 清空搜索历史
接口地址: DELETE /api/front/search/history
请求头:
Authorization: Bearer <token>
响应示例:
{
"code": 200,
"message": "清空成功",
"data": true
}
12. 观看历史模块
12.1 添加观看历史
接口地址: POST /api/front/watch/history
请求头:
Authorization: Bearer <token>
请求参数:
{
"roomId": "1",
"duration": 120
}
参数说明:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| roomId | String | 是 | 直播间ID |
| duration | Integer | 否 | 观看时长(秒) |
响应示例:
{
"code": 200,
"message": "添加成功",
"data": true
}
12.2 获取观看历史列表
接口地址: GET /api/front/watch/history
请求头:
Authorization: Bearer <token>
查询参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | Integer | 否 | 页码,默认1 |
| pageSize | Integer | 否 | 每页数量,默认20 |
响应示例:
{
"code": 200,
"message": null,
"data": {
"pageNum": 1,
"pageSize": 20,
"total": 50,
"list": [
{
"id": 1001,
"roomId": "1",
"roomTitle": "直播间标题",
"roomCover": "https://example.com/cover.jpg",
"streamerId": 2001,
"streamerNickname": "主播昵称",
"streamerAvatar": "https://example.com/avatar.jpg",
"duration": 120,
"watchTime": "2024-12-30T12:00:00",
"timestamp": 1735542000000
}
]
}
}
12.3 清空观看历史
接口地址: DELETE /api/front/watch/history
请求头:
Authorization: Bearer <token>
响应示例:
{
"code": 200,
"message": "清空成功",
"data": true
}
13. 分类管理模块
13.1 获取直播间分类列表
接口地址: GET /api/front/category/live-room
响应示例:
{
"code": 200,
"message": null,
"data": [
{
"id": 1,
"name": "娱乐",
"type": "room",
"icon": "https://example.com/icon/entertainment.png",
"sort": 1,
"isHot": true,
"description": "娱乐分类"
},
{
"id": 2,
"name": "游戏",
"type": "room",
"icon": "https://example.com/icon/game.png",
"sort": 2,
"isHot": true,
"description": "游戏分类"
}
]
}
13.2 获取作品分类列表
接口地址: GET /api/front/category/work
响应示例:
{
"code": 200,
"message": null,
"data": [
{
"id": 1,
"name": "搞笑",
"type": "works",
"icon": "https://example.com/icon/funny.png",
"sort": 1,
"isHot": true,
"description": "搞笑分类"
},
{
"id": 2,
"name": "音乐",
"type": "works",
"icon": "https://example.com/icon/music.png",
"sort": 2,
"isHot": true,
"description": "音乐分类"
}
]
}
13.3 获取分类详情
接口地址: GET /api/front/category/{categoryId}
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| categoryId | Integer | 是 | 分类ID |
响应示例:
{
"code": 200,
"message": null,
"data": {
"id": 1,
"name": "娱乐",
"type": "room",
"icon": "https://example.com/icon/entertainment.png",
"sort": 1,
"isHot": true,
"description": "娱乐分类",
"contentCount": 1234,
"createTime": "2024-01-01T00:00:00"
}
}
13.4 根据分类获取内容列表
接口地址: GET /api/front/category/{categoryId}/content
路径参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| categoryId | Integer | 是 | 分类ID |
查询参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| sortBy | String | 否 | 排序方式:hot/new/popular,默认hot |
| page | Integer | 否 | 页码,默认1 |
| pageSize | Integer | 否 | 每页数量,默认20 |
响应示例:
{
"code": 200,
"message": null,
"data": {
"categoryId": 1,
"categoryName": "娱乐",
"pageNum": 1,
"pageSize": 20,
"total": 100,
"list": [
{
"id": "1",
"title": "直播间标题",
"type": "room",
"coverImage": "https://example.com/cover.jpg",
"streamerName": "主播昵称",
"streamerId": 1001,
"streamerAvatar": "https://example.com/avatar.jpg",
"isLive": true,
"viewerCount": 1234,
"likeCount": 5678
}
]
}
}
📝 附录
A. 通用响应格式
所有接口都遵循统一的响应格式:
{
"code": 200,
"message": "success",
"data": {}
}
响应字段说明:
| 字段名 | 类型 | 说明 |
|---|---|---|
| code | Integer | 状态码:200=成功,其他=失败 |
| message | String | 响应消息 |
| data | Object/Array | 响应数据 |
B. 常见状态码
| 状态码 | 说明 |
|---|---|
| 200 | 请求成功 |
| 400 | 请求参数错误 |
| 401 | 未授权,需要登录 |
| 403 | 禁止访问 |
| 404 | 资源不存在 |
| 500 | 服务器内部错误 |
C. 认证说明
大部分接口需要在请求头中携带Token:
Authorization: Bearer <token>
Token通过登录接口获取,有效期为7天。
D. 分页参数说明
支持分页的接口统一使用以下参数:
| 参数名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| page | Integer | 1 | 页码,从1开始 |
| pageSize | Integer | 20 | 每页数量 |
分页响应格式:
{
"pageNum": 1,
"pageSize": 20,
"total": 100,
"list": []
}
E. WebSocket连接说明
私聊WebSocket地址: ws://your-server:port/ws/private-chat?token=<token>
直播间WebSocket地址: ws://your-server:port/ws/live-chat?roomId=<roomId>&token=<token>
礼物WebSocket地址: ws://your-server:port/ws/gift?roomId=<roomId>&token=<token>
F. 文件上传说明
文件上传接口使用 multipart/form-data 格式:
- 图片支持格式:jpg, jpeg, png, gif
- 图片大小限制:5MB
- 视频支持格式:mp4, avi, mov
- 视频大小限制:100MB
G. 测试账号
测试账号1:
- 账号:18888888888
- 密码:123456
测试账号2:
- 账号:18888888889
- 密码:123456
📞 技术支持
如有问题,请联系技术支持团队。
文档结束