# 直播间管理模块接口文档 ## 模块概述 直播间管理模块提供直播间的创建、查询、控制等功能。 --- ## 接口列表 ### 1. 获取直播间列表 **接口路径**: `GET /api/front/live/public/rooms` **请求参数**: 无 **返回参数**: ```json { "code": 200, "msg": "success", "data": [ { "id": "房间ID", "title": "直播间标题", "streamerName": "主播名称", "streamerId": 主播ID, "streamerAvatar": "主播头像URL", "coverImage": "封面图URL", "isLive": true, "viewerCount": 1234, "likeCount": 5678, "categoryId": 1, "categoryName": "游戏", "tags": ["英雄联盟", "竞技"], "streamUrls": { "rtmp": "rtmp://192.168.1.164:1935/live/房间ID", "flv": "http://192.168.1.164:8080/live/房间ID.flv", "hls": "http://192.168.1.164:8080/live/房间ID.m3u8" }, "createTime": "2024-12-30T10:00:00", "startTime": "2024-12-30T10:30:00" } ] } ``` --- ### 2. 获取直播间详情 **接口路径**: `GET /api/front/live/public/rooms/{id}` **请求参数**: ``` id: 房间ID (路径参数) ``` **返回参数**: ```json { "code": 200, "msg": "success", "data": { "id": "房间ID", "title": "直播间标题", "description": "直播间描述", "streamerName": "主播名称", "streamerId": 主播ID, "streamerAvatar": "主播头像URL", "streamerLevel": 10, "coverImage": "封面图URL", "streamKey": "推流密钥", "isLive": true, "viewerCount": 1234, "likeCount": 5678, "shareCount": 123, "categoryId": 1, "categoryName": "游戏", "tags": ["英雄联盟", "竞技"], "streamUrls": { "rtmp": "rtmp://192.168.1.164:1935/live/房间ID", "flv": "http://192.168.1.164:8080/live/房间ID.flv", "hls": "http://192.168.1.164:8080/live/房间ID.m3u8" }, "isFollowing": false, "createTime": "2024-12-30T10:00:00", "startTime": "2024-12-30T10:30:00", "notice": "直播间公告" } } ``` --- ### 3. 创建直播间 **接口路径**: `POST /api/front/live/rooms` **请求头**: ``` Authorization: Bearer {token} ``` **请求参数**: ```json { "title": "直播间标题", "streamerName": "主播名称", "type": "live", "categoryId": 1, "description": "描述", "coverImage": "封面URL" } ``` **返回参数**: ```json { "code": 200, "msg": "success", "data": { "id": "房间ID", "title": "直播间标题", "streamKey": "推流密钥", "streamUrls": { "rtmp": "rtmp://192.168.1.164:1935/live/房间ID", "flv": "http://192.168.1.164:8080/live/房间ID.flv", "hls": "http://192.168.1.164:8080/live/房间ID.m3u8" } } } ``` --- ### 4. 开始直播 **接口路径**: `POST /api/front/live/room/{id}/start` **请求头**: ``` Authorization: Bearer {token} ``` **请求参数**: ``` id: 房间ID (路径参数) ``` **返回参数**: ```json { "code": 200, "msg": "success", "data": { "success": true, "message": "直播已开始" } } ``` --- ### 5. 结束直播 **接口路径**: `POST /api/front/live/room/{id}/stop` **请求头**: ``` Authorization: Bearer {token} ``` **请求参数**: ``` id: 房间ID (路径参数) ``` **返回参数**: ```json { "code": 200, "msg": "success", "data": { "success": true, "message": "直播已结束" } } ``` --- ### 6. 关注主播 **接口路径**: `POST /api/front/live/follow` **请求头**: ``` Authorization: Bearer {token} ``` **请求参数**: ```json { "streamerId": 主播ID, "action": "follow" } ``` **返回参数**: ```json { "code": 200, "msg": "success", "data": { "success": true, "isFollowing": true } } ``` --- ### 7. 获取在线人数 **接口路径**: `GET /api/live/online/count/{roomId}` **请求参数**: ``` roomId: 房间ID (路径参数) ``` **返回参数**: ```json { "code": 200, "msg": "success", "data": { "count": 1234, "roomId": "房间ID" } } ``` --- ### 8. 获取观众列表 **接口路径**: `GET /api/front/live/rooms/{roomId}/viewers` **请求参数**: ``` roomId: 房间ID (路径参数) page: 页码 (默认1) pageSize: 每页数量 (默认20) ``` **返回参数**: ```json { "code": 200, "msg": "success", "data": [ { "userId": 用户ID, "nickname": "用户昵称", "avatar": "用户头像URL", "level": 10, "vipLevel": 2, "isFollowing": false, "joinTime": "2024-12-30T10:30:00" } ], "total": 1234, "page": 1, "pageSize": 20 } ``` --- ### 9. 赠送礼物 **接口路径**: `POST /api/front/live/rooms/{roomId}/gift` **请求头**: ``` Authorization: Bearer {token} ``` **请求参数**: ```json { "roomId": 房间ID, "giftId": 礼物ID, "count": 数量 } ``` **返回参数**: ```json { "code": 200, "msg": "success", "data": { "success": true, "newBalance": 9500, "giftName": "玫瑰", "totalPrice": 500, "message": "赠送成功" } } ``` --- ### 10. 手动广播在线人数 **接口路径**: `POST /api/live/online/broadcast/{roomId}` **请求头**: ``` Authorization: Bearer {token} ``` **请求参数**: ``` roomId: 房间ID (路径参数) ``` **返回参数**: ```json { "code": 200, "msg": "success" } ```