diff --git a/java-backend/src/main/java/com/example/livestreaming/dto/CreateRoomRequest.java b/java-backend/src/main/java/com/example/livestreaming/dto/CreateRoomRequest.java deleted file mode 100644 index f2c464ca..00000000 --- a/java-backend/src/main/java/com/example/livestreaming/dto/CreateRoomRequest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.example.livestreaming.dto; - -import jakarta.validation.constraints.NotBlank; -import lombok.Data; - -@Data -public class CreateRoomRequest { - - @NotBlank(message = "标题不能为空") - private String title; - - @NotBlank(message = "主播名称不能为空") - private String streamerName; - - @NotBlank(message = "直播类型不能为空") - private String type; -} diff --git a/java-backend/src/main/java/com/example/livestreaming/dto/RoomResponse.java b/java-backend/src/main/java/com/example/livestreaming/dto/RoomResponse.java deleted file mode 100644 index 04a381d9..00000000 --- a/java-backend/src/main/java/com/example/livestreaming/dto/RoomResponse.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.example.livestreaming.dto; - -import com.example.livestreaming.entity.Room; -import lombok.Data; - -@Data -public class RoomResponse { - - private String id; - private String title; - private String streamerName; - private String type; - private String streamKey; - private boolean isLive; - private int viewerCount; - private String createdAt; - private String startedAt; - private StreamUrls streamUrls; - - @Data - public static class StreamUrls { - private String rtmp; - private String flv; - private String hls; - } - - public static RoomResponse fromEntity(Room room, String rtmpHost, int rtmpPort, String httpHost, int httpPort) { - RoomResponse response = new RoomResponse(); - response.setId(room.getId()); - response.setTitle(room.getTitle()); - response.setStreamerName(room.getStreamerName()); - response.setType(room.getType()); - response.setStreamKey(room.getStreamKey()); - response.setLive(room.isLive()); - response.setViewerCount(room.getViewerCount()); - response.setCreatedAt(room.getCreatedAt() != null ? room.getCreatedAt().toString() : null); - response.setStartedAt(room.getStartedAt() != null ? room.getStartedAt().toString() : null); - - // 构建流地址 - StreamUrls urls = new StreamUrls(); - String streamKey = room.getStreamKey(); - urls.setRtmp(String.format("rtmp://%s:%d/live/%s", rtmpHost, rtmpPort, streamKey)); - urls.setFlv(String.format("http://%s:%d/live/%s.flv", httpHost, httpPort, streamKey)); - urls.setHls(String.format("http://%s:%d/live/%s/index.m3u8", httpHost, httpPort, streamKey)); - response.setStreamUrls(urls); - - return response; - } -} diff --git a/java-backend/src/main/java/com/example/livestreaming/service/RoomService.java b/java-backend/src/main/java/com/example/livestreaming/service/RoomService.java deleted file mode 100644 index 662bd402..00000000 --- a/java-backend/src/main/java/com/example/livestreaming/service/RoomService.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.example.livestreaming.service; - -import com.example.livestreaming.dto.CreateRoomRequest; -import com.example.livestreaming.dto.RoomResponse; -import com.example.livestreaming.entity.Room; -import com.example.livestreaming.repository.RoomRepository; -import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -@Service -@RequiredArgsConstructor -public class RoomService { - - private final RoomRepository roomRepository; - - @Value("${livestream.rtmp.host:localhost}") - private String rtmpHost; - - @Value("${livestream.rtmp.port:1935}") - private int rtmpPort; - - @Value("${livestream.http.host:localhost}") - private String httpHost; - - @Value("${livestream.http.port:8080}") - private int httpPort; - - /** - * 获取所有直播间 - */ - public List getAllRooms() { - return roomRepository.findAll().stream() - .map(room -> RoomResponse.fromEntity(room, rtmpHost, rtmpPort, httpHost, httpPort)) - .collect(Collectors.toList()); - } - - /** - * 根据ID获取直播间 - */ - public Optional getRoomById(String id) { - return roomRepository.findById(id) - .map(room -> RoomResponse.fromEntity(room, rtmpHost, rtmpPort, httpHost, httpPort)); - } - - /** - * 创建直播间 - */ - @Transactional - public RoomResponse createRoom(CreateRoomRequest request) { - Room room = new Room(); - room.setTitle(request.getTitle()); - room.setStreamerName(request.getStreamerName()); - room.setType(request.getType()); - - Room saved = roomRepository.save(room); - return RoomResponse.fromEntity(saved, rtmpHost, rtmpPort, httpHost, httpPort); - } - - /** - * 更新直播状态(供SRS回调使用) - */ - @Transactional - public Optional setLiveStatus(String streamKey, boolean isLive) { - return roomRepository.findByStreamKey(streamKey) - .map(room -> { - room.setLive(isLive); - room.setStartedAt(isLive ? LocalDateTime.now() : null); - return roomRepository.save(room); - }); - } - - /** - * 删除直播间 - */ - @Transactional - public boolean deleteRoom(String id) { - if (roomRepository.existsById(id)) { - roomRepository.deleteById(id); - return true; - } - return false; - } -} diff --git a/java-backend/target/classes/com/example/livestreaming/dto/CreateRoomRequest.class b/java-backend/target/classes/com/example/livestreaming/dto/CreateRoomRequest.class deleted file mode 100644 index c1bd224d..00000000 Binary files a/java-backend/target/classes/com/example/livestreaming/dto/CreateRoomRequest.class and /dev/null differ diff --git a/java-backend/target/classes/com/example/livestreaming/dto/RoomResponse.class b/java-backend/target/classes/com/example/livestreaming/dto/RoomResponse.class deleted file mode 100644 index 7d791c16..00000000 Binary files a/java-backend/target/classes/com/example/livestreaming/dto/RoomResponse.class and /dev/null differ diff --git a/模块文档/01-用户系统模块.md b/模块文档/01-用户系统模块.md deleted file mode 100644 index 93f8b468..00000000 --- a/模块文档/01-用户系统模块.md +++ /dev/null @@ -1,194 +0,0 @@ -# 用户系统模块接口文档 - -## 模块概述 -用户系统模块提供用户注册、登录、资料管理等基础功能。 - ---- - -## 接口列表 - -### 1. 账号密码登录 - -**接口路径**: `POST /api/front/login` - -**请求参数**: -```json -{ - "account": "手机号", - "password": "密码" -} -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "token": "JWT令牌", - "uid": 用户ID, - "nikeName": "昵称", - "phone": "手机号" - } -} -``` - ---- - -### 2. APP用户注册 - -**接口路径**: `POST /api/front/register` - -**请求参数**: -```json -{ - "phone": "手机号", - "password": "密码", - "verificationCode": "验证码(可选)", - "nickname": "昵称(可选)" -} -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "token": "JWT令牌", - "uid": 用户ID, - "nikeName": "昵称", - "phone": "手机号" - } -} -``` - ---- - -### 3. 发送短信验证码 - -**接口路径**: `POST /api/front/sendCode` - -**请求参数**: -``` -phone=手机号 (FormUrlEncoded格式) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "发送成功" -} -``` - ---- - -### 4. 获取用户信息 - -**接口路径**: `GET /api/front/user` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: 无 - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "uid": 用户ID, - "nickname": "昵称", - "avatar": "头像URL", - "phone": "手机号", - "balance": 余额, - "integral": 积分, - "experience": 经验值, - "level": 等级 - } -} -``` - ---- - -### 5. 更新用户资料 - -**接口路径**: `POST /api/front/user/edit` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -```json -{ - "nickname": "昵称", - "avatar": "头像URL" -} -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success" -} -``` - ---- - -### 6. 上传头像 - -**接口路径**: `POST /api/front/user/upload/image` - -**请求头**: -``` -Authorization: Bearer {token} -Content-Type: multipart/form-data -``` - -**请求参数**: -``` -file: 图片文件 -model: "user" -pid: 7 -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "url": "图片URL", - "name": "文件名", - "size": 文件大小 - } -} -``` - ---- - -### 7. 退出登录 - -**接口路径**: `GET /api/front/logout` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: 无 - -**返回参数**: -```json -{ - "code": 200, - "msg": "success" -} -``` diff --git a/模块文档/02-直播间管理模块.md b/模块文档/02-直播间管理模块.md deleted file mode 100644 index 5e1419ba..00000000 --- a/模块文档/02-直播间管理模块.md +++ /dev/null @@ -1,336 +0,0 @@ -# 直播间管理模块接口文档 - -## 模块概述 -直播间管理模块提供直播间的创建、查询、控制等功能。 - ---- - -## 接口列表 - -### 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" -} -``` diff --git a/模块文档/03-直播间弹幕模块.md b/模块文档/03-直播间弹幕模块.md deleted file mode 100644 index 7866938a..00000000 --- a/模块文档/03-直播间弹幕模块.md +++ /dev/null @@ -1,74 +0,0 @@ -# 直播间弹幕模块接口文档 - -## 模块概述 -直播间弹幕模块提供弹幕消息的发送和历史记录查询功能。 - ---- - -## 接口列表 - -### 1. 获取历史弹幕 - -**接口路径**: `GET /api/front/live/public/rooms/{roomId}/messages` - -**请求参数**: -``` -roomId: 房间ID (路径参数) -limit: 获取最近N条消息 (可选,默认50) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": [ - { - "id": "消息ID", - "userId": 用户ID, - "nickname": "用户昵称", - "avatar": "用户头像URL", - "content": "弹幕内容", - "type": "text", - "createTime": "2024-12-30T10:30:00" - } - ] -} -``` - ---- - -### 2. 发送弹幕消息 - -**接口路径**: `POST /api/front/live/public/rooms/{roomId}/messages` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -```json -{ - "roomId": "房间ID", - "content": "弹幕内容", - "type": "text" -} -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "id": "消息ID", - "userId": 用户ID, - "nickname": "用户昵称", - "avatar": "用户头像URL", - "content": "弹幕内容", - "type": "text", - "createTime": "2024-12-30T10:30:00" - } -} -``` diff --git a/模块文档/04-WebSocket通信模块.md b/模块文档/04-WebSocket通信模块.md deleted file mode 100644 index 23220910..00000000 --- a/模块文档/04-WebSocket通信模块.md +++ /dev/null @@ -1,118 +0,0 @@ -# WebSocket通信模块接口文档 - -## 模块概述 -WebSocket通信模块提供实时弹幕和在线人数的推送功能。 - ---- - -## WebSocket连接 - -### 1. 实时弹幕WebSocket - -**连接地址**: `ws://host:port/ws/live/chat/{roomId}` - -**连接参数**: -``` -roomId: 房间ID (路径参数) -``` - -**发送消息格式**: -```json -{ - "type": "chat", - "content": "弹幕内容", - "nickname": "用户昵称", - "userId": 用户ID -} -``` - -**接收消息格式**: - -弹幕消息: -```json -{ - "type": "chat", - "nickname": "用户昵称", - "content": "弹幕内容" -} -``` - -连接确认: -```json -{ - "type": "connected", - "content": "连接成功" -} -``` - -心跳响应: -```json -{ - "type": "pong" -} -``` - -**心跳消息**: -```json -{ - "type": "ping" -} -``` - -**说明**: -- 心跳间隔: 30秒 -- 自动重连: 最多5次 -- 重连延迟: 5秒 × 重连次数 - ---- - -### 2. 在线人数WebSocket - -**连接地址**: `ws://host:port/ws/live/{roomId}?clientId={clientId}` - -**连接参数**: -``` -roomId: 房间ID (路径参数) -clientId: 客户端ID (查询参数,用户ID或guest_时间戳) -``` - -**接收消息格式**: - -在线人数更新: -```json -{ - "type": "online_count", - "count": 1234, - "roomId": "房间ID", - "timestamp": 1704000000000 -} -``` - -连接确认: -```json -{ - "type": "connected", - "message": "连接成功", - "clientId": "用户ID或guest_时间戳" -} -``` - -心跳响应: -```json -{ - "type": "pong" -} -``` - -**心跳消息**: -```json -{ - "type": "ping" -} -``` - -**说明**: -- 心跳间隔: 30秒 -- 自动重连: 最多5次 -- 重连延迟: 5秒 × 重连次数 -- 用户进入/离开时自动推送在线人数更新 diff --git a/模块文档/05-好友管理模块.md b/模块文档/05-好友管理模块.md deleted file mode 100644 index 889e2f76..00000000 --- a/模块文档/05-好友管理模块.md +++ /dev/null @@ -1,308 +0,0 @@ -# 好友管理模块接口文档 - -## 模块概述 -好友管理模块提供好友搜索、添加、删除、拉黑等功能。 - ---- - -## 接口列表 - -### 1. 搜索用户 - -**接口路径**: `GET /api/front/users/search` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -keyword: 搜索关键词 (昵称或手机号) -page: 页码 (默认1) -pageSize: 每页数量 (默认20) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "list": [ - { - "id": 用户ID, - "nickname": "昵称", - "phone": "手机号", - "avatarUrl": "头像URL", - "friendStatus": 0 - } - ], - "total": 总数, - "page": 当前页, - "limit": 每页数量 - } -} -``` - -**friendStatus说明**: -- 0: 未添加 -- 1: 已是好友 -- 2: 已申请 - ---- - -### 2. 发送好友申请 - -**接口路径**: `POST /api/front/friends/request` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -```json -{ - "targetUserId": 目标用户ID, - "message": "申请消息(可选)" -} -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": true -} -``` - ---- - -### 3. 获取好友申请列表 - -**接口路径**: `GET /api/front/friends/requests` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -page: 页码 (默认1) -pageSize: 每页数量 (默认20) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "list": [ - { - "id": 请求ID, - "from_user_id": 发送者ID, - "nickname": "发送者昵称", - "avatarUrl": "头像URL", - "message": "申请消息", - "create_time": "创建时间" - } - ], - "total": 总数 - } -} -``` - ---- - -### 4. 处理好友请求 - -**接口路径**: `POST /api/front/friends/requests/{requestId}/handle` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -```json -{ - "accept": true -} -``` - -**accept说明**: -- true: 接受 -- false: 拒绝 - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": true -} -``` - -**说明**: 接受后自动创建双向好友关系和私聊会话 - ---- - -### 5. 获取好友列表 - -**接口路径**: `GET /api/front/friends` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -page: 页码 (默认1) -pageSize: 每页数量 (默认20) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "list": [ - { - "id": 好友ID, - "name": "昵称", - "avatarUrl": "头像URL", - "phone": "手机号", - "isOnline": 1, - "lastOnlineTime": "最后在线时间" - } - ], - "total": 总数 - } -} -``` - -**isOnline说明**: -- 1: 在线 -- 0: 离线 - ---- - -### 6. 删除好友 - -**接口路径**: `DELETE /api/front/friends/{friendId}` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -friendId: 好友ID (路径参数) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": true -} -``` - -**说明**: 删除双向好友关系 - ---- - -### 7. 拉黑好友 - -**接口路径**: `POST /api/front/friends/block/{friendId}` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -friendId: 好友ID (路径参数) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": true -} -``` - -**说明**: 拉黑后自动删除好友关系,被拉黑用户无法再发送好友申请 - ---- - -### 8. 取消拉黑 - -**接口路径**: `POST /api/front/friends/unblock/{friendId}` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -friendId: 好友ID (路径参数) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": true -} -``` - ---- - -### 9. 获取黑名单列表 - -**接口路径**: `GET /api/front/friends/blocked` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -page: 页码 (默认1) -pageSize: 每页数量 (默认20) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "list": [ - { - "id": 用户ID, - "name": "昵称", - "avatarUrl": "头像URL", - "phone": "手机号", - "blockedTime": "拉黑时间" - } - ], - "total": 总数 - } -} -``` diff --git a/模块文档/06-关注功能模块.md b/模块文档/06-关注功能模块.md deleted file mode 100644 index 5cece704..00000000 --- a/模块文档/06-关注功能模块.md +++ /dev/null @@ -1,238 +0,0 @@ -# 关注功能模块接口文档 - -## 模块概述 -关注功能模块提供用户关注、取消关注、关注列表、粉丝列表等功能。 - ---- - -## 接口列表 - -### 1. 关注用户 - -**接口路径**: `POST /api/front/follow/follow` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -```json -{ - "userId": 目标用户ID -} -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "success": true, - "message": "关注成功", - "isFollowing": true - } -} -``` - ---- - -### 2. 取消关注 - -**接口路径**: `POST /api/front/follow/unfollow` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -```json -{ - "userId": 目标用户ID -} -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "success": true, - "message": "取消关注成功", - "isFollowing": false - } -} -``` - ---- - -### 3. 检查关注状态 - -**接口路径**: `GET /api/front/follow/status/{userId}` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -userId: 用户ID (路径参数) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "isFollowing": true, - "userId": 用户ID - } -} -``` - ---- - -### 4. 批量检查关注状态 - -**接口路径**: `POST /api/front/follow/status/batch` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -```json -{ - "userIds": [用户ID1, 用户ID2, 用户ID3] -} -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "statusMap": { - "用户ID1": true, - "用户ID2": false, - "用户ID3": true - } - } -} -``` - ---- - -### 5. 获取关注列表 - -**接口路径**: `GET /api/front/follow/following` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -page: 页码 (默认1) -pageSize: 每页数量 (默认20) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "list": [ - { - "userId": 用户ID, - "nickname": "昵称", - "avatar": "头像URL", - "isOnline": true, - "followTime": "关注时间" - } - ], - "total": 总数, - "page": 当前页, - "pageSize": 每页数量 - } -} -``` - ---- - -### 6. 获取粉丝列表 - -**接口路径**: `GET /api/front/follow/followers` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -page: 页码 (默认1) -pageSize: 每页数量 (默认20) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "list": [ - { - "userId": 用户ID, - "nickname": "昵称", - "avatar": "头像URL", - "isOnline": true, - "isMutualFollow": false, - "followTime": "关注时间" - } - ], - "total": 总数, - "page": 当前页, - "pageSize": 每页数量 - } -} -``` - -**isMutualFollow说明**: 是否互相关注 - ---- - -### 7. 获取关注统计 - -**接口路径**: `GET /api/front/follow/stats` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -userId: 用户ID (可选,不传则查询当前用户) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "followingCount": 关注数, - "followersCount": 粉丝数 - } -} -``` diff --git a/模块文档/07-作品管理模块.md b/模块文档/07-作品管理模块.md deleted file mode 100644 index dc8b0013..00000000 --- a/模块文档/07-作品管理模块.md +++ /dev/null @@ -1,475 +0,0 @@ -# 作品管理模块接口文档 - -## 模块概述 -作品管理模块提供作品的发布、编辑、删除、点赞、收藏等功能。 - ---- - -## 接口列表 - -### 1. 发布作品 - -**接口路径**: `POST /api/front/works/publish` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -```json -{ - "title": "作品标题", - "description": "作品描述", - "type": "IMAGE", - "coverUrl": "封面URL", - "videoUrl": "视频URL(视频作品)", - "imageUrls": ["图片URL1", "图片URL2"] -} -``` - -**type说明**: -- IMAGE: 图片作品 -- VIDEO: 视频作品 - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": 作品ID -} -``` - ---- - -### 2. 获取作品详情 - -**接口路径**: `GET /api/front/works/detail/{worksId}` - -**请求头**: -``` -Authorization: Bearer {token} (可选) -``` - -**请求参数**: -``` -worksId: 作品ID (路径参数) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "id": 作品ID, - "title": "作品标题", - "description": "作品描述", - "type": "IMAGE", - "coverUrl": "封面URL", - "videoUrl": "视频URL", - "imageUrls": ["图片URL1", "图片URL2"], - "authorId": 作者ID, - "authorName": "作者昵称", - "authorAvatar": "作者头像", - "likeCount": 点赞数, - "collectCount": 收藏数, - "commentCount": 评论数, - "shareCount": 分享数, - "isLiked": false, - "isCollected": false, - "createTime": "创建时间" - } -} -``` - ---- - -### 3. 编辑作品 - -**接口路径**: `POST /api/front/works/update` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -```json -{ - "id": 作品ID, - "title": "作品标题", - "description": "作品描述" -} -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": true -} -``` - -**说明**: 仅作者可编辑 - ---- - -### 4. 删除作品 - -**接口路径**: `POST /api/front/works/delete/{worksId}` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -worksId: 作品ID (路径参数) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": true -} -``` - -**说明**: 仅作者可删除,逻辑删除 - ---- - -### 5. 搜索作品 - -**接口路径**: `POST /api/front/works/search` - -**请求参数**: -```json -{ - "keyword": "搜索关键词", - "type": "IMAGE", - "page": 1, - "pageSize": 20 -} -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "list": [ - { - "id": 作品ID, - "title": "作品标题", - "coverUrl": "封面URL", - "type": "IMAGE", - "likeCount": 点赞数, - "authorName": "作者昵称" - } - ], - "total": 总数, - "page": 当前页, - "pageSize": 每页数量 - } -} -``` - ---- - -### 6. 获取用户作品列表 - -**接口路径**: `GET /api/front/works/user/{userId}` - -**请求参数**: -``` -userId: 用户ID (路径参数) -page: 页码 (默认1) -pageSize: 每页数量 (默认20) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "list": [ - { - "id": 作品ID, - "title": "作品标题", - "coverUrl": "封面URL", - "type": "IMAGE", - "likeCount": 点赞数 - } - ], - "total": 总数 - } -} -``` - ---- - -### 7. 点赞作品 - -**接口路径**: `POST /api/front/works/like/{worksId}` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -worksId: 作品ID (路径参数) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": true -} -``` - ---- - -### 8. 取消点赞 - -**接口路径**: `POST /api/front/works/unlike/{worksId}` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -worksId: 作品ID (路径参数) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": true -} -``` - ---- - -### 9. 收藏作品 - -**接口路径**: `POST /api/front/works/collect/{worksId}` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -worksId: 作品ID (路径参数) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": true -} -``` - ---- - -### 10. 取消收藏 - -**接口路径**: `POST /api/front/works/uncollect/{worksId}` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -worksId: 作品ID (路径参数) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": true -} -``` - ---- - -### 11. 我的点赞列表 - -**接口路径**: `GET /api/front/works/my/liked` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -page: 页码 (默认1) -pageSize: 每页数量 (默认20) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "list": [ - { - "id": 作品ID, - "title": "作品标题", - "coverUrl": "封面URL", - "type": "IMAGE", - "likeCount": 点赞数 - } - ], - "total": 总数 - } -} -``` - ---- - -### 12. 我的收藏列表 - -**接口路径**: `GET /api/front/works/my/collected` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -page: 页码 (默认1) -pageSize: 每页数量 (默认20) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "list": [ - { - "id": 作品ID, - "title": "作品标题", - "coverUrl": "封面URL", - "type": "IMAGE", - "collectCount": 收藏数 - } - ], - "total": 总数 - } -} -``` - ---- - -### 13. 分享作品 - -**接口路径**: `POST /api/front/works/share/{worksId}` - -**请求参数**: -``` -worksId: 作品ID (路径参数) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": true -} -``` - -**说明**: 增加分享次数统计 - ---- - -### 14. 视频上传 - -**接口路径**: `POST /api/front/upload/work/video` - -**请求头**: -``` -Authorization: Bearer {token} -Content-Type: multipart/form-data -``` - -**请求参数**: -``` -multipart: 视频文件 -model: "works" -pid: 0 -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "url": "视频URL", - "name": "文件名", - "size": 文件大小 - } -} -``` - ---- - -### 15. 图片上传 - -**接口路径**: `POST /api/front/upload/image` - -**请求头**: -``` -Authorization: Bearer {token} -Content-Type: multipart/form-data -``` - -**请求参数**: -``` -multipart: 图片文件 -model: "works" -pid: 0 -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "url": "图片URL", - "name": "文件名", - "size": 文件大小 - } -} -``` diff --git a/模块文档/08-搜索功能模块.md b/模块文档/08-搜索功能模块.md deleted file mode 100644 index 29f101f6..00000000 --- a/模块文档/08-搜索功能模块.md +++ /dev/null @@ -1,297 +0,0 @@ -# 搜索功能模块接口文档 - -## 模块概述 -搜索功能模块提供用户、直播间、作品的搜索,以及热门搜索、搜索历史等功能。 - ---- - -## 接口列表 - -### 1. 搜索用户 - -**接口路径**: `GET /api/front/search/users` - -**请求参数**: -``` -keyword: 搜索关键词 -pageNum: 页码 (默认1) -pageSize: 每页数量 (默认20) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "list": [ - { - "userId": 用户ID, - "nickname": "昵称", - "avatar": "头像URL", - "phone": "手机号", - "isFollowing": false - } - ], - "total": 总数, - "pageNum": 当前页, - "pageSize": 每页数量 - } -} -``` - ---- - -### 2. 搜索直播间 - -**接口路径**: `GET /api/front/search/live-rooms` - -**请求参数**: -``` -keyword: 搜索关键词 -categoryId: 分类ID (可选) -isLive: 是否直播中 (可选) -pageNum: 页码 (默认1) -pageSize: 每页数量 (默认20) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "list": [ - { - "id": "房间ID", - "title": "直播间标题", - "streamerName": "主播名称", - "coverImage": "封面图", - "isLive": true, - "viewerCount": 1234, - "categoryName": "分类名称" - } - ], - "total": 总数, - "pageNum": 当前页, - "pageSize": 每页数量 - } -} -``` - ---- - -### 3. 搜索作品 - -**接口路径**: `GET /api/front/search/works` - -**请求参数**: -``` -keyword: 搜索关键词 -categoryId: 分类ID (可选) -pageNum: 页码 (默认1) -pageSize: 每页数量 (默认20) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "list": [ - { - "id": 作品ID, - "title": "作品标题", - "coverUrl": "封面URL", - "type": "IMAGE", - "authorName": "作者昵称", - "likeCount": 点赞数, - "isLiked": false, - "isCollected": false - } - ], - "total": 总数, - "pageNum": 当前页, - "pageSize": 每页数量 - } -} -``` - ---- - -### 4. 综合搜索 - -**接口路径**: `GET /api/front/search/all` - -**请求参数**: -``` -keyword: 搜索关键词 -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "users": [ - { - "userId": 用户ID, - "nickname": "昵称", - "avatar": "头像URL" - } - ], - "liveRooms": [ - { - "id": "房间ID", - "title": "直播间标题", - "streamerName": "主播名称" - } - ], - "works": [ - { - "id": 作品ID, - "title": "作品标题", - "coverUrl": "封面URL" - } - ] - } -} -``` - -**说明**: 返回各类型的前几条结果 - ---- - -### 5. 获取热门搜索 - -**接口路径**: `GET /api/front/search/hot` - -**请求参数**: -``` -searchType: 搜索类型 (0-全部 1-用户 2-直播间 3-作品) -limit: 返回数量 (默认10) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": [ - { - "keyword": "关键词", - "searchCount": 搜索次数 - } - ] -} -``` - ---- - -### 6. 获取搜索历史 - -**接口路径**: `GET /api/front/search/history` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -searchType: 搜索类型 (可选) -limit: 返回数量 (默认20) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": [ - { - "id": 历史ID, - "keyword": "关键词", - "searchType": 搜索类型, - "createTime": "创建时间" - } - ] -} -``` - ---- - -### 7. 清除搜索历史 - -**接口路径**: `DELETE /api/front/search/history` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -searchType: 搜索类型 (可选,不传则清除全部) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "搜索历史已清除" -} -``` - ---- - -### 8. 删除单条搜索历史 - -**接口路径**: `DELETE /api/front/search/history/{historyId}` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -historyId: 历史ID (路径参数) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "删除成功" -} -``` - ---- - -### 9. 获取搜索建议 - -**接口路径**: `GET /api/front/search/suggestions` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -keyword: 关键词前缀 -searchType: 搜索类型 (可选) -limit: 返回数量 (默认10) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": ["建议1", "建议2", "建议3"] -} -``` diff --git a/模块文档/09-支付集成模块.md b/模块文档/09-支付集成模块.md deleted file mode 100644 index 58f2d296..00000000 --- a/模块文档/09-支付集成模块.md +++ /dev/null @@ -1,146 +0,0 @@ -# 支付集成模块接口文档 - -## 模块概述 -支付集成模块提供金币充值、订单创建、支付处理等功能。 - ---- - -## 接口列表 - -### 1. 获取充值选项列表 - -**接口路径**: `GET /api/front/gift/recharge/options` - -**请求参数**: 无 - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": [ - { - "id": "选项ID", - "coinAmount": 金币数量, - "price": 价格, - "discountLabel": "优惠标签" - } - ] -} -``` - ---- - -### 2. 创建充值订单 - -**接口路径**: `POST /api/front/gift/recharge/create` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -```json -{ - "optionId": "选项ID", - "coinAmount": 金币数量, - "price": 价格 -} -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "orderId": "订单ID", - "paymentUrl": "支付URL" - } -} -``` - ---- - -### 3. 订单支付 - -**接口路径**: `POST /api/front/pay/payment` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -```json -{ - "orderNo": "订单号", - "payType": "支付类型", - "payChannel": "支付渠道", - "from": "android" -} -``` - -**payType说明**: -- alipay: 支付宝支付 -- weixin: 微信支付 -- yue: 余额支付 - -**payChannel说明**: -- appAliPay: 支付宝APP支付 -- weixinAppAndroid: 微信APP支付(Android) -- yue: 余额支付 - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "status": true, - "payType": "支付类型", - "orderNo": "订单号", - "jsConfig": { - "appId": "应用ID", - "partnerId": "商户ID", - "prepayId": "预支付ID", - "package": "扩展字段", - "nonceStr": "随机字符串", - "timeStamp": "时间戳", - "sign": "签名" - } - } -} -``` - -**说明**: jsConfig用于调用支付SDK - ---- - -### 4. 查询支付宝支付结果 - -**接口路径**: `GET /api/front/pay/alipay/queryPayResult` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -orderNo: 订单号 -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": true -} -``` - -**data说明**: -- true: 支付成功 -- false: 支付失败或未支付 diff --git a/模块文档/10-分类管理模块.md b/模块文档/10-分类管理模块.md deleted file mode 100644 index 138174e8..00000000 --- a/模块文档/10-分类管理模块.md +++ /dev/null @@ -1,194 +0,0 @@ -# 分类管理模块接口文档 - -## 模块概述 -分类管理模块提供直播间分类、作品分类的查询和统计功能。 - ---- - -## 接口列表 - -### 1. 获取直播间分类列表 - -**接口路径**: `GET /api/front/category/live-room` - -**请求参数**: 无 - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": [ - { - "id": 分类ID, - "name": "分类名称", - "pid": 父分类ID, - "sort": 排序, - "extra": "扩展字段" - } - ] -} -``` - ---- - -### 2. 获取作品分类列表 - -**接口路径**: `GET /api/front/category/work` - -**请求参数**: 无 - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": [ - { - "id": 分类ID, - "name": "分类名称", - "pid": 父分类ID, - "sort": 排序, - "extra": "扩展字段" - } - ] -} -``` - ---- - -### 3. 获取指定类型的分类列表 - -**接口路径**: `GET /api/front/category/list` - -**请求参数**: -``` -type: 分类类型 (1=商品, 3=文章, 8=直播间, 9=作品) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": [ - { - "id": 分类ID, - "name": "分类名称", - "pid": 父分类ID, - "sort": 排序, - "extra": "扩展字段" - } - ] -} -``` - ---- - -### 4. 获取分类详情 - -**接口路径**: `GET /api/front/category/{id}` - -**请求参数**: -``` -id: 分类ID (路径参数) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "id": 分类ID, - "name": "分类名称", - "pid": 父分类ID, - "sort": 排序, - "extra": "扩展字段" - } -} -``` - ---- - -### 5. 获取分类统计信息 - -**接口路径**: `GET /api/front/category/statistics` - -**请求参数**: -``` -type: 分类类型 (8=直播间, 9=作品) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": [ - { - "categoryId": 分类ID, - "categoryName": "分类名称", - "count": 数量 - } - ] -} -``` - ---- - -### 6. 获取热门分类 - -**接口路径**: `GET /api/front/category/hot` - -**请求参数**: -``` -type: 分类类型 (8=直播间, 9=作品) -limit: 返回数量限制 (默认10) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": [ - { - "id": 分类ID, - "name": "分类名称", - "pid": 父分类ID, - "sort": 排序, - "extra": "扩展字段" - } - ] -} -``` - ---- - -### 7. 获取子分类列表 - -**接口路径**: `GET /api/front/category/{parentId}/children` - -**请求参数**: -``` -parentId: 父分类ID (路径参数) -recursive: 是否递归获取所有子分类 (默认false) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": [ - { - "id": 分类ID, - "name": "分类名称", - "pid": 父分类ID, - "sort": 排序, - "extra": "扩展字段" - } - ] -} -``` diff --git a/模块文档/11-消息表情回应模块.md b/模块文档/11-消息表情回应模块.md deleted file mode 100644 index b4a6bfe9..00000000 --- a/模块文档/11-消息表情回应模块.md +++ /dev/null @@ -1,137 +0,0 @@ -# 消息表情回应模块接口文档 - -## 模块概述 -消息表情回应模块提供对私聊消息添加表情符号作为快速回应的功能。 - ---- - -## 接口列表 - -### 1. 添加表情回应 - -**接口路径**: `POST /api/front/messages/reactions/add` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -```json -{ - "messageId": "消息ID", - "emoji": "表情符号" -} -``` - -**emoji说明**: 支持的表情符号如 👍 ❤️ 😂 😮 😢 😠 🔥 👏 🤔 🎉 ⭐ ✅ - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": true -} -``` - ---- - -### 2. 移除表情回应 - -**接口路径**: `DELETE /api/front/messages/reactions/remove` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -```json -{ - "messageId": "消息ID", - "emoji": "表情符号" -} -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": true -} -``` - ---- - -### 3. 获取消息的所有表情回应 - -**接口路径**: `GET /api/front/messages/{messageId}/reactions` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -messageId: 消息ID (路径参数) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": [ - { - "emoji": "👍", - "count": 5, - "reactedByMe": true - }, - { - "emoji": "❤️", - "count": 3, - "reactedByMe": false - } - ] -} -``` - -**字段说明**: -- emoji: 表情符号 -- count: 回应数量 -- reactedByMe: 当前用户是否已回应 - ---- - -### 4. 获取特定表情的用户列表 - -**接口路径**: `GET /api/front/messages/{messageId}/reactions/users` - -**请求头**: -``` -Authorization: Bearer {token} -``` - -**请求参数**: -``` -messageId: 消息ID (路径参数) -emoji: 表情符号 (查询参数) -``` - -**返回参数**: -```json -{ - "code": 200, - "msg": "success", - "data": [ - { - "userId": 用户ID, - "username": "用户名", - "avatarUrl": "头像URL" - } - ] -} -``` diff --git a/模块文档/12-私聊会话模块.md b/模块文档/12-私聊会话模块.md deleted file mode 100644 index 2a4078ff..00000000 --- a/模块文档/12-私聊会话模块.md +++ /dev/null @@ -1,282 +0,0 @@ -# 私聊会话模块 - -## 模块概述 -私聊会话模块负责处理用户之间的一对一聊天功能,包括会话管理、消息发送、消息历史等。 - -## 相关文件 -- `MessagesActivity.java` - 会话列表界面 -- `ConversationActivity.java` - 聊天界面 -- `ConversationsAdapter.java` - 会话列表适配器 -- `ConversationMessagesAdapter.java` - 消息列表适配器 -- `ConversationResponse.java` - 会话响应模型 -- `PrivateMessageResponse.java` - 私聊消息响应模型 - ---- - -## 接口列表 - -### 1. 获取会话列表 -**接口地址**: `GET /api/front/conversations` - -**请求参数**: 无 - -**返回数据**: -```json -{ - "code": 200, - "msg": "success", - "data": [ - { - "id": "long", // 会话ID - "otherUserId": "integer", // 对方用户ID - "otherUserNickname": "string", // 对方昵称 - "otherUserAvatar": "string", // 对方头像URL - "lastMessage": "string", // 最后一条消息内容 - "lastMessageTime": "long", // 最后消息时间戳 - "unreadCount": "integer", // 未读消息数 - "isOnline": "boolean" // 对方是否在线 - } - ] -} -``` - ---- - -### 2. 搜索会话 -**接口地址**: `GET /api/front/conversations/search` - -**请求参数**: -``` -keyword: string // 搜索关键词(昵称) -``` - -**返回数据**: 同获取会话列表 - ---- - -### 3. 获取或创建会话 -**接口地址**: `POST /api/front/conversations/with/{otherUserId}` - -**路径参数**: -``` -otherUserId: integer // 对方用户ID -``` - -**请求参数**: 无 - -**返回数据**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "conversationId": "long", // 会话ID - "created": "boolean" // 是否新创建 - } -} -``` - ---- - -### 4. 标记会话已读 -**接口地址**: `POST /api/front/conversations/{id}/read` - -**路径参数**: -``` -id: long // 会话ID -``` - -**请求参数**: 无 - -**返回数据**: -```json -{ - "code": 200, - "msg": "success", - "data": true -} -``` - ---- - -### 5. 删除会话 -**接口地址**: `DELETE /api/front/conversations/{id}` - -**路径参数**: -``` -id: long // 会话ID -``` - -**请求参数**: 无 - -**返回数据**: -```json -{ - "code": 200, - "msg": "删除成功", - "data": true -} -``` - ---- - -### 6. 获取会话消息列表 -**接口地址**: `GET /api/front/conversations/{id}/messages` - -**路径参数**: -``` -id: long // 会话ID -``` - -**请求参数**: -``` -page: integer // 页码,默认1 -pageSize: integer // 每页数量,默认20 -``` - -**返回数据**: -```json -{ - "code": 200, - "msg": "success", - "data": [ - { - "id": "long", // 消息ID - "conversationId": "long", // 会话ID - "senderId": "integer", // 发送者ID - "senderNickname": "string",// 发送者昵称 - "senderAvatar": "string", // 发送者头像 - "content": "string", // 消息内容 - "messageType": "string", // 消息类型: text/image/voice - "mediaUrl": "string", // 媒体文件URL(图片/语音) - "duration": "integer", // 语音时长(秒) - "isRead": "boolean", // 是否已读 - "createTime": "long" // 发送时间戳 - } - ] -} -``` - ---- - -### 7. 发送私聊消息 -**接口地址**: `POST /api/front/conversations/{id}/messages` - -**路径参数**: -``` -id: long // 会话ID -``` - -**请求参数** (SendMessageRequest): -```json -{ - "content": "string", // 消息内容 - "messageType": "string", // 消息类型: text/image/voice - "mediaUrl": "string", // 媒体文件URL(可选) - "duration": "integer" // 语音时长(可选) -} -``` - -**返回数据** (PrivateMessageResponse): -```json -{ - "code": 200, - "msg": "发送成功", - "data": { - "id": "long", // 消息ID - "conversationId": "long", // 会话ID - "senderId": "integer", // 发送者ID - "senderNickname": "string",// 发送者昵称 - "senderAvatar": "string", // 发送者头像 - "content": "string", // 消息内容 - "messageType": "string", // 消息类型 - "mediaUrl": "string", // 媒体文件URL - "duration": "integer", // 语音时长 - "isRead": "boolean", // 是否已读 - "createTime": "long" // 发送时间戳 - } -} -``` - ---- - -### 8. 删除消息 -**接口地址**: `DELETE /api/front/conversations/messages/{id}` - -**路径参数**: -``` -id: long // 消息ID -``` - -**请求参数**: 无 - -**返回数据**: -```json -{ - "code": 200, - "msg": "删除成功", - "data": true -} -``` - ---- - -## 功能说明 - -### 会话管理 -- 会话列表按最后消息时间倒序排列 -- 显示未读消息数量 -- 支持搜索会话(按对方昵称) -- 支持删除会话 - -### 消息发送 -- 支持文本消息 -- 支持图片消息(需先上传图片获取URL) -- 支持语音消息(需先上传语音获取URL) -- 消息实时推送(通过WebSocket) - -### 消息状态 -- 已读/未读状态 -- 消息发送时间 -- 消息类型标识 - ---- - -## 消息类型说明 - -| 类型 | 值 | 说明 | -|------|-----|------| -| 文本消息 | text | 普通文字消息 | -| 图片消息 | image | 图片消息,需要mediaUrl | -| 语音消息 | voice | 语音消息,需要mediaUrl和duration | - ---- - -## 使用流程 - -### 发送文本消息 -1. 进入会话界面 -2. 输入文本内容 -3. 调用发送消息接口 -4. 消息通过WebSocket实时推送给对方 - -### 发送图片消息 -1. 选择图片 -2. 调用文件上传接口获取URL -3. 调用发送消息接口,messageType为image,mediaUrl为上传返回的URL -4. 消息通过WebSocket实时推送给对方 - -### 发送语音消息 -1. 录制语音 -2. 调用文件上传接口获取URL -3. 调用发送消息接口,messageType为voice,mediaUrl为上传返回的URL,duration为语音时长 -4. 消息通过WebSocket实时推送给对方 - ---- - -## 注意事项 -1. 所有接口都需要登录认证 -2. 图片和语音消息需要先上传文件获取URL -3. 消息列表支持分页加载 -4. 建议配合WebSocket实现实时消息推送 -5. 删除会话不会删除消息记录,只是隐藏会话 diff --git a/模块文档/13-文件上传模块.md b/模块文档/13-文件上传模块.md deleted file mode 100644 index 1fa91edf..00000000 --- a/模块文档/13-文件上传模块.md +++ /dev/null @@ -1,239 +0,0 @@ -# 文件上传模块 - -## 模块概述 -文件上传模块负责处理图片、视频等媒体文件的上传功能,为用户头像、作品发布、消息图片等功能提供支持。 - -## 相关文件 -- `FileUploadResponse.java` - 文件上传响应模型 -- `PublishWorkActivity.java` - 作品发布界面(使用文件上传) -- `EditProfileActivity.java` - 编辑资料界面(使用头像上传) - ---- - -## 接口列表 - -### 1. 上传图片 -**接口地址**: `POST /api/front/user/upload/image` - -**请求方式**: `multipart/form-data` - -**请求参数**: -``` -file: File // 图片文件(必填) -model: string // 模块标识(必填) -pid: integer // 关联ID(必填) -``` - -**model参数说明**: -- `avatar` - 用户头像 -- `work` - 作品图片 -- `message` - 聊天图片 -- `cover` - 封面图片 - -**返回数据** (FileUploadResponse): -```json -{ - "code": 200, - "msg": "上传成功", - "data": { - "url": "string", // 文件访问URL - "fileName": "string", // 文件名 - "fileSize": "long", // 文件大小(字节) - "fileType": "string", // 文件类型 - "uploadTime": "long" // 上传时间戳 - } -} -``` - ---- - -### 2. 上传视频 -**接口地址**: `POST /api/front/upload/work/video` - -**请求方式**: `multipart/form-data` - -**请求参数**: -``` -file: File // 视频文件(必填) -model: string // 模块标识(必填) -pid: integer // 关联ID(必填) -``` - -**model参数说明**: -- `work` - 作品视频 -- `message` - 聊天视频 - -**返回数据** (FileUploadResponse): -```json -{ - "code": 200, - "msg": "上传成功", - "data": { - "url": "string", // 文件访问URL - "fileName": "string", // 文件名 - "fileSize": "long", // 文件大小(字节) - "fileType": "string", // 文件类型 - "duration": "integer", // 视频时长(秒) - "width": "integer", // 视频宽度 - "height": "integer", // 视频高度 - "uploadTime": "long" // 上传时间戳 - } -} -``` - ---- - -## 功能说明 - -### 支持的文件类型 - -**图片格式**: -- JPG/JPEG -- PNG -- GIF -- WEBP - -**视频格式**: -- MP4 -- AVI -- MOV -- FLV - -### 文件大小限制 -- 图片:最大 10MB -- 视频:最大 100MB - -### 上传流程 -1. 选择文件 -2. 构建 multipart/form-data 请求 -3. 调用上传接口 -4. 获取返回的文件URL -5. 使用URL进行后续操作(如发布作品、更新头像等) - ---- - -## 使用示例 - -### Android代码示例 - -#### 上传图片 -```java -// 创建文件部分 -File imageFile = new File(imagePath); -RequestBody fileBody = RequestBody.create( - MediaType.parse("image/*"), - imageFile -); -MultipartBody.Part filePart = MultipartBody.Part.createFormData( - "file", - imageFile.getName(), - fileBody -); - -// 创建其他参数 -RequestBody model = RequestBody.create( - MediaType.parse("text/plain"), - "avatar" -); -RequestBody pid = RequestBody.create( - MediaType.parse("text/plain"), - String.valueOf(userId) -); - -// 调用接口 -ApiService apiService = ApiClient.getService(context); -Call> call = - apiService.uploadImage(filePart, model, pid); - -call.enqueue(new Callback>() { - @Override - public void onResponse(Call> call, - Response> response) { - if (response.isSuccessful() && response.body() != null) { - ApiResponse apiResponse = response.body(); - if (apiResponse.getCode() == 200) { - String imageUrl = apiResponse.getData().getUrl(); - // 使用图片URL - } - } - } - - @Override - public void onFailure(Call> call, Throwable t) { - // 处理错误 - } -}); -``` - -#### 上传视频 -```java -// 创建文件部分 -File videoFile = new File(videoPath); -RequestBody fileBody = RequestBody.create( - MediaType.parse("video/*"), - videoFile -); -MultipartBody.Part filePart = MultipartBody.Part.createFormData( - "file", - videoFile.getName(), - fileBody -); - -// 创建其他参数 -RequestBody model = RequestBody.create( - MediaType.parse("text/plain"), - "work" -); -RequestBody pid = RequestBody.create( - MediaType.parse("text/plain"), - String.valueOf(userId) -); - -// 调用接口 -ApiService apiService = ApiClient.getService(context); -Call> call = - apiService.uploadVideo(filePart, model, pid); - -call.enqueue(new Callback>() { - @Override - public void onResponse(Call> call, - Response> response) { - if (response.isSuccessful() && response.body() != null) { - ApiResponse apiResponse = response.body(); - if (apiResponse.getCode() == 200) { - String videoUrl = apiResponse.getData().getUrl(); - int duration = apiResponse.getData().getDuration(); - // 使用视频URL和时长 - } - } - } - - @Override - public void onFailure(Call> call, Throwable t) { - // 处理错误 - } -}); -``` - ---- - -## 错误处理 - -| 错误码 | 说明 | -|--------|------| -| 400 | 参数错误或文件格式不支持 | -| 401 | 未登录 | -| 413 | 文件过大 | -| 415 | 不支持的文件类型 | -| 500 | 服务器错误 | - ---- - -## 注意事项 -1. 所有上传接口都需要登录认证 -2. 上传前建议先压缩图片以提高上传速度 -3. 视频上传时间较长,建议显示进度条 -4. 上传失败时可以重试 -5. model和pid参数用于后端文件管理和关联 -6. 返回的URL是完整的访问地址,可直接使用 -7. 建议在上传前检查文件大小和格式 diff --git a/模块文档/14-在线状态模块.md b/模块文档/14-在线状态模块.md deleted file mode 100644 index f292c134..00000000 --- a/模块文档/14-在线状态模块.md +++ /dev/null @@ -1,286 +0,0 @@ -# 在线状态模块 - -## 模块概述 -在线状态模块负责管理和查询用户的在线状态,包括单个用户在线状态、批量查询、房间在线人数统计等功能。 - -## 相关文件 -- `RoomDetailActivity.java` - 直播间详情(显示在线人数) -- `ConversationsAdapter.java` - 会话列表(显示好友在线状态) -- `FriendsAdapter.java` - 好友列表(显示在线状态) - ---- - -## 接口列表 - -### 1. 查询用户在线状态 -**接口地址**: `GET /api/front/online/status/{userId}` - -**路径参数**: -``` -userId: integer // 用户ID -``` - -**请求参数**: 无 - -**返回数据**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "userId": "integer", // 用户ID - "isOnline": "boolean", // 是否在线 - "lastOnlineTime": "long", // 最后在线时间戳 - "status": "string" // 状态: online/offline/busy - } -} -``` - ---- - -### 2. 批量查询用户在线状态 -**接口地址**: `POST /api/front/online/status/batch` - -**请求参数**: -```json -[1, 2, 3, 4, 5] // 用户ID数组 -``` - -**返回数据**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "1": { - "userId": 1, - "isOnline": true, - "lastOnlineTime": 1703001234567, - "status": "online" - }, - "2": { - "userId": 2, - "isOnline": false, - "lastOnlineTime": 1703000000000, - "status": "offline" - } - } -} -``` - ---- - -### 3. 获取房间在线人数 -**接口地址**: `GET /api/front/online/room/{roomId}/count` - -**路径参数**: -``` -roomId: string // 房间ID -``` - -**请求参数**: 无 - -**返回数据**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "roomId": "string", // 房间ID - "onlineCount": "integer" // 在线人数 - } -} -``` - ---- - -### 4. 获取房间在线用户列表 -**接口地址**: `GET /api/front/online/room/{roomId}/users` - -**路径参数**: -``` -roomId: string // 房间ID -``` - -**请求参数**: 无 - -**返回数据**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "roomId": "string", - "onlineCount": "integer", - "users": [ - { - "userId": "integer", - "nickname": "string", - "avatar": "string", - "joinTime": "long" // 进入房间时间 - } - ] - } -} -``` - ---- - -### 5. 获取连接统计信息 -**接口地址**: `GET /api/front/online/stats` - -**请求参数**: 无 - -**返回数据**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "totalOnlineUsers": "integer", // 总在线用户数 - "totalConnections": "integer", // 总连接数 - "totalRooms": "integer", // 总房间数 - "activeRooms": "integer", // 活跃房间数 - "serverTime": "long" // 服务器时间戳 - } -} -``` - ---- - -## 功能说明 - -### 在线状态类型 - -| 状态 | 值 | 说明 | -|------|-----|------| -| 在线 | online | 用户当前在线 | -| 离线 | offline | 用户已离线 | -| 忙碌 | busy | 用户在线但忙碌 | - -### 状态更新机制 -- 用户登录时自动设置为在线 -- 用户退出登录时设置为离线 -- WebSocket连接断开时设置为离线 -- 心跳检测维持在线状态 - -### 房间在线统计 -- 实时统计房间内的在线用户数 -- 通过WebSocket实时推送在线人数变化 -- 支持查询房间内的在线用户列表 - ---- - -## 使用场景 - -### 1. 好友列表显示在线状态 -```java -// 获取好友列表后,批量查询在线状态 -List friendIds = new ArrayList<>(); -for (Friend friend : friends) { - friendIds.add(friend.getUserId()); -} - -ApiService apiService = ApiClient.getService(context); -Call>> call = - apiService.checkUsersOnline(friendIds); - -call.enqueue(new Callback>>() { - @Override - public void onResponse(Call>> call, - Response>> response) { - if (response.isSuccessful() && response.body() != null) { - Map statusMap = response.body().getData(); - // 更新好友列表的在线状态 - } - } - - @Override - public void onFailure(Call>> call, Throwable t) { - // 处理错误 - } -}); -``` - -### 2. 直播间显示在线人数 -```java -// 进入直播间后获取在线人数 -ApiService apiService = ApiClient.getService(context); -Call>> call = - apiService.getRoomOnlineCount(roomId); - -call.enqueue(new Callback>>() { - @Override - public void onResponse(Call>> call, - Response>> response) { - if (response.isSuccessful() && response.body() != null) { - Map data = response.body().getData(); - int onlineCount = (int) data.get("onlineCount"); - // 更新UI显示在线人数 - } - } - - @Override - public void onFailure(Call>> call, Throwable t) { - // 处理错误 - } -}); - -// 同时通过WebSocket监听在线人数变化 -// 参考 WebSocket通信模块文档 -``` - -### 3. 会话列表显示对方在线状态 -```java -// 获取会话列表后,查询对方在线状态 -for (Conversation conversation : conversations) { - int otherUserId = conversation.getOtherUserId(); - - ApiService apiService = ApiClient.getService(context); - Call>> call = - apiService.checkUserOnline(otherUserId); - - call.enqueue(new Callback>>() { - @Override - public void onResponse(Call>> call, - Response>> response) { - if (response.isSuccessful() && response.body() != null) { - Map data = response.body().getData(); - boolean isOnline = (boolean) data.get("isOnline"); - // 更新会话列表的在线状态 - } - } - - @Override - public void onFailure(Call>> call, Throwable t) { - // 处理错误 - } - }); -} -``` - ---- - -## WebSocket实时推送 - -在线状态变化可以通过WebSocket实时推送,详见 [WebSocket通信模块](./04-WebSocket通信模块.md)。 - -**推送消息格式**: -```json -{ - "type": "online_status", - "userId": 123, - "isOnline": true, - "status": "online" -} -``` - ---- - -## 注意事项 -1. 批量查询建议一次不超过100个用户ID -2. 在线状态有缓存,可能存在几秒延迟 -3. 建议配合WebSocket实现实时状态更新 -4. 房间在线人数通过WebSocket实时推送更准确 -5. 离线时间超过5分钟的用户会显示最后在线时间 -6. 频繁查询在线状态可能影响性能,建议合理控制查询频率 diff --git a/模块文档/15-离线消息模块.md b/模块文档/15-离线消息模块.md deleted file mode 100644 index 970c0bdf..00000000 --- a/模块文档/15-离线消息模块.md +++ /dev/null @@ -1,296 +0,0 @@ -# 离线消息模块 - -## 模块概述 -离线消息模块负责管理用户离线期间收到的消息,包括消息存储、查询、清除等功能,确保用户上线后能够接收到离线期间的消息。 - -## 相关文件 -- `MessagesActivity.java` - 消息列表(显示离线消息提示) -- `ConversationActivity.java` - 聊天界面(加载离线消息) -- `UnreadMessageManager.java` - 未读消息管理器 - ---- - -## 接口列表 - -### 1. 获取离线消息数量 -**接口地址**: `GET /api/front/online/offline/count/{userId}` - -**路径参数**: -``` -userId: integer // 用户ID -``` - -**请求参数**: 无 - -**返回数据**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "userId": "integer", // 用户ID - "totalCount": "integer", // 总离线消息数 - "privateCount": "integer", // 私聊消息数 - "systemCount": "integer", // 系统消息数 - "lastOfflineTime": "long" // 最后离线时间 - } -} -``` - ---- - -### 2. 获取离线消息列表 -**接口地址**: `GET /api/front/online/offline/messages/{userId}` - -**路径参数**: -``` -userId: integer // 用户ID -``` - -**请求参数**: -``` -limit: integer // 获取数量限制,默认100 -``` - -**返回数据**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "userId": "integer", - "messages": [ - { - "id": "long", // 消息ID - "messageType": "string", // 消息类型: private/system/notification - "senderId": "integer", // 发送者ID - "senderNickname": "string", // 发送者昵称 - "senderAvatar": "string", // 发送者头像 - "content": "string", // 消息内容 - "conversationId": "long", // 会话ID(私聊消息) - "createTime": "long", // 消息时间戳 - "extra": {} // 额外信息 - } - ], - "totalCount": "integer", - "hasMore": "boolean" // 是否还有更多消息 - } -} -``` - ---- - -### 3. 清除离线消息 -**接口地址**: `DELETE /api/front/online/offline/messages/{userId}` - -**路径参数**: -``` -userId: integer // 用户ID -``` - -**请求参数**: 无 - -**返回数据**: -```json -{ - "code": 200, - "msg": "清除成功", - "data": "success" -} -``` - ---- - -## 功能说明 - -### 离线消息类型 - -| 类型 | 值 | 说明 | -|------|-----|------| -| 私聊消息 | private | 用户之间的私聊消息 | -| 系统消息 | system | 系统通知消息 | -| 通知消息 | notification | 应用内通知 | - -### 离线消息机制 -1. 用户离线时,服务器会保存发送给该用户的消息 -2. 用户上线后,自动推送离线消息 -3. 离线消息保存时间:7天 -4. 超过7天的离线消息会被自动清除 - -### 消息推送流程 -1. 用户登录/连接WebSocket -2. 服务器检测到用户上线 -3. 查询该用户的离线消息 -4. 通过WebSocket推送离线消息 -5. 推送完成后标记消息已送达 - ---- - -## 使用场景 - -### 1. 用户登录后获取离线消息数量 -```java -// 登录成功后查询离线消息数量 -int userId = AuthStore.getUserId(context); - -ApiService apiService = ApiClient.getService(context); -Call>> call = - apiService.getOfflineMessageCount(userId); - -call.enqueue(new Callback>>() { - @Override - public void onResponse(Call>> call, - Response>> response) { - if (response.isSuccessful() && response.body() != null) { - Map data = response.body().getData(); - int totalCount = (int) data.get("totalCount"); - - if (totalCount > 0) { - // 显示离线消息提示 - showOfflineMessageNotification(totalCount); - } - } - } - - @Override - public void onFailure(Call>> call, Throwable t) { - // 处理错误 - } -}); -``` - -### 2. 获取并显示离线消息 -```java -// 获取离线消息列表 -int userId = AuthStore.getUserId(context); - -ApiService apiService = ApiClient.getService(context); -Call>> call = - apiService.getOfflineMessages(userId, 100); - -call.enqueue(new Callback>>() { - @Override - public void onResponse(Call>> call, - Response>> response) { - if (response.isSuccessful() && response.body() != null) { - Map data = response.body().getData(); - List> messages = - (List>) data.get("messages"); - - // 处理离线消息 - for (Map message : messages) { - String messageType = (String) message.get("messageType"); - - if ("private".equals(messageType)) { - // 处理私聊消息 - handlePrivateMessage(message); - } else if ("system".equals(messageType)) { - // 处理系统消息 - handleSystemMessage(message); - } - } - - // 处理完成后清除离线消息 - clearOfflineMessages(userId); - } - } - - @Override - public void onFailure(Call>> call, Throwable t) { - // 处理错误 - } -}); -``` - -### 3. 清除离线消息 -```java -// 用户查看完离线消息后清除 -int userId = AuthStore.getUserId(context); - -ApiService apiService = ApiClient.getService(context); -Call> call = - apiService.clearOfflineMessages(userId); - -call.enqueue(new Callback>() { - @Override - public void onResponse(Call> call, - Response> response) { - if (response.isSuccessful() && response.body() != null) { - Log.d("OfflineMessage", "离线消息已清除"); - } - } - - @Override - public void onFailure(Call> call, Throwable t) { - // 处理错误 - } -}); -``` - ---- - -## WebSocket自动推送 - -用户上线后,服务器会自动通过WebSocket推送离线消息,无需手动调用接口。 - -**推送消息格式**: -```json -{ - "type": "offline_message", - "messages": [ - { - "id": 123, - "messageType": "private", - "senderId": 456, - "senderNickname": "张三", - "content": "你好", - "createTime": 1703001234567 - } - ], - "totalCount": 5 -} -``` - ---- - -## 最佳实践 - -### 1. 登录后处理流程 -``` -用户登录 - ↓ -连接WebSocket - ↓ -查询离线消息数量 - ↓ -显示离线消息提示(如果有) - ↓ -用户点击查看 - ↓ -获取离线消息列表 - ↓ -显示消息内容 - ↓ -清除离线消息 -``` - -### 2. 消息处理建议 -- 私聊消息:更新对应会话的未读数 -- 系统消息:显示在通知中心 -- 通知消息:显示应用内通知 - -### 3. 性能优化 -- 分批获取离线消息(每次100条) -- 优先显示最新的消息 -- 后台异步处理历史消息 - ---- - -## 注意事项 -1. 离线消息保存时间为7天 -2. 获取离线消息后建议及时清除,避免重复推送 -3. 离线消息数量过多时建议分批获取 -4. WebSocket连接成功后会自动推送离线消息 -5. 清除操作不可恢复,请谨慎使用 -6. 建议在用户查看完消息后再清除 -7. 系统会自动清理已读的离线消息 diff --git a/模块文档/16-观看历史模块.md b/模块文档/16-观看历史模块.md deleted file mode 100644 index 4405331e..00000000 --- a/模块文档/16-观看历史模块.md +++ /dev/null @@ -1,170 +0,0 @@ -# 观看历史模块 - -## 模块概述 -观看历史模块负责记录用户观看直播间的历史记录,用于推荐算法、用户行为分析等功能。 - -## 相关文件 -- `RoomDetailActivity.java` - 直播间详情(记录观看历史) -- `WatchHistoryActivity.java` - 观看历史列表界面 - ---- - -## 接口列表 - -### 1. 记录观看历史 -**接口地址**: `POST /api/front/watch/history` - -**请求参数**: -```json -{ - "roomId": "string", // 直播间ID(必填) - "watchTime": "long" // 观看时间戳(必填) -} -``` - -**返回数据**: -```json -{ - "code": 200, - "msg": "记录成功", - "data": { - "historyId": "long", // 历史记录ID - "roomId": "string", // 直播间ID - "userId": "integer", // 用户ID - "watchTime": "long", // 观看时间 - "duration": "integer" // 观看时长(秒) - } -} -``` - ---- - -## 功能说明 - -### 记录时机 -- 用户进入直播间时自动记录 -- 记录用户进入时间 -- 用户退出时更新观看时长 - -### 数据用途 -- 个性化推荐:根据观看历史推荐相似直播间 -- 用户画像:分析用户兴趣偏好 -- 数据统计:统计直播间热度和观看数据 -- 历史记录:用户可查看自己的观看历史 - -### 隐私保护 -- 仅记录已登录用户的观看历史 -- 用户可以清除自己的观看历史 -- 观看历史仅用户本人可见 - ---- - -## 使用场景 - -### 1. 进入直播间时记录 -```java -// 在 RoomDetailActivity 的 onCreate 中调用 -private void recordWatchHistory() { - if (!AuthHelper.isLoggedIn(this)) { - return; // 未登录用户不记录 - } - - if (TextUtils.isEmpty(roomId)) { - return; - } - - ApiService apiService = ApiClient.getService(getApplicationContext()); - - Map body = new HashMap<>(); - body.put("roomId", roomId); - body.put("watchTime", System.currentTimeMillis()); - - Call>> call = - apiService.recordWatchHistory(body); - - call.enqueue(new Callback>>() { - @Override - public void onResponse(Call>> call, - Response>> response) { - if (response.isSuccessful() && response.body() != null) { - Log.d("RoomDetail", "观看历史记录成功"); - } - } - - @Override - public void onFailure(Call>> call, Throwable t) { - Log.e("RoomDetail", "观看历史记录失败: " + t.getMessage()); - } - }); -} -``` - -### 2. 退出直播间时更新时长 -```java -// 在 onDestroy 或 onStop 中调用 -private void updateWatchDuration() { - if (historyId == null) { - return; - } - - long duration = (System.currentTimeMillis() - enterTime) / 1000; // 秒 - - // 调用更新接口(如果后端提供) - // 或者在记录时就包含时长计算 -} -``` - ---- - -## 扩展功能(建议) - -虽然当前接口只有记录功能,但建议后端提供以下扩展接口: - -### 获取观看历史列表 -``` -GET /api/front/watch/history -参数: page, pageSize -返回: 用户的观看历史列表 -``` - -### 清除观看历史 -``` -DELETE /api/front/watch/history/{historyId} -或 -DELETE /api/front/watch/history/clear -``` - -### 获取推荐直播间 -``` -GET /api/front/watch/recommendations -基于观看历史推荐相似直播间 -``` - ---- - -## 数据统计 - -观看历史数据可用于以下统计: - -### 用户维度 -- 观看总时长 -- 观看直播间数量 -- 最常观看的分类 -- 观看时间分布 - -### 直播间维度 -- 总观看人数 -- 平均观看时长 -- 回访率 -- 观看高峰时段 - ---- - -## 注意事项 -1. 仅记录已登录用户的观看历史 -2. 未登录用户不会记录观看历史 -3. 记录失败不影响用户正常观看 -4. 建议异步记录,不阻塞主流程 -5. 观看时长计算应考虑用户切换后台的情况 -6. 同一用户多次进入同一直播间会产生多条记录 -7. 建议定期清理过期的历史记录(如保留最近3个月) diff --git a/模块文档/17-礼物打赏模块.md b/模块文档/17-礼物打赏模块.md deleted file mode 100644 index 51171928..00000000 --- a/模块文档/17-礼物打赏模块.md +++ /dev/null @@ -1,394 +0,0 @@ -# 礼物打赏模块 - -## 模块概述 -礼物打赏模块负责处理直播间内的虚拟礼物赠送功能,包括礼物列表、用户余额、礼物赠送、充值等功能。 - -## 相关文件 -- `RoomDetailActivity.java` - 直播间详情(礼物赠送) -- `Gift.java` - 礼物模型 -- `GiftAdapter.java` - 礼物列表适配器 -- `GiftResponse.java` - 礼物响应模型 -- `SendGiftRequest.java` - 赠送礼物请求模型 -- `SendGiftResponse.java` - 赠送礼物响应模型 -- `UserBalanceResponse.java` - 用户余额响应模型 -- `RechargeOption.java` - 充值选项模型 -- `RechargeAdapter.java` - 充值选项适配器 - ---- - -## 接口列表 - -### 1. 获取礼物列表 -**接口地址**: `GET /api/front/gift/list` - -**请求参数**: 无 - -**返回数据**: -```json -{ - "code": 200, - "msg": "success", - "data": [ - { - "id": "integer", // 礼物ID - "name": "string", // 礼物名称 - "price": "integer", // 礼物价格(金币) - "icon": "string", // 礼物图标URL - "level": "integer", // 礼物等级(1-5) - "description": "string", // 礼物描述 - "animation": "string", // 动画效果URL - "sort": "integer" // 排序 - } - ] -} -``` - ---- - -### 2. 获取用户余额 -**接口地址**: `GET /api/front/gift/balance` - -**请求参数**: 无 - -**返回数据** (UserBalanceResponse): -```json -{ - "code": 200, - "msg": "success", - "data": { - "userId": "integer", // 用户ID - "coinBalance": "integer", // 金币余额 - "totalRecharge": "integer",// 累计充值金币 - "totalConsume": "integer", // 累计消费金币 - "vipLevel": "integer" // VIP等级 - } -} -``` - ---- - -### 3. 赠送礼物 -**接口地址**: `POST /api/front/gift/send` - -**请求参数** (SendGiftRequest): -```json -{ - "giftId": "integer", // 礼物ID(必填) - "receiverId": "integer", // 接收者ID(必填) - "roomId": "string", // 直播间ID(必填) - "count": "integer", // 赠送数量(必填) - "message": "string" // 附加消息(可选) -} -``` - -**返回数据** (SendGiftResponse): -```json -{ - "code": 200, - "msg": "赠送成功", - "data": { - "giftRecordId": "long", // 礼物记录ID - "giftId": "integer", // 礼物ID - "giftName": "string", // 礼物名称 - "count": "integer", // 赠送数量 - "totalPrice": "integer", // 总价格 - "newBalance": "integer", // 赠送后的余额 - "sendTime": "long" // 赠送时间戳 - } -} -``` - ---- - -### 4. 获取充值选项 -**接口地址**: `GET /api/front/gift/recharge/options` - -**请求参数**: 无 - -**返回数据**: -```json -{ - "code": 200, - "msg": "success", - "data": [ - { - "id": "string", // 选项ID - "coinAmount": "integer", // 金币数量 - "price": "number", // 价格(元) - "discountLabel": "string",// 优惠标签(可选) - "isHot": "boolean", // 是否热门 - "sort": "integer" // 排序 - } - ] -} -``` - ---- - -### 5. 创建充值订单 -**接口地址**: `POST /api/front/gift/recharge/create` - -**请求参数** (CreateRechargeRequest): -```json -{ - "optionId": "string", // 充值选项ID(必填) - "coinAmount": "integer", // 金币数量(必填) - "price": "number" // 价格(必填) -} -``` - -**返回数据** (CreateRechargeResponse): -```json -{ - "code": 200, - "msg": "订单创建成功", - "data": { - "orderId": "string", // 订单ID - "orderNo": "string", // 订单号 - "coinAmount": "integer", // 金币数量 - "price": "number", // 价格 - "paymentUrl": "string", // 支付URL - "createTime": "long" // 创建时间 - } -} -``` - ---- - -## 功能说明 - -### 礼物等级 - -| 等级 | 价格范围 | 说明 | -|------|---------|------| -| 1 | 1-50金币 | 普通礼物 | -| 2 | 51-100金币 | 精美礼物 | -| 3 | 101-500金币 | 豪华礼物 | -| 4 | 501-1000金币 | 贵族礼物 | -| 5 | 1000+金币 | 至尊礼物 | - -### 赠送流程 -1. 用户点击礼物按钮 -2. 显示礼物列表和当前余额 -3. 选择礼物和数量 -4. 检查余额是否足够 -5. 调用赠送接口 -6. 扣除金币,更新余额 -7. 在直播间显示礼物动画 -8. 通过WebSocket推送给其他观众 - -### 充值流程 -1. 用户点击充值按钮 -2. 显示充值选项列表 -3. 选择充值金额 -4. 创建充值订单 -5. 选择支付方式(支付宝/微信) -6. 调用支付接口 -7. 支付成功后更新余额 - ---- - -## 使用场景 - -### 1. 加载礼物列表 -```java -private void loadGiftsFromBackend() { - ApiService apiService = ApiClient.getService(getApplicationContext()); - Call>> call = apiService.getGiftList(); - - call.enqueue(new Callback>>() { - @Override - public void onResponse(Call>> call, - Response>> response) { - if (response.isSuccessful() && response.body() != null) { - ApiResponse> apiResponse = response.body(); - if (apiResponse.getCode() == 200 && apiResponse.getData() != null) { - availableGifts = new ArrayList<>(); - for (GiftResponse giftResponse : apiResponse.getData()) { - Gift gift = new Gift( - String.valueOf(giftResponse.getId()), - giftResponse.getName(), - giftResponse.getPrice().intValue(), - R.drawable.ic_gift_rose, - giftResponse.getLevel() != null ? giftResponse.getLevel() : 1 - ); - availableGifts.add(gift); - } - } - } - } - - @Override - public void onFailure(Call>> call, Throwable t) { - Log.e("Gift", "加载礼物列表失败: " + t.getMessage()); - } - }); -} -``` - -### 2. 获取用户余额 -```java -private void loadUserBalance(TextView coinBalanceView) { - ApiService apiService = ApiClient.getService(getApplicationContext()); - Call> call = apiService.getUserBalance(); - - call.enqueue(new Callback>() { - @Override - public void onResponse(Call> call, - Response> response) { - if (response.isSuccessful() && response.body() != null) { - ApiResponse apiResponse = response.body(); - if (apiResponse.getCode() == 200 && apiResponse.getData() != null) { - userCoinBalance = apiResponse.getData().getCoinBalance().intValue(); - coinBalanceView.setText(String.valueOf(userCoinBalance)); - } - } - } - - @Override - public void onFailure(Call> call, Throwable t) { - Log.e("Gift", "获取余额失败: " + t.getMessage()); - } - }); -} -``` - -### 3. 赠送礼物 -```java -private void sendGiftToBackend(Gift selectedGift, int count, int totalPrice) { - // 检查余额 - if (userCoinBalance < totalPrice) { - Toast.makeText(this, "金币不足,请先充值", Toast.LENGTH_SHORT).show(); - showRechargeDialog(); - return; - } - - ApiService apiService = ApiClient.getService(getApplicationContext()); - - SendGiftRequest request = new SendGiftRequest(); - request.setGiftId(Integer.parseInt(selectedGift.getId())); - request.setReceiverId(room.getStreamerId()); - request.setRoomId(roomId); - request.setCount(count); - - Call> call = apiService.sendGift(request); - - call.enqueue(new Callback>() { - @Override - public void onResponse(Call> call, - Response> response) { - if (response.isSuccessful() && response.body() != null) { - ApiResponse apiResponse = response.body(); - if (apiResponse.getCode() == 200 && apiResponse.getData() != null) { - SendGiftResponse giftResponse = apiResponse.getData(); - - // 更新余额 - userCoinBalance = giftResponse.getNewBalance().intValue(); - - // 显示赠送消息 - String giftMessage = String.format("送出了 %d 个 %s", - count, selectedGift.getName()); - addChatMessage(new ChatMessage("我", giftMessage, true)); - - Toast.makeText(RoomDetailActivity.this, - "赠送成功!", Toast.LENGTH_SHORT).show(); - } - } - } - - @Override - public void onFailure(Call> call, Throwable t) { - Toast.makeText(RoomDetailActivity.this, - "网络错误: " + t.getMessage(), Toast.LENGTH_SHORT).show(); - } - }); -} -``` - -### 4. 创建充值订单 -```java -private void createRechargeOrder(RechargeOption selectedOption) { - ApiService apiService = ApiClient.getService(getApplicationContext()); - - CreateRechargeRequest request = new CreateRechargeRequest(); - request.setOptionId(selectedOption.getId()); - request.setCoinAmount(selectedOption.getCoinAmount()); - request.setPrice(selectedOption.getPrice()); - - Call> call = - apiService.createRecharge(request); - - call.enqueue(new Callback>() { - @Override - public void onResponse(Call> call, - Response> response) { - if (response.isSuccessful() && response.body() != null) { - ApiResponse apiResponse = response.body(); - if (apiResponse.getCode() == 200 && apiResponse.getData() != null) { - CreateRechargeResponse rechargeResponse = apiResponse.getData(); - String orderId = rechargeResponse.getOrderId(); - - // 显示支付选择对话框 - showPaymentMethodDialog(orderId, selectedOption); - } - } - } - - @Override - public void onFailure(Call> call, Throwable t) { - Toast.makeText(RoomDetailActivity.this, - "网络错误: " + t.getMessage(), Toast.LENGTH_SHORT).show(); - } - }); -} -``` - ---- - -## WebSocket推送 - -礼物赠送后会通过WebSocket推送给直播间内的所有用户,用于显示礼物动画。 - -**推送消息格式**: -```json -{ - "type": "gift", - "giftId": 1, - "giftName": "玫瑰", - "count": 10, - "senderId": 123, - "senderNickname": "张三", - "receiverId": 456, - "receiverNickname": "主播", - "roomId": "room123" -} -``` - ---- - -## 默认礼物列表 - -如果接口加载失败,可以使用以下默认礼物: - -| ID | 名称 | 价格 | 等级 | -|----|------|------|------| -| 1 | 玫瑰 | 10 | 1 | -| 2 | 爱心 | 20 | 1 | -| 3 | 蛋糕 | 50 | 2 | -| 4 | 星星 | 100 | 2 | -| 5 | 钻石 | 200 | 3 | -| 6 | 皇冠 | 500 | 4 | -| 7 | 跑车 | 1000 | 5 | -| 8 | 火箭 | 2000 | 5 | - ---- - -## 注意事项 -1. 所有接口都需要登录认证 -2. 赠送礼物前必须检查余额是否足够 -3. 礼物价格以金币为单位,不是人民币 -4. 充值需要集成第三方支付SDK(支付宝/微信) -5. 礼物动画效果需要前端实现 -6. 建议缓存礼物列表,减少网络请求 -7. 余额变化后及时更新UI显示 -8. 赠送失败时不扣除金币 diff --git a/模块文档/18-通话功能模块.md b/模块文档/18-通话功能模块.md deleted file mode 100644 index 29d00ef4..00000000 --- a/模块文档/18-通话功能模块.md +++ /dev/null @@ -1,526 +0,0 @@ -# 通话功能模块 - -## 模块概述 -通话功能模块负责处理用户之间的语音和视频通话功能,包括发起通话、接听/拒绝通话、通话记录等。 - -## 相关文件 -- `CallActivity.java` - 通话界面 -- `IncomingCallActivity.java` - 来电界面 -- `CallHistoryActivity.java` - 通话记录界面 -- `CallManager.java` - 通话管理器 -- `CallSignalingClient.java` - 信令客户端 -- `CallApiService.java` - 通话API接口 -- `InitiateCallRequest.java` - 发起通话请求模型 -- `InitiateCallResponse.java` - 发起通话响应模型 -- `CallRecordResponse.java` - 通话记录响应模型 -- `CallHistoryResponse.java` - 通话历史响应模型 - ---- - -## 接口列表 - -### 1. 发起通话 -**接口地址**: `POST /api/front/call/initiate` - -**请求参数** (InitiateCallRequest): -```json -{ - "calleeId": "integer", // 被叫用户ID(必填) - "callType": "string" // 通话类型: voice/video(必填) -} -``` - -**返回数据** (InitiateCallResponse): -```json -{ - "code": 200, - "msg": "success", - "data": { - "callId": "string", // 通话ID - "callType": "string", // 通话类型 - "calleeId": "integer", // 被叫用户ID - "calleeName": "string", // 被叫用户昵称 - "calleeAvatar": "string", // 被叫用户头像 - "status": "string", // 通话状态: calling - "signalingUrl": "string" // 信令服务器URL - } -} -``` - ---- - -### 2. 接听通话 -**接口地址**: `POST /api/front/call/accept/{callId}` - -**路径参数**: -``` -callId: string // 通话ID -``` - -**请求参数**: 无 - -**返回数据**: -```json -{ - "code": 200, - "msg": "接听成功", - "data": true -} -``` - ---- - -### 3. 拒绝通话 -**接口地址**: `POST /api/front/call/reject/{callId}` - -**路径参数**: -``` -callId: string // 通话ID -``` - -**请求参数**: 无 - -**返回数据**: -```json -{ - "code": 200, - "msg": "已拒绝", - "data": true -} -``` - ---- - -### 4. 取消通话 -**接口地址**: `POST /api/front/call/cancel/{callId}` - -**路径参数**: -``` -callId: string // 通话ID -``` - -**请求参数**: 无 - -**返回数据**: -```json -{ - "code": 200, - "msg": "已取消", - "data": true -} -``` - ---- - -### 5. 结束通话 -**接口地址**: `POST /api/front/call/end/{callId}` - -**路径参数**: -``` -callId: string // 通话ID -``` - -**请求参数**: -``` -endReason: string // 结束原因(可选) -``` - -**返回数据**: -```json -{ - "code": 200, - "msg": "通话已结束", - "data": true -} -``` - ---- - -### 6. 获取通话记录 -**接口地址**: `GET /api/front/call/history` - -**请求参数**: -``` -page: integer // 页码,默认1 -limit: integer // 每页数量,默认20 -``` - -**返回数据** (CallHistoryResponse): -```json -{ - "code": 200, - "msg": "success", - "data": { - "records": [ - { - "id": "long", // 记录ID - "callId": "string", // 通话ID - "callType": "string", // 通话类型: voice/video - "callDirection": "string", // 通话方向: outgoing/incoming - "otherUserId": "integer", // 对方用户ID - "otherUserName": "string", // 对方用户昵称 - "otherUserAvatar": "string",// 对方用户头像 - "status": "string", // 状态: completed/missed/rejected/cancelled - "duration": "integer", // 通话时长(秒) - "startTime": "long", // 开始时间戳 - "endTime": "long" // 结束时间戳 - } - ], - "total": "integer", - "page": "integer", - "limit": "integer" - } -} -``` - ---- - -### 7. 删除通话记录 -**接口地址**: `DELETE /api/front/call/record/{recordId}` - -**路径参数**: -``` -recordId: long // 记录ID -``` - -**请求参数**: 无 - -**返回数据**: -```json -{ - "code": 200, - "msg": "删除成功", - "data": true -} -``` - ---- - -### 8. 获取未接来电数量 -**接口地址**: `GET /api/front/call/missed/count` - -**请求参数**: 无 - -**返回数据**: -```json -{ - "code": 200, - "msg": "success", - "data": 5 // 未接来电数量 -} -``` - ---- - -### 9. 获取通话状态 -**接口地址**: `GET /api/front/call/status` - -**请求参数**: 无 - -**返回数据**: -```json -{ - "code": 200, - "msg": "success", - "data": { - "inCall": "boolean", // 是否正在通话中 - "callId": "string", // 当前通话ID - "callType": "string", // 通话类型 - "otherUserId": "integer", // 对方用户ID - "startTime": "long" // 通话开始时间 - } -} -``` - ---- - -### 10. 获取通话详情 -**接口地址**: `GET /api/front/call/detail/{callId}` - -**路径参数**: -``` -callId: string // 通话ID -``` - -**请求参数**: 无 - -**返回数据** (CallRecordResponse): -```json -{ - "code": 200, - "msg": "success", - "data": { - "id": "long", - "callId": "string", - "callType": "string", - "callDirection": "string", - "callerId": "integer", - "callerName": "string", - "callerAvatar": "string", - "calleeId": "integer", - "calleeName": "string", - "calleeAvatar": "string", - "status": "string", - "duration": "integer", - "startTime": "long", - "endTime": "long", - "endReason": "string" - } -} -``` - ---- - -## 功能说明 - -### 通话类型 - -| 类型 | 值 | 说明 | -|------|-----|------| -| 语音通话 | voice | 仅语音通话 | -| 视频通话 | video | 视频+语音通话 | - -### 通话状态 - -| 状态 | 值 | 说明 | -|------|-----|------| -| 呼叫中 | calling | 正在呼叫对方 | -| 振铃中 | ringing | 对方正在振铃 | -| 通话中 | connected | 通话已接通 | -| 已完成 | completed | 通话正常结束 | -| 未接听 | missed | 对方未接听 | -| 已拒绝 | rejected | 对方拒绝接听 | -| 已取消 | cancelled | 主叫方取消 | -| 已结束 | ended | 通话结束 | - -### 通话方向 - -| 方向 | 值 | 说明 | -|------|-----|------| -| 呼出 | outgoing | 我发起的通话 | -| 呼入 | incoming | 对方发起的通话 | - ---- - -## 通话流程 - -### 发起通话流程 -``` -1. 用户A点击通话按钮 - ↓ -2. 调用发起通话接口 - ↓ -3. 获取callId和信令服务器地址 - ↓ -4. 连接信令服务器 - ↓ -5. 等待对方响应 - ↓ -6. 对方接听 → 建立P2P连接 → 开始通话 - 或 - 对方拒绝/超时 → 结束流程 -``` - -### 接听通话流程 -``` -1. 用户B收到来电通知(WebSocket推送) - ↓ -2. 显示来电界面 - ↓ -3. 用户点击接听按钮 - ↓ -4. 调用接听通话接口 - ↓ -5. 连接信令服务器 - ↓ -6. 建立P2P连接 - ↓ -7. 开始通话 -``` - -### 结束通话流程 -``` -1. 用户点击挂断按钮 - ↓ -2. 调用结束通话接口 - ↓ -3. 断开P2P连接 - ↓ -4. 断开信令连接 - ↓ -5. 保存通话记录 - ↓ -6. 返回上一页面 -``` - ---- - -## WebSocket推送 - -通话相关的实时通知通过WebSocket推送: - -### 来电通知 -```json -{ - "type": "incoming_call", - "callId": "call123", - "callType": "video", - "callerId": 123, - "callerName": "张三", - "callerAvatar": "https://..." -} -``` - -### 通话状态变化 -```json -{ - "type": "call_status", - "callId": "call123", - "status": "connected", - "timestamp": 1703001234567 -} -``` - -### 对方挂断 -```json -{ - "type": "call_ended", - "callId": "call123", - "endReason": "normal", - "duration": 120 -} -``` - ---- - -## 使用示例 - -### 1. 发起语音通话 -```java -private void initiateVoiceCall(int calleeId) { - CallApiService callApiService = // 获取CallApiService实例 - - InitiateCallRequest request = new InitiateCallRequest(calleeId, "voice"); - Call> call = - callApiService.initiateCall(request); - - call.enqueue(new Callback>() { - @Override - public void onResponse(Call> call, - Response> response) { - if (response.isSuccessful() && response.body() != null) { - CallApiResponse apiResponse = response.body(); - if (apiResponse.getCode() == 200) { - InitiateCallResponse data = apiResponse.getData(); - String callId = data.getCallId(); - String signalingUrl = data.getSignalingUrl(); - - // 跳转到通话界面 - Intent intent = new Intent(this, CallActivity.class); - intent.putExtra("callId", callId); - intent.putExtra("callType", "voice"); - intent.putExtra("signalingUrl", signalingUrl); - startActivity(intent); - } - } - } - - @Override - public void onFailure(Call> call, Throwable t) { - Toast.makeText(this, "发起通话失败", Toast.LENGTH_SHORT).show(); - } - }); -} -``` - -### 2. 接听通话 -```java -private void acceptCall(String callId) { - CallApiService callApiService = // 获取CallApiService实例 - - Call> call = callApiService.acceptCall(callId); - - call.enqueue(new Callback>() { - @Override - public void onResponse(Call> call, - Response> response) { - if (response.isSuccessful() && response.body() != null) { - CallApiResponse apiResponse = response.body(); - if (apiResponse.getCode() == 200) { - // 跳转到通话界面 - Intent intent = new Intent(this, CallActivity.class); - intent.putExtra("callId", callId); - startActivity(intent); - finish(); - } - } - } - - @Override - public void onFailure(Call> call, Throwable t) { - Toast.makeText(this, "接听失败", Toast.LENGTH_SHORT).show(); - } - }); -} -``` - -### 3. 获取通话记录 -```java -private void loadCallHistory(int page) { - CallApiService callApiService = // 获取CallApiService实例 - - Call> call = - callApiService.getCallHistory(page, 20); - - call.enqueue(new Callback>() { - @Override - public void onResponse(Call> call, - Response> response) { - if (response.isSuccessful() && response.body() != null) { - CallApiResponse apiResponse = response.body(); - if (apiResponse.getCode() == 200) { - CallHistoryResponse data = apiResponse.getData(); - List records = data.getRecords(); - - // 更新UI显示通话记录 - updateCallHistoryList(records); - } - } - } - - @Override - public void onFailure(Call> call, Throwable t) { - Toast.makeText(this, "加载失败", Toast.LENGTH_SHORT).show(); - } - }); -} -``` - ---- - -## 技术实现 - -### WebRTC集成 -通话功能基于WebRTC技术实现: -- 使用信令服务器交换SDP和ICE候选 -- 建立P2P连接进行音视频传输 -- 支持NAT穿透 - -### 权限要求 -- 语音通话:`RECORD_AUDIO` -- 视频通话:`RECORD_AUDIO` + `CAMERA` -- 网络访问:`INTERNET` - ---- - -## 注意事项 -1. 所有接口都需要登录认证 -2. 通话前需要检查对方是否在线 -3. 需要申请音频和摄像头权限 -4. 通话过程中保持屏幕常亮 -5. 通话时禁用锁屏 -6. 建议使用耳机以获得更好的通话质量 -7. 通话记录保存30天 -8. 未接来电会显示红点提示 -9. 通话过程中网络断开需要自动重连 -10. 需要集成WebRTC库实现音视频通话 diff --git a/模块文档/README.md b/模块文档/README.md deleted file mode 100644 index 5e081612..00000000 --- a/模块文档/README.md +++ /dev/null @@ -1,145 +0,0 @@ -# 直播IM系统接口文档总览 - -## 文档说明 - -本文档集按照功能模块组织,每个模块文档包含: -- 模块概述 -- 接口列表 -- 每个接口的请求参数和返回参数 - -**注意**: 本文档仅包含接口定义,不包含代码实现。 - ---- - -## 模块列表 - -### 已完成模块 (18个) - -| 序号 | 模块名称 | 接口数量 | 文档文件 | 状态 | -|------|---------|---------|---------|------| -| 1 | 用户系统模块 | 7 | [01-用户系统模块.md](./01-用户系统模块.md) | ✅ 已完成 | -| 2 | 直播间管理模块 | 10 | [02-直播间管理模块.md](./02-直播间管理模块.md) | ✅ 已完成 | -| 3 | 直播间弹幕模块 | 2 | [03-直播间弹幕模块.md](./03-直播间弹幕模块.md) | ✅ 已完成 | -| 4 | WebSocket通信模块 | 2 | [04-WebSocket通信模块.md](./04-WebSocket通信模块.md) | ✅ 已完成 | -| 5 | 好友管理模块 | 9 | [05-好友管理模块.md](./05-好友管理模块.md) | ✅ 已完成 | -| 6 | 关注功能模块 | 7 | [06-关注功能模块.md](./06-关注功能模块.md) | ✅ 已完成 | -| 7 | 作品管理模块 | 15 | [07-作品管理模块.md](./07-作品管理模块.md) | ✅ 已完成 | -| 8 | 搜索功能模块 | 9 | [08-搜索功能模块.md](./08-搜索功能模块.md) | ✅ 已完成 | -| 9 | 支付集成模块 | 4 | [09-支付集成模块.md](./09-支付集成模块.md) | ✅ 已完成 | -| 10 | 分类管理模块 | 7 | [10-分类管理模块.md](./10-分类管理模块.md) | ✅ 已完成 | -| 11 | 消息表情回应模块 | 4 | [11-消息表情回应模块.md](./11-消息表情回应模块.md) | ✅ 已完成 | -| 12 | 私聊会话模块 | 8 | [12-私聊会话模块.md](./12-私聊会话模块.md) | ✅ 已完成 | -| 13 | 文件上传模块 | 2 | [13-文件上传模块.md](./13-文件上传模块.md) | ✅ 已完成 | -| 14 | 在线状态模块 | 5 | [14-在线状态模块.md](./14-在线状态模块.md) | ✅ 已完成 | -| 15 | 离线消息模块 | 3 | [15-离线消息模块.md](./15-离线消息模块.md) | ✅ 已完成 | -| 16 | 观看历史模块 | 1 | [16-观看历史模块.md](./16-观看历史模块.md) | ✅ 已完成 | -| 17 | 礼物打赏模块 | 5 | [17-礼物打赏模块.md](./17-礼物打赏模块.md) | ✅ 已完成 | -| 18 | 通话功能模块 | 10 | [18-通话功能模块.md](./18-通话功能模块.md) | ✅ 已完成 | - -**总计**: 109个接口 - ---- - -## 快速导航 - -### 基础功能 -- [用户系统模块](./01-用户系统模块.md) - 登录、注册、用户信息管理 -- [分类管理模块](./10-分类管理模块.md) - 直播间和作品分类 - -### 直播功能 -- [直播间管理模块](./02-直播间管理模块.md) - 直播间创建、控制、查询 -- [直播间弹幕模块](./03-直播间弹幕模块.md) - 弹幕发送和历史记录 -- [WebSocket通信模块](./04-WebSocket通信模块.md) - 实时弹幕和在线人数 - -### 社交功能 -- [好友管理模块](./05-好友管理模块.md) - 好友添加、删除、拉黑 -- [关注功能模块](./06-关注功能模块.md) - 用户关注和粉丝管理 -- [私聊会话模块](./12-私聊会话模块.md) - 一对一聊天、消息发送 -- [消息表情回应模块](./11-消息表情回应模块.md) - 消息表情回应 -- [通话功能模块](./18-通话功能模块.md) - 语音/视频通话 - -### 内容功能 -- [作品管理模块](./07-作品管理模块.md) - 作品发布、编辑、点赞、收藏 -- [搜索功能模块](./08-搜索功能模块.md) - 用户、直播间、作品搜索 -- [文件上传模块](./13-文件上传模块.md) - 图片和视频上传 - -### 支付功能 -- [支付集成模块](./09-支付集成模块.md) - 金币充值和支付 -- [礼物打赏模块](./17-礼物打赏模块.md) - 礼物赠送和余额管理 - -### 状态管理 -- [在线状态模块](./14-在线状态模块.md) - 用户在线状态查询 -- [离线消息模块](./15-离线消息模块.md) - 离线消息管理 -- [观看历史模块](./16-观看历史模块.md) - 观看历史记录 - ---- - -## 接口规范 - -### 通用请求头 - -需要登录的接口需要携带以下请求头: -``` -Authorization: Bearer {token} -``` - -### 通用响应格式 - -所有接口返回统一的响应格式: -```json -{ - "code": 200, - "msg": "success", - "data": {} -} -``` - -**code说明**: -- 200: 成功 -- 401: 未登录 -- 403: 无权限 -- 404: 资源不存在 -- 500: 服务器错误 - -### 分页参数 - -支持分页的接口使用以下参数: -``` -page 或 pageNum: 页码 (默认1) -pageSize: 每页数量 (默认20) -``` - -分页响应格式: -```json -{ - "code": 200, - "msg": "success", - "data": { - "list": [], - "total": 总数, - "page": 当前页, - "pageSize": 每页数量 - } -} -``` - ---- - -## 更新日志 - -### 2024-12-30 -- 补充7个新模块文档 -- 新增私聊会话、文件上传、在线状态、离线消息、观看历史、礼物打赏、通话功能模块 -- 更新模块总数为18个,接口总数为109个 -- 完善快速导航分类 - -### 2024-12-30 -- 创建模块化接口文档 -- 整理11个功能模块,共76个接口 -- 删除旧的对接文档,统一使用模块文档 - ---- - -## 联系方式 - -如有问题,请在项目Issue中提出。 diff --git a/模块文档/缘池与许愿树管理端设计文档.md b/模块文档/缘池与许愿树管理端设计文档.md deleted file mode 100644 index ceab2ceb..00000000 --- a/模块文档/缘池与许愿树管理端设计文档.md +++ /dev/null @@ -1,1763 +0,0 @@ -# 缘池与许愿树管理端设计文档 - -> 版本:V2.0 -> 更新日期:2025-12-30 -> 设计范围:缘池社区 + 许愿树管理 -> 核心特性:**服务端实时存储,数据云端同步** - ---- - -## 一、设计概述 - -### 1.1 核心改动 - -将原本地存储改为服务端实时存储: -- ❌ 原方案:SharedPreferences本地存储,数据仅存在单设备 -- ✅ 新方案:服务端API实时存储,数据云端同步,多端共享 - -### 1.2 数据流架构 - -``` -┌─────────────┐ API请求 ┌─────────────┐ 数据库 ┌─────────────┐ -│ 移动端APP │ ◄──────────────► │ 后端服务 │ ◄──────────────► │ MySQL │ -└─────────────┘ └─────────────┘ └─────────────┘ - │ │ - │ │ - ▼ ▼ - 实时获取数据 管理端审核 - 发布/删除心愿 数据统计 - 点赞/评论 内容管理 -``` - -### 1.3 功能对照 - -| 功能 | 原方案(本地) | 新方案(服务端) | -|------|---------------|-----------------| -| 心愿存储 | SharedPreferences | MySQL + API | -| 数据同步 | 无 | 实时同步 | -| 多端访问 | 不支持 | 支持 | -| 内容审核 | 无 | 自动+人工审核 | -| 数据统计 | 无 | 管理端统计 | -| 用户互动 | 无 | 点赞/评论 | - ---- - -## 二、移动端API设计(前台接口) - -### 2.1 缘池移动端API - -``` -基础路径: /api/front/community - -板块相关: -GET /categories # 获取板块列表(启用状态) - -消息相关: -GET /messages # 获取消息列表 - ?categoryId={id}&page=1&limit=20 -POST /messages # 发布消息(自动审核) -GET /messages/{id} # 获取消息详情 -DELETE /messages/{id} # 删除我的消息 - -用户匹配: -GET /nearby-users # 获取附近用户(轨道展示) - ?latitude={lat}&longitude={lng}&radius=5000&limit=6 -``` - -### 2.2 许愿树移动端API - -``` -基础路径: /api/front/wishtree - -节日相关: -GET /festivals # 获取节日列表(启用状态) -GET /festivals/current # 获取当前进行中的节日 - -心愿相关: -GET /wishes # 获取心愿列表 - ?festivalId={id}&page=1&limit=20 -GET /wishes/my # 获取我的心愿列表 -POST /wishes # 发布心愿(自动审核) -GET /wishes/{id} # 获取心愿详情 -DELETE /wishes/{id} # 删除我的心愿 - -互动相关: -POST /wishes/{id}/like # 点赞心愿 -DELETE /wishes/{id}/like # 取消点赞 -GET /wishes/{id}/comments # 获取评论列表 -POST /wishes/{id}/comments # 发表评论 - -素材相关: -GET /backgrounds # 获取背景素材列表 -``` - -### 2.3 移动端请求/响应示例 - -#### 发布心愿 - -```json -// POST /api/front/wishtree/wishes -// Request: -{ - "festivalId": 1, - "content": "新年快乐,万事如意!", - "backgroundId": 1 -} - -// Response: -{ - "code": 200, - "message": "发布成功", - "data": { - "id": 10001, - "uid": 1001, - "festivalId": 1, - "content": "新年快乐,万事如意!", - "backgroundId": 1, - "status": 1, - "auditRemark": "自动审核通过", - "likeCount": 0, - "createTime": "2025-12-30 12:00:00" - } -} -``` - -#### 获取我的心愿列表 - -```json -// GET /api/front/wishtree/wishes/my?page=1&limit=10 -// Response: -{ - "code": 200, - "data": { - "list": [ - { - "id": 10001, - "content": "新年快乐,万事如意!", - "festivalName": "元旦", - "festivalIcon": "🎉", - "backgroundImage": "https://xxx/bg1.jpg", - "status": 1, - "likeCount": 128, - "commentCount": 32, - "createTime": "2025-12-30 12:00:00" - } - ], - "total": 5, - "page": 1, - "limit": 10 - } -} -``` - ---- - -## 三、管理端前端设计 - -### 3.1 路由配置 - -文件:`Zhibo/admin/src/router/modules/communityManage.js` - -```javascript -import Layout from '@/layout'; - -const communityManageRouter = { - path: '/community', - component: Layout, - redirect: '/community/category', - name: 'Community', - alwaysShow: true, - meta: { - title: '缘池管理', - icon: 'el-icon-s-opportunity', - }, - children: [ - { - path: 'category', - component: () => import('@/views/community/category/index'), - name: 'CommunityCategory', - meta: { title: '板块管理' }, - }, - { - path: 'message', - component: () => import('@/views/community/message/index'), - name: 'CommunityMessage', - meta: { title: '消息管理' }, - }, - { - path: 'match-config', - component: () => import('@/views/community/matchConfig/index'), - name: 'MatchConfig', - meta: { title: '匹配配置' }, - }, - ], -}; - -export default communityManageRouter; -``` - -文件:`Zhibo/admin/src/router/modules/wishtreeManage.js` - -```javascript -import Layout from '@/layout'; - -const wishtreeManageRouter = { - path: '/wishtree', - component: Layout, - redirect: '/wishtree/festival', - name: 'Wishtree', - alwaysShow: true, - meta: { - title: '许愿树管理', - icon: 'el-icon-present', - }, - children: [ - { - path: 'festival', - component: () => import('@/views/wishtree/festival/index'), - name: 'WishtreeFestival', - meta: { title: '节日管理' }, - }, - { - path: 'wish', - component: () => import('@/views/wishtree/wish/index'), - name: 'WishtreeWish', - meta: { title: '心愿管理' }, - }, - { - path: 'background', - component: () => import('@/views/wishtree/background/index'), - name: 'WishtreeBackground', - meta: { title: '背景素材' }, - }, - { - path: 'statistics', - component: () => import('@/views/wishtree/statistics/index'), - name: 'WishtreeStatistics', - meta: { title: '数据统计' }, - }, - ], -}; - -export default wishtreeManageRouter; -``` - -### 3.2 API接口 - -文件:`Zhibo/admin/src/api/community.js` - -```javascript -import request from '@/utils/request'; - -// ==================== 板块管理 ==================== -export function categoryList() { - return request({ url: '/admin/community/category/list', method: 'get' }); -} - -export function categorySave(data) { - return request({ url: '/admin/community/category/save', method: 'post', data }); -} - -export function categoryDelete(id) { - return request({ url: `/admin/community/category/delete/${id}`, method: 'delete' }); -} - -export function categoryStatus(data) { - return request({ url: '/admin/community/category/status', method: 'post', data }); -} - -// ==================== 消息管理 ==================== -export function messageList(data) { - return request({ url: '/admin/community/message/list', method: 'post', data }); -} - -export function messageAudit(data) { - return request({ url: '/admin/community/message/audit', method: 'post', data }); -} - -export function messageDelete(id) { - return request({ url: `/admin/community/message/delete/${id}`, method: 'delete' }); -} - -// ==================== 匹配配置 ==================== -export function getMatchConfig() { - return request({ url: '/admin/community/match/config', method: 'get' }); -} - -export function saveMatchConfig(data) { - return request({ url: '/admin/community/match/config/save', method: 'post', data }); -} -``` - -文件:`Zhibo/admin/src/api/wishtree.js` - -```javascript -import request from '@/utils/request'; - -// ==================== 节日管理 ==================== -export function festivalList(params) { - return request({ url: '/admin/wishtree/festival/list', method: 'get', params }); -} - -export function festivalSave(data) { - return request({ url: '/admin/wishtree/festival/save', method: 'post', data }); -} - -export function festivalDelete(id) { - return request({ url: `/admin/wishtree/festival/delete/${id}`, method: 'delete' }); -} - -export function festivalStatus(data) { - return request({ url: '/admin/wishtree/festival/status', method: 'post', data }); -} - -// ==================== 心愿管理 ==================== -export function wishList(data) { - return request({ url: '/admin/wishtree/wish/list', method: 'post', data }); -} - -export function wishAudit(data) { - return request({ url: '/admin/wishtree/wish/audit', method: 'post', data }); -} - -export function wishDelete(id) { - return request({ url: `/admin/wishtree/wish/delete/${id}`, method: 'delete' }); -} - -// ==================== 背景素材 ==================== -export function backgroundList(params) { - return request({ url: '/admin/wishtree/background/list', method: 'get', params }); -} - -export function backgroundSave(data) { - return request({ url: '/admin/wishtree/background/save', method: 'post', data }); -} - -export function backgroundDelete(id) { - return request({ url: `/admin/wishtree/background/delete/${id}`, method: 'delete' }); -} - -// ==================== 数据统计 ==================== -export function getStatistics(params) { - return request({ url: '/admin/wishtree/statistics', method: 'get', params }); -} - -export function getWishTrend(params) { - return request({ url: '/admin/wishtree/statistics/trend', method: 'get', params }); -} -``` - -### 3.3 页面设计 - -#### 3.3.1 缘池 - 板块管理 - -``` -┌─────────────────────────────────────────────────────────────────┐ -│ [+ 新增板块] │ -├─────────────────────────────────────────────────────────────────┤ -│ 图标 │ 名称 │ 类型 │ 跳转页面 │ 排序 │ 状态 │ 操作 │ -├──────┼────────────┼────────┼──────────────┼──────┼──────┼──────┤ -│ 🎤 │ 语音匹配 │ 快捷 │ VoiceMatch │ 100 │ ●启用│ 编辑 │ -│ 💕 │ 心动信号 │ 快捷 │ Heartbeat │ 99 │ ●启用│ 编辑 │ -│ 💑 │ 在线处对象 │ 功能卡 │ OnlineDating │ 90 │ ●启用│ 编辑 │ -│ 🎮 │ 找人玩游戏 │ 功能卡 │ FindGame │ 89 │ ●启用│ 编辑 │ -│ 🎵 │ 一起KTV │ 功能卡 │ KTVTogether │ 88 │ ●启用│ 编辑 │ -└─────────────────────────────────────────────────────────────────┘ -``` - -#### 3.3.2 缘池 - 消息管理 - -``` -┌─────────────────────────────────────────────────────────────────────┐ -│ 板块[全部▼] 状态[全部▼] 时间[起始-结束] [搜索] │ -├─────────────────────────────────────────────────────────────────────┤ -│ 用户 │ 板块 │ 内容 │ 状态 │ 审核 │ 时间 │ 操作 │ -├──────────┼──────────┼──────────────┼────────┼────────┼───────┼──────┤ -│ 👤张三 │ 找人玩游戏│ 有人一起.. │ 已通过 │ 自动 │ 12:30 │ 删除 │ -│ 👤李四 │ 在线处对象│ 真诚交友.. │ 待审核 │ - │ 11:20 │ ✓ ✗ │ -│ 👤王五 │ 一起KTV │ 周末约歌.. │ 已拒绝 │ 自动 │ 10:15 │ 删除 │ -└─────────────────────────────────────────────────────────────────────┘ -``` - -#### 3.3.3 缘池 - 匹配配置 - -``` -┌─────────────────────────────────────────────────────────────────┐ -│ 用户匹配配置 │ -├─────────────────────────────────────────────────────────────────┤ -│ │ -│ 匹配半径(公里) [____5____] │ -│ │ -│ 每次推荐用户数 [____6____] │ -│ │ -│ 优先显示在线用户 [========●] │ -│ │ -│ 优先显示同城用户 [========●] │ -│ │ -│ 优先显示异性用户 [========●] │ -│ │ -│ 自动审核开关 [========●] │ -│ │ -│ [保存配置] │ -└─────────────────────────────────────────────────────────────────┘ -``` - -#### 3.3.4 许愿树 - 节日管理 - -``` -┌─────────────────────────────────────────────────────────────────────┐ -│ [+ 新增节日] │ -├─────────────────────────────────────────────────────────────────────┤ -│ 图标 │ 节日名称 │ 开始日期 │ 结束日期 │ 主题色 │ 状态 │ 操作 │ -├──────┼──────────┼────────────┼────────────┼─────────┼──────┼───────┤ -│ 🎉 │ 元旦 │ 12-31 │ 01-03 │ #FF6B6B │ ●启用│ 编辑 │ -│ 🧧 │ 春节 │ 农历除夕 │ 正月十五 │ #E74C3C │ ●启用│ 编辑 │ -│ 💕 │ 情人节 │ 02-13 │ 02-15 │ #FF69B4 │ ●启用│ 编辑 │ -│ 🎂 │ 生日祝福 │ 全年 │ 全年 │ #FFB6C1 │ ●启用│ 编辑 │ -│ ✨ │ 日常祝福 │ 全年 │ 全年 │ #9B59B6 │ ●启用│ 编辑 │ -└─────────────────────────────────────────────────────────────────────┘ -``` - -#### 3.3.5 许愿树 - 心愿管理 - -``` -┌─────────────────────────────────────────────────────────────────────┐ -│ 节日[全部▼] 状态[全部▼] 时间[起始-结束] [搜索] │ -├─────────────────────────────────────────────────────────────────────┤ -│ 用户 │ 节日 │ 心愿内容 │ 状态 │ 审核 │ 时间 │ 操作 │ -├──────────┼────────┼────────────────┼────────┼────────┼───────┼──────┤ -│ 👤张三 │ 元旦 │ 新年快乐.. │ 已通过 │ 自动 │ 12:30 │ 删除 │ -│ 👤李四 │ 生日 │ 祝自己生日.. │ 待审核 │ - │ 11:20 │ ✓ ✗ │ -│ 👤王五 │ 日常 │ 希望一切.. │ 已通过 │ 自动 │ 10:15 │ 删除 │ -└─────────────────────────────────────────────────────────────────────┘ -``` - -#### 3.3.6 许愿树 - 背景素材 - -``` -┌─────────────────────────────────────────────────────────────────────┐ -│ [+ 上传背景] 类型[全部▼] │ -├─────────────────────────────────────────────────────────────────────┤ -│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ -│ │ 🎄 │ │ 🧧 │ │ 💕 │ │ 🎂 │ │ ✨ │ │ -│ │ 元旦 │ │ 春节 │ │ 情人节 │ │ 生日 │ │ 日常 │ │ -│ │ [删除] │ │ [删除] │ │ [删除] │ │ [删除] │ │ [删除] │ │ -│ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │ -│ │ -│ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ -│ │ 🌸 │ │ 🎈 │ │ 🌙 │ │ -│ │ 妇女节 │ │ 儿童节 │ │ 七夕 │ │ -│ │ [删除] │ │ [删除] │ │ [删除] │ │ -│ └─────────┘ └─────────┘ └─────────┘ │ -└─────────────────────────────────────────────────────────────────────┘ -``` - -#### 3.3.7 许愿树 - 数据统计 - -``` -┌─────────────────────────────────────────────────────────────────────┐ -│ 数据统计 时间范围[近7天▼] │ -├─────────────────────────────────────────────────────────────────────┤ -│ │ -│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌────────────┐ │ -│ │ 总心愿数 │ │ 今日新增 │ │ 待审核 │ │ 总点赞数 │ │ -│ │ 12,580 │ │ 156 │ │ 23 │ │ 89,320 │ │ -│ └──────────────┘ └──────────────┘ └──────────────┘ └────────────┘ │ -│ │ -│ ┌─────────────────────────────────────────────────────────────┐ │ -│ │ 心愿发布趋势 │ │ -│ │ 📈 折线图 │ │ -│ │ │ │ -│ └─────────────────────────────────────────────────────────────┘ │ -│ │ -│ ┌──────────────────────────┐ ┌────────────────────────────────┐ │ -│ │ 节日分布(饼图) │ │ 热门心愿TOP10 │ │ -│ │ 🎉元旦 35% │ │ 1. 新年快乐... ❤️128 │ │ -│ │ 🧧春节 28% │ │ 2. 万事如意... ❤️96 │ │ -│ │ 💕情人节 15% │ │ 3. 心想事成... ❤️85 │ │ -│ │ ✨日常 22% │ │ ... │ │ -│ └──────────────────────────┘ └────────────────────────────────┘ │ -└─────────────────────────────────────────────────────────────────────┘ -``` - ---- - -## 四、后端设计 - -### 4.1 移动端Controller(前台接口) - -#### CommunityFrontController.java - -```java -@RestController -@RequestMapping("/api/front/community") -@Api(tags = "缘池-移动端") -public class CommunityFrontController { - - @Autowired - private CommunityService communityService; - - @ApiOperation("获取板块列表") - @GetMapping("/categories") - public CommonResult> getCategories() { - return CommonResult.success(communityService.getEnabledCategories()); - } - - @ApiOperation("获取消息列表") - @GetMapping("/messages") - public CommonResult> getMessages( - @RequestParam(required = false) Integer categoryId, - @RequestParam(defaultValue = "1") Integer page, - @RequestParam(defaultValue = "20") Integer limit) { - return CommonResult.success(communityService.getFrontMessageList(categoryId, page, limit)); - } - - @ApiOperation("发布消息") - @PostMapping("/messages") - public CommonResult publishMessage(@RequestBody CommunityMessageRequest request) { - return CommonResult.success(communityService.publishMessage(request)); - } - - @ApiOperation("删除我的消息") - @DeleteMapping("/messages/{id}") - public CommonResult deleteMyMessage(@PathVariable Long id) { - communityService.deleteMyMessage(id); - return CommonResult.success("删除成功"); - } - - @ApiOperation("获取附近用户") - @GetMapping("/nearby-users") - public CommonResult> getNearbyUsers( - @RequestParam Double latitude, - @RequestParam Double longitude, - @RequestParam(defaultValue = "5000") Integer radius, - @RequestParam(defaultValue = "6") Integer limit) { - return CommonResult.success(communityService.getNearbyUsers(latitude, longitude, radius, limit)); - } -} -``` - -#### WishtreeFrontController.java - -```java -@RestController -@RequestMapping("/api/front/wishtree") -@Api(tags = "许愿树-移动端") -public class WishtreeFrontController { - - @Autowired - private WishtreeService wishtreeService; - - // ==================== 节日相关 ==================== - @ApiOperation("获取节日列表") - @GetMapping("/festivals") - public CommonResult> getFestivals() { - return CommonResult.success(wishtreeService.getEnabledFestivals()); - } - - @ApiOperation("获取当前进行中的节日") - @GetMapping("/festivals/current") - public CommonResult getCurrentFestival() { - return CommonResult.success(wishtreeService.getCurrentFestival()); - } - - // ==================== 心愿相关 ==================== - @ApiOperation("获取心愿列表") - @GetMapping("/wishes") - public CommonResult> getWishes( - @RequestParam(required = false) Integer festivalId, - @RequestParam(defaultValue = "1") Integer page, - @RequestParam(defaultValue = "20") Integer limit) { - return CommonResult.success(wishtreeService.getFrontWishList(festivalId, page, limit)); - } - - @ApiOperation("获取我的心愿列表") - @GetMapping("/wishes/my") - public CommonResult> getMyWishes( - @RequestParam(defaultValue = "1") Integer page, - @RequestParam(defaultValue = "10") Integer limit) { - return CommonResult.success(wishtreeService.getMyWishList(page, limit)); - } - - @ApiOperation("发布心愿") - @PostMapping("/wishes") - public CommonResult publishWish(@RequestBody WishtreeWishRequest request) { - return CommonResult.success(wishtreeService.publishWish(request)); - } - - @ApiOperation("获取心愿详情") - @GetMapping("/wishes/{id}") - public CommonResult getWishDetail(@PathVariable Long id) { - return CommonResult.success(wishtreeService.getWishDetail(id)); - } - - @ApiOperation("删除我的心愿") - @DeleteMapping("/wishes/{id}") - public CommonResult deleteMyWish(@PathVariable Long id) { - wishtreeService.deleteMyWish(id); - return CommonResult.success("删除成功"); - } - - // ==================== 互动相关 ==================== - @ApiOperation("点赞心愿") - @PostMapping("/wishes/{id}/like") - public CommonResult likeWish(@PathVariable Long id) { - wishtreeService.likeWish(id); - return CommonResult.success("点赞成功"); - } - - @ApiOperation("取消点赞") - @DeleteMapping("/wishes/{id}/like") - public CommonResult unlikeWish(@PathVariable Long id) { - wishtreeService.unlikeWish(id); - return CommonResult.success("取消成功"); - } - - @ApiOperation("获取评论列表") - @GetMapping("/wishes/{id}/comments") - public CommonResult> getComments( - @PathVariable Long id, - @RequestParam(defaultValue = "1") Integer page, - @RequestParam(defaultValue = "20") Integer limit) { - return CommonResult.success(wishtreeService.getCommentList(id, page, limit)); - } - - @ApiOperation("发表评论") - @PostMapping("/wishes/{id}/comments") - public CommonResult addComment( - @PathVariable Long id, - @RequestBody WishtreeCommentRequest request) { - return CommonResult.success(wishtreeService.addComment(id, request)); - } - - // ==================== 素材相关 ==================== - @ApiOperation("获取背景素材列表") - @GetMapping("/backgrounds") - public CommonResult> getBackgrounds() { - return CommonResult.success(wishtreeService.getEnabledBackgrounds()); - } -} -``` - -### 4.2 管理端Controller(后台接口) - -#### CommunityAdminController.java - -文件:`crmeb-admin/src/main/java/com/zbkj/admin/controller/CommunityAdminController.java` - -```java -package com.zbkj.admin.controller; - -import com.github.pagehelper.PageInfo; -import com.zbkj.common.model.community.*; -import com.zbkj.common.request.*; -import com.zbkj.common.response.*; -import com.zbkj.common.result.CommonResult; -import com.zbkj.service.service.CommunityService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; -import java.util.List; - -@RestController -@RequestMapping("/admin/community") -@Api(tags = "缘池管理") -public class CommunityAdminController { - - @Autowired - private CommunityService communityService; - - // ==================== 板块管理 ==================== - @ApiOperation("板块列表") - @GetMapping("/category/list") - public CommonResult> categoryList() { - return CommonResult.success(communityService.getCategoryList()); - } - - @ApiOperation("保存板块") - @PostMapping("/category/save") - public CommonResult categorySave(@RequestBody CommunityCategory category) { - communityService.saveCategory(category); - return CommonResult.success("保存成功"); - } - - @ApiOperation("删除板块") - @DeleteMapping("/category/delete/{id}") - public CommonResult categoryDelete(@PathVariable Integer id) { - communityService.deleteCategory(id); - return CommonResult.success("删除成功"); - } - - @ApiOperation("更新板块状态") - @PostMapping("/category/status") - public CommonResult categoryStatus(@RequestBody CommunityCategory category) { - communityService.updateCategoryStatus(category.getId(), category.getStatus()); - return CommonResult.success("更新成功"); - } - - // ==================== 消息管理 ==================== - @ApiOperation("消息列表") - @PostMapping("/message/list") - public CommonResult> messageList( - @RequestBody CommunityMessageRequest request) { - return CommonResult.success(communityService.getMessageList(request)); - } - - @ApiOperation("审核消息") - @PostMapping("/message/audit") - public CommonResult messageAudit(@RequestBody AuditRequest request) { - communityService.auditMessage(request.getId(), request.getStatus(), request.getRemark()); - return CommonResult.success("审核成功"); - } - - @ApiOperation("删除消息") - @DeleteMapping("/message/delete/{id}") - public CommonResult messageDelete(@PathVariable Long id) { - communityService.deleteMessage(id); - return CommonResult.success("删除成功"); - } - - // ==================== 匹配配置 ==================== - @ApiOperation("获取匹配配置") - @GetMapping("/match/config") - public CommonResult getMatchConfig() { - return CommonResult.success(communityService.getMatchConfig()); - } - - @ApiOperation("保存匹配配置") - @PostMapping("/match/config/save") - public CommonResult saveMatchConfig(@RequestBody CommunityMatchConfig config) { - communityService.saveMatchConfig(config); - return CommonResult.success("保存成功"); - } -} -``` - -#### WishtreeAdminController.java - -文件:`crmeb-admin/src/main/java/com/zbkj/admin/controller/WishtreeAdminController.java` - -```java -package com.zbkj.admin.controller; - -import com.github.pagehelper.PageInfo; -import com.zbkj.common.model.wishtree.*; -import com.zbkj.common.request.*; -import com.zbkj.common.response.*; -import com.zbkj.common.result.CommonResult; -import com.zbkj.service.service.WishtreeService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; -import java.util.List; - -@RestController -@RequestMapping("/admin/wishtree") -@Api(tags = "许愿树管理") -public class WishtreeAdminController { - - @Autowired - private WishtreeService wishtreeService; - - // ==================== 节日管理 ==================== - @ApiOperation("节日列表") - @GetMapping("/festival/list") - public CommonResult> festivalList() { - return CommonResult.success(wishtreeService.getFestivalList()); - } - - @ApiOperation("保存节日") - @PostMapping("/festival/save") - public CommonResult festivalSave(@RequestBody WishtreeFestival festival) { - wishtreeService.saveFestival(festival); - return CommonResult.success("保存成功"); - } - - @ApiOperation("删除节日") - @DeleteMapping("/festival/delete/{id}") - public CommonResult festivalDelete(@PathVariable Integer id) { - wishtreeService.deleteFestival(id); - return CommonResult.success("删除成功"); - } - - @ApiOperation("更新节日状态") - @PostMapping("/festival/status") - public CommonResult festivalStatus(@RequestBody WishtreeFestival festival) { - wishtreeService.updateFestivalStatus(festival.getId(), festival.getStatus()); - return CommonResult.success("更新成功"); - } - - // ==================== 心愿管理 ==================== - @ApiOperation("心愿列表") - @PostMapping("/wish/list") - public CommonResult> wishList(@RequestBody WishtreeWishRequest request) { - return CommonResult.success(wishtreeService.getWishList(request)); - } - - @ApiOperation("审核心愿") - @PostMapping("/wish/audit") - public CommonResult wishAudit(@RequestBody AuditRequest request) { - wishtreeService.auditWish(request.getId(), request.getStatus(), request.getRemark()); - return CommonResult.success("审核成功"); - } - - @ApiOperation("删除心愿") - @DeleteMapping("/wish/delete/{id}") - public CommonResult wishDelete(@PathVariable Long id) { - wishtreeService.deleteWish(id); - return CommonResult.success("删除成功"); - } - - // ==================== 背景素材 ==================== - @ApiOperation("背景列表") - @GetMapping("/background/list") - public CommonResult> backgroundList() { - return CommonResult.success(wishtreeService.getBackgroundList()); - } - - @ApiOperation("保存背景") - @PostMapping("/background/save") - public CommonResult backgroundSave(@RequestBody WishtreeBackground background) { - wishtreeService.saveBackground(background); - return CommonResult.success("保存成功"); - } - - @ApiOperation("删除背景") - @DeleteMapping("/background/delete/{id}") - public CommonResult backgroundDelete(@PathVariable Integer id) { - wishtreeService.deleteBackground(id); - return CommonResult.success("删除成功"); - } -} -``` - -### 4.3 Service核心方法 - -#### CommunityService.java(核心方法) - -```java -@Service -public class CommunityService { - - @Autowired - private CommunityCategoryDao categoryDao; - @Autowired - private CommunityMessageDao messageDao; - @Autowired - private CommunityMatchConfigDao matchConfigDao; - @Autowired - private SensitiveWordService sensitiveWordService; - - // 板块管理 - public List getCategoryList() { - return categoryDao.selectList(new QueryWrapper() - .orderByDesc("sort")); - } - - public void saveCategory(CommunityCategory category) { - if (category.getId() != null) { - categoryDao.updateById(category); - } else { - categoryDao.insert(category); - } - } - - // 消息管理 - public PageInfo getMessageList(CommunityMessageRequest request) { - PageHelper.startPage(request.getPage(), request.getLimit()); - List list = messageDao.selectMessageList(request); - return new PageInfo<>(list); - } - - // 自动审核 - public void autoAuditMessage(CommunityMessage message) { - CommunityMatchConfig config = getMatchConfig(); - if (config.getAutoAudit() != 1) { - message.setStatus(0); - return; - } - - List words = sensitiveWordService.findAll(message.getContent()); - if (words.isEmpty()) { - message.setStatus(1); - message.setAuditRemark("自动审核通过"); - } else { - message.setStatus(0); - message.setAuditRemark("含敏感词:" + String.join(",", words)); - } - message.setAuditType(0); - } - - // 匹配配置 - public CommunityMatchConfig getMatchConfig() { - return matchConfigDao.selectById(1); - } - - public void saveMatchConfig(CommunityMatchConfig config) { - config.setId(1); - matchConfigDao.updateById(config); - } -} -``` - -#### WishtreeService.java(核心方法) - -```java -@Service -public class WishtreeService { - - @Autowired - private WishtreeFestivalDao festivalDao; - @Autowired - private WishtreeWishDao wishDao; - @Autowired - private WishtreeBackgroundDao backgroundDao; - @Autowired - private WishtreeLikeDao likeDao; - @Autowired - private WishtreeCommentDao commentDao; - @Autowired - private SensitiveWordService sensitiveWordService; - - // ==================== 移动端方法 ==================== - - // 获取启用的节日列表 - public List getEnabledFestivals() { - return festivalDao.selectList(new QueryWrapper() - .eq("status", 1) - .orderByDesc("sort")); - } - - // 获取当前进行中的节日 - public WishtreeFestival getCurrentFestival() { - // 根据当前日期匹配节日 - return festivalDao.selectCurrentFestival(); - } - - // 获取心愿列表(移动端) - public PageInfo getFrontWishList(Integer festivalId, Integer page, Integer limit) { - PageHelper.startPage(page, limit); - List list = wishDao.selectFrontWishList(festivalId); - return new PageInfo<>(list); - } - - // 获取我的心愿列表 - public PageInfo getMyWishList(Integer page, Integer limit) { - Integer uid = SecurityUtil.getLoginUserVo().getUser().getId(); - PageHelper.startPage(page, limit); - List list = wishDao.selectMyWishList(uid); - return new PageInfo<>(list); - } - - // 发布心愿(自动审核) - @Transactional - public WishtreeWish publishWish(WishtreeWishRequest request) { - Integer uid = SecurityUtil.getLoginUserVo().getUser().getId(); - - WishtreeWish wish = new WishtreeWish(); - wish.setUid(uid); - wish.setFestivalId(request.getFestivalId()); - wish.setContent(request.getContent()); - wish.setBackgroundId(request.getBackgroundId()); - wish.setLikeCount(0); - wish.setCommentCount(0); - wish.setIsDelete(0); - - // 自动审核 - autoAuditWish(wish); - - wishDao.insert(wish); - return wish; - } - - // 删除我的心愿 - public void deleteMyWish(Long id) { - Integer uid = SecurityUtil.getLoginUserVo().getUser().getId(); - WishtreeWish wish = wishDao.selectById(id); - if (wish != null && wish.getUid().equals(uid)) { - wish.setIsDelete(1); - wishDao.updateById(wish); - } - } - - // 点赞心愿 - @Transactional - public void likeWish(Long wishId) { - Integer uid = SecurityUtil.getLoginUserVo().getUser().getId(); - - // 检查是否已点赞 - WishtreeLike existing = likeDao.selectOne(new QueryWrapper() - .eq("uid", uid).eq("wish_id", wishId)); - if (existing != null) return; - - // 添加点赞记录 - WishtreeLike like = new WishtreeLike(); - like.setUid(uid); - like.setWishId(wishId); - likeDao.insert(like); - - // 更新点赞数 - wishDao.incrementLikeCount(wishId); - } - - // 取消点赞 - @Transactional - public void unlikeWish(Long wishId) { - Integer uid = SecurityUtil.getLoginUserVo().getUser().getId(); - likeDao.delete(new QueryWrapper() - .eq("uid", uid).eq("wish_id", wishId)); - wishDao.decrementLikeCount(wishId); - } - - // 发表评论 - @Transactional - public WishtreeComment addComment(Long wishId, WishtreeCommentRequest request) { - Integer uid = SecurityUtil.getLoginUserVo().getUser().getId(); - - WishtreeComment comment = new WishtreeComment(); - comment.setWishId(wishId); - comment.setUid(uid); - comment.setContent(request.getContent()); - comment.setStatus(1); // 自动通过或待审核 - - // 自动审核评论 - List words = sensitiveWordService.findAll(request.getContent()); - if (!words.isEmpty()) { - comment.setStatus(0); // 待审核 - } - - commentDao.insert(comment); - - // 更新评论数 - if (comment.getStatus() == 1) { - wishDao.incrementCommentCount(wishId); - } - - return comment; - } - - // ==================== 管理端方法 ==================== - - // 节日管理 - public List getFestivalList() { - return festivalDao.selectList(new QueryWrapper() - .orderByDesc("sort")); - } - - public void saveFestival(WishtreeFestival festival) { - if (festival.getId() != null) { - festivalDao.updateById(festival); - } else { - festivalDao.insert(festival); - } - } - - // 心愿管理 - public PageInfo getWishList(WishtreeWishRequest request) { - PageHelper.startPage(request.getPage(), request.getLimit()); - List list = wishDao.selectWishList(request); - return new PageInfo<>(list); - } - - // 自动审核心愿 - public void autoAuditWish(WishtreeWish wish) { - List words = sensitiveWordService.findAll(wish.getContent()); - if (words.isEmpty()) { - wish.setStatus(1); - wish.setAuditRemark("自动审核通过"); - } else { - wish.setStatus(0); - wish.setAuditRemark("含敏感词:" + String.join(",", words)); - } - wish.setAuditType(0); - } - - // 数据统计 - public WishtreeStatisticsVO getStatistics() { - WishtreeStatisticsVO vo = new WishtreeStatisticsVO(); - vo.setTotalWishes(wishDao.countTotal()); - vo.setTodayWishes(wishDao.countToday()); - vo.setPendingWishes(wishDao.countPending()); - vo.setTotalLikes(wishDao.sumLikes()); - return vo; - } - - // 背景素材 - public List getBackgroundList() { - return backgroundDao.selectList(new QueryWrapper() - .orderByDesc("sort")); - } - - public List getEnabledBackgrounds() { - return backgroundDao.selectList(new QueryWrapper() - .eq("status", 1) - .orderByDesc("sort")); - } -} -``` - ---- - -## 五、数据库设计 - -### 5.1 缘池相关表 - -```sql --- ============================================ --- 缘池管理数据库表 --- ============================================ - --- 1. 板块表 -CREATE TABLE `eb_community_category` ( - `id` int NOT NULL AUTO_INCREMENT COMMENT '板块ID', - `name` varchar(50) NOT NULL COMMENT '板块名称', - `icon` varchar(255) DEFAULT '' COMMENT '图标', - `type` varchar(20) DEFAULT 'card' COMMENT '类型 quick=快捷入口 card=功能卡片', - `jump_page` varchar(100) DEFAULT '' COMMENT '跳转页面', - `sort` int DEFAULT 0 COMMENT '排序', - `status` tinyint DEFAULT 1 COMMENT '状态 0禁用 1启用', - `create_time` datetime DEFAULT CURRENT_TIMESTAMP, - `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='缘池板块表'; - --- 2. 消息表 -CREATE TABLE `eb_community_message` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '消息ID', - `uid` int NOT NULL COMMENT '用户ID', - `category_id` int NOT NULL COMMENT '板块ID', - `content` text COMMENT '消息内容', - `images` varchar(1000) DEFAULT '' COMMENT '图片(逗号分隔)', - `status` tinyint DEFAULT 1 COMMENT '状态 0待审核 1通过 2拒绝', - `audit_type` tinyint DEFAULT 0 COMMENT '审核方式 0自动 1人工', - `audit_remark` varchar(255) DEFAULT '' COMMENT '审核备注', - `is_delete` tinyint DEFAULT 0 COMMENT '是否删除', - `create_time` datetime DEFAULT CURRENT_TIMESTAMP, - `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - KEY `idx_uid` (`uid`), - KEY `idx_category` (`category_id`), - KEY `idx_status` (`status`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='缘池消息表'; - --- 3. 匹配配置表 -CREATE TABLE `eb_community_match_config` ( - `id` int NOT NULL AUTO_INCREMENT, - `match_radius` int DEFAULT 5 COMMENT '匹配半径(公里)', - `recommend_count` int DEFAULT 6 COMMENT '推荐用户数', - `priority_online` tinyint DEFAULT 1 COMMENT '优先在线用户', - `priority_same_city` tinyint DEFAULT 1 COMMENT '优先同城用户', - `priority_opposite_sex` tinyint DEFAULT 1 COMMENT '优先异性用户', - `auto_audit` tinyint DEFAULT 1 COMMENT '自动审核开关', - `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='缘池匹配配置表'; - --- 初始化匹配配置 -INSERT INTO `eb_community_match_config` VALUES (1, 5, 6, 1, 1, 1, 1, NOW()); - --- 初始化板块数据 -INSERT INTO `eb_community_category` (`name`, `icon`, `type`, `jump_page`, `sort`) VALUES -('语音匹配', 'el-icon-microphone', 'quick', 'VoiceMatchActivity', 100), -('心动信号', 'el-icon-star-on', 'quick', 'HeartbeatSignalActivity', 99), -('在线处对象', 'el-icon-user', 'card', 'OnlineDatingActivity', 90), -('找人玩游戏', 'el-icon-video-play', 'card', 'FindGameActivity', 89), -('一起KTV', 'el-icon-headset', 'card', 'KTVTogetherActivity', 88), -('你画我猜', 'el-icon-edit', 'card', 'DrawGuessActivity', 87), -('和平精英', 'el-icon-aim', 'card', 'PeaceEliteActivity', 86), -('桌游', 'el-icon-s-grid', 'card', 'TableGamesActivity', 85); -``` - -### 5.2 许愿树相关表 - -```sql --- ============================================ --- 许愿树管理数据库表 --- ============================================ - --- 1. 节日表 -CREATE TABLE `eb_wishtree_festival` ( - `id` int NOT NULL AUTO_INCREMENT COMMENT '节日ID', - `name` varchar(50) NOT NULL COMMENT '节日名称', - `icon` varchar(255) DEFAULT '' COMMENT '节日图标', - `start_date` varchar(20) DEFAULT '' COMMENT '开始日期(MM-DD或农历)', - `end_date` varchar(20) DEFAULT '' COMMENT '结束日期', - `is_lunar` tinyint DEFAULT 0 COMMENT '是否农历 0否 1是', - `theme_color` varchar(20) DEFAULT '#FF6B6B' COMMENT '主题色', - `sort` int DEFAULT 0 COMMENT '排序', - `status` tinyint DEFAULT 1 COMMENT '状态 0禁用 1启用', - `create_time` datetime DEFAULT CURRENT_TIMESTAMP, - `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='许愿树节日表'; - --- 2. 心愿表 -CREATE TABLE `eb_wishtree_wish` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '心愿ID', - `uid` int NOT NULL COMMENT '用户ID', - `festival_id` int DEFAULT 0 COMMENT '节日ID', - `content` varchar(500) NOT NULL COMMENT '心愿内容', - `background_id` int DEFAULT 0 COMMENT '背景ID', - `status` tinyint DEFAULT 1 COMMENT '状态 0待审核 1通过 2拒绝', - `audit_type` tinyint DEFAULT 0 COMMENT '审核方式 0自动 1人工', - `audit_remark` varchar(255) DEFAULT '' COMMENT '审核备注', - `like_count` int DEFAULT 0 COMMENT '点赞数', - `comment_count` int DEFAULT 0 COMMENT '评论数', - `is_delete` tinyint DEFAULT 0 COMMENT '是否删除', - `create_time` datetime DEFAULT CURRENT_TIMESTAMP, - `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - KEY `idx_uid` (`uid`), - KEY `idx_festival` (`festival_id`), - KEY `idx_status` (`status`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='许愿树心愿表'; - --- 3. 心愿点赞表 -CREATE TABLE `eb_wishtree_like` ( - `id` bigint NOT NULL AUTO_INCREMENT, - `uid` int NOT NULL COMMENT '用户ID', - `wish_id` bigint NOT NULL COMMENT '心愿ID', - `create_time` datetime DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - UNIQUE KEY `uk_uid_wish` (`uid`, `wish_id`), - KEY `idx_wish` (`wish_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='许愿树点赞表'; - --- 4. 心愿评论表 -CREATE TABLE `eb_wishtree_comment` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '评论ID', - `wish_id` bigint NOT NULL COMMENT '心愿ID', - `uid` int NOT NULL COMMENT '用户ID', - `content` varchar(255) NOT NULL COMMENT '评论内容', - `parent_id` bigint DEFAULT 0 COMMENT '父评论ID', - `status` tinyint DEFAULT 1 COMMENT '状态 0待审核 1通过 2拒绝', - `is_delete` tinyint DEFAULT 0 COMMENT '是否删除', - `create_time` datetime DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - KEY `idx_wish` (`wish_id`), - KEY `idx_uid` (`uid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='许愿树评论表'; - --- 5. 背景素材表 -CREATE TABLE `eb_wishtree_background` ( - `id` int NOT NULL AUTO_INCREMENT COMMENT '背景ID', - `name` varchar(50) NOT NULL COMMENT '背景名称', - `image` varchar(255) NOT NULL COMMENT '背景图片', - `festival_id` int DEFAULT 0 COMMENT '关联节日ID(0=通用)', - `sort` int DEFAULT 0 COMMENT '排序', - `status` tinyint DEFAULT 1 COMMENT '状态', - `create_time` datetime DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='许愿树背景素材表'; - --- 初始化节日数据 -INSERT INTO `eb_wishtree_festival` (`name`, `icon`, `start_date`, `end_date`, `is_lunar`, `theme_color`, `sort`) VALUES -('元旦', '🎉', '12-31', '01-03', 0, '#FF6B6B', 100), -('春节', '🧧', '除夕', '正月十五', 1, '#E74C3C', 99), -('情人节', '💕', '02-13', '02-15', 0, '#FF69B4', 98), -('妇女节', '🌸', '03-07', '03-09', 0, '#FFB6C1', 97), -('清明节', '🌿', '清明', '清明后2天', 1, '#90EE90', 96), -('劳动节', '💪', '04-30', '05-03', 0, '#FFA500', 95), -('母亲节', '🌹', '5月第2周日', '5月第2周日', 0, '#FF1493', 94), -('儿童节', '🎈', '05-31', '06-02', 0, '#87CEEB', 93), -('端午节', '🐲', '五月初五', '五月初七', 1, '#228B22', 92), -('七夕', '🌙', '七月初七', '七月初七', 1, '#9370DB', 91), -('中秋节', '🥮', '八月十五', '八月十七', 1, '#FFD700', 90), -('国庆节', '🇨🇳', '09-30', '10-07', 0, '#FF0000', 89), -('圣诞节', '🎄', '12-24', '12-26', 0, '#228B22', 88), -('生日祝福', '🎂', '全年', '全年', 0, '#FF69B4', 50), -('日常祝福', '✨', '全年', '全年', 0, '#9B59B6', 49); -``` - ---- - -## 六、实体类设计 - -### 6.1 缘池实体类 - -```java -// CommunityCategory.java -@Data -@TableName("eb_community_category") -public class CommunityCategory { - @TableId(type = IdType.AUTO) - private Integer id; - private String name; - private String icon; - private String type; // quick=快捷入口 card=功能卡片 - private String jumpPage; // 跳转页面 - private Integer sort; - private Integer status; - private Date createTime; - private Date updateTime; -} - -// CommunityMessage.java -@Data -@TableName("eb_community_message") -public class CommunityMessage { - @TableId(type = IdType.AUTO) - private Long id; - private Integer uid; - private Integer categoryId; - private String content; - private String images; - private Integer status; - private Integer auditType; - private String auditRemark; - private Integer isDelete; - private Date createTime; - private Date updateTime; -} - -// CommunityMatchConfig.java -@Data -@TableName("eb_community_match_config") -public class CommunityMatchConfig { - @TableId(type = IdType.AUTO) - private Integer id; - private Integer matchRadius; // 匹配半径 - private Integer recommendCount; // 推荐用户数 - private Integer priorityOnline; // 优先在线 - private Integer prioritySameCity; // 优先同城 - private Integer priorityOppositeSex; // 优先异性 - private Integer autoAudit; // 自动审核 - private Date updateTime; -} -``` - -### 6.2 许愿树实体类 - -```java -// WishtreeFestival.java -@Data -@TableName("eb_wishtree_festival") -public class WishtreeFestival { - @TableId(type = IdType.AUTO) - private Integer id; - private String name; - private String icon; - private String startDate; - private String endDate; - private Integer isLunar; // 是否农历 - private String themeColor; - private Integer sort; - private Integer status; - private Date createTime; - private Date updateTime; -} - -// WishtreeWish.java -@Data -@TableName("eb_wishtree_wish") -public class WishtreeWish { - @TableId(type = IdType.AUTO) - private Long id; - private Integer uid; - private Integer festivalId; - private String content; - private Integer backgroundId; - private Integer status; - private Integer auditType; - private String auditRemark; - private Integer likeCount; - private Integer commentCount; - private Integer isDelete; - private Date createTime; - private Date updateTime; -} - -// WishtreeLike.java -@Data -@TableName("eb_wishtree_like") -public class WishtreeLike { - @TableId(type = IdType.AUTO) - private Long id; - private Integer uid; - private Long wishId; - private Date createTime; -} - -// WishtreeComment.java -@Data -@TableName("eb_wishtree_comment") -public class WishtreeComment { - @TableId(type = IdType.AUTO) - private Long id; - private Long wishId; - private Integer uid; - private String content; - private Long parentId; - private Integer status; - private Integer isDelete; - private Date createTime; -} - -// WishtreeBackground.java -@Data -@TableName("eb_wishtree_background") -public class WishtreeBackground { - @TableId(type = IdType.AUTO) - private Integer id; - private String name; - private String image; - private Integer festivalId; - private Integer sort; - private Integer status; - private Date createTime; -} -``` - -### 6.3 VO/Request类 - -```java -// WishtreeWishVO.java - 心愿响应VO -@Data -public class WishtreeWishVO { - private Long id; - private Integer uid; - private String nickname; - private String avatar; - private Integer festivalId; - private String festivalName; - private String festivalIcon; - private String content; - private Integer backgroundId; - private String backgroundImage; - private Integer status; - private Integer auditType; - private String auditRemark; - private Integer likeCount; - private Integer commentCount; - private Boolean isLiked; // 当前用户是否已点赞 - private Date createTime; -} - -// WishtreeWishRequest.java - 发布心愿请求 -@Data -public class WishtreeWishRequest { - private Integer festivalId; - private String content; - private Integer backgroundId; - // 管理端查询用 - private Integer page; - private Integer limit; - private Integer status; -} - -// WishtreeCommentVO.java - 评论响应VO -@Data -public class WishtreeCommentVO { - private Long id; - private Long wishId; - private Integer uid; - private String nickname; - private String avatar; - private String content; - private Long parentId; - private Integer status; - private Date createTime; -} - -// WishtreeCommentRequest.java - 发表评论请求 -@Data -public class WishtreeCommentRequest { - private String content; - private Long parentId; -} - -// WishtreeStatisticsVO.java - 统计数据VO -@Data -public class WishtreeStatisticsVO { - private Integer totalWishes; - private Integer todayWishes; - private Integer pendingWishes; - private Integer totalLikes; - private List festivalStats; - private List hotWishes; -} -``` - ---- - -## 七、文件清单 - -### 7.1 前端文件 - -``` -Zhibo/admin/src/ -├── api/ -│ ├── community.js # 缘池API -│ └── wishtree.js # 许愿树API -├── router/modules/ -│ ├── communityManage.js # 缘池路由 -│ └── wishtreeManage.js # 许愿树路由 -└── views/ - ├── community/ - │ ├── category/index.vue # 板块管理 - │ ├── message/index.vue # 消息管理 - │ └── matchConfig/index.vue # 匹配配置 - └── wishtree/ - ├── festival/index.vue # 节日管理 - ├── wish/index.vue # 心愿管理 - └── background/index.vue # 背景素材 -``` - -### 7.2 后端文件 - -``` -Zhibo/zhibo-h/ -├── crmeb-admin/src/main/java/com/zbkj/admin/controller/ -│ ├── CommunityAdminController.java # 缘池管理端 -│ └── WishtreeAdminController.java # 许愿树管理端 -├── crmeb-front/src/main/java/com/zbkj/front/controller/ -│ ├── CommunityFrontController.java # 缘池移动端API -│ └── WishtreeFrontController.java # 许愿树移动端API -├── crmeb-service/src/main/java/com/zbkj/service/ -│ ├── service/ -│ │ ├── CommunityService.java -│ │ └── WishtreeService.java -│ └── dao/ -│ ├── CommunityCategoryDao.java -│ ├── CommunityMessageDao.java -│ ├── CommunityMatchConfigDao.java -│ ├── WishtreeFestivalDao.java -│ ├── WishtreeWishDao.java -│ ├── WishtreeLikeDao.java -│ ├── WishtreeCommentDao.java -│ └── WishtreeBackgroundDao.java -└── crmeb-common/src/main/java/com/zbkj/common/ - ├── model/ - │ ├── community/ - │ │ ├── CommunityCategory.java - │ │ ├── CommunityMessage.java - │ │ └── CommunityMatchConfig.java - │ └── wishtree/ - │ ├── WishtreeFestival.java - │ ├── WishtreeWish.java - │ ├── WishtreeLike.java - │ ├── WishtreeComment.java - │ └── WishtreeBackground.java - ├── request/ - │ ├── WishtreeWishRequest.java - │ └── WishtreeCommentRequest.java - └── response/ - ├── WishtreeWishVO.java - ├── WishtreeCommentVO.java - └── WishtreeStatisticsVO.java -``` - -### 7.3 数据库表 - -``` -缘池: -├── eb_community_category # 板块表 -├── eb_community_message # 消息表 -└── eb_community_match_config # 匹配配置表 - -许愿树: -├── eb_wishtree_festival # 节日表 -├── eb_wishtree_wish # 心愿表 -├── eb_wishtree_like # 点赞表 -├── eb_wishtree_comment # 评论表 -└── eb_wishtree_background # 背景素材表 -``` - ---- - -## 八、菜单配置SQL - -```sql --- 缘池管理菜单 -INSERT INTO `eb_system_menu` (`pid`, `name`, `icon`, `perms`, `component`, `menu_type`, `sort`, `is_show`) VALUES -(0, '缘池管理', 'el-icon-s-opportunity', '', '/community', 'M', 140, 1); -SET @community_id = LAST_INSERT_ID(); - -INSERT INTO `eb_system_menu` (`pid`, `name`, `perms`, `component`, `menu_type`, `sort`, `is_show`) VALUES -(@community_id, '板块管理', 'admin:community:category', '/community/category', 'C', 3, 1), -(@community_id, '消息管理', 'admin:community:message', '/community/message', 'C', 2, 1), -(@community_id, '匹配配置', 'admin:community:match', '/community/match-config', 'C', 1, 1); - --- 许愿树管理菜单 -INSERT INTO `eb_system_menu` (`pid`, `name`, `icon`, `perms`, `component`, `menu_type`, `sort`, `is_show`) VALUES -(0, '许愿树管理', 'el-icon-present', '', '/wishtree', 'M', 139, 1); -SET @wishtree_id = LAST_INSERT_ID(); - -INSERT INTO `eb_system_menu` (`pid`, `name`, `perms`, `component`, `menu_type`, `sort`, `is_show`) VALUES -(@wishtree_id, '节日管理', 'admin:wishtree:festival', '/wishtree/festival', 'C', 4, 1), -(@wishtree_id, '心愿管理', 'admin:wishtree:wish', '/wishtree/wish', 'C', 3, 1), -(@wishtree_id, '背景素材', 'admin:wishtree:background', '/wishtree/background', 'C', 2, 1), -(@wishtree_id, '数据统计', 'admin:wishtree:statistics', '/wishtree/statistics', 'C', 1, 1); -``` - ---- - -## 九、移动端改造说明 - -### 9.1 WishTreeActivity改造 - -原本地存储改为API调用: - -```java -// 原代码(本地存储) -private void loadWishes() { - for (int i = 0; i < 7; i++) { - wishes[i] = prefs.getString("wish_" + i, ""); - } -} - -// 新代码(API调用) -private void loadWishes() { - ApiService.getInstance() - .getMyWishes(1, 10) - .enqueue(new Callback>>() { - @Override - public void onResponse(Call>> call, - Response>> response) { - if (response.isSuccessful() && response.body() != null) { - List list = response.body().getData().getList(); - updateWishCards(list); - } - } - @Override - public void onFailure(Call>> call, Throwable t) { - Toast.makeText(WishTreeActivity.this, "加载失败", Toast.LENGTH_SHORT).show(); - } - }); -} -``` - -### 9.2 ApiService接口定义 - -```java -public interface ApiService { - - // ==================== 许愿树API ==================== - - @GET("api/front/wishtree/festivals") - Call>> getFestivals(); - - @GET("api/front/wishtree/festivals/current") - Call> getCurrentFestival(); - - @GET("api/front/wishtree/wishes") - Call>> getWishes( - @Query("festivalId") Integer festivalId, - @Query("page") int page, - @Query("limit") int limit - ); - - @GET("api/front/wishtree/wishes/my") - Call>> getMyWishes( - @Query("page") int page, - @Query("limit") int limit - ); - - @POST("api/front/wishtree/wishes") - Call> publishWish(@Body WishRequest request); - - @DELETE("api/front/wishtree/wishes/{id}") - Call> deleteWish(@Path("id") long id); - - @POST("api/front/wishtree/wishes/{id}/like") - Call> likeWish(@Path("id") long id); - - @DELETE("api/front/wishtree/wishes/{id}/like") - Call> unlikeWish(@Path("id") long id); - - @GET("api/front/wishtree/wishes/{id}/comments") - Call>> getComments( - @Path("id") long wishId, - @Query("page") int page, - @Query("limit") int limit - ); - - @POST("api/front/wishtree/wishes/{id}/comments") - Call> addComment( - @Path("id") long wishId, - @Body CommentRequest request - ); - - @GET("api/front/wishtree/backgrounds") - Call>> getBackgrounds(); -} -``` - -### 9.3 数据模型类 - -```java -// WishVO.java -@Data -public class WishVO { - private Long id; - private Integer uid; - private String nickname; - private String avatar; - private Integer festivalId; - private String festivalName; - private String festivalIcon; - private String content; - private String backgroundImage; - private Integer likeCount; - private Integer commentCount; - private Boolean isLiked; - private String createTime; -} - -// WishRequest.java -@Data -public class WishRequest { - private Integer festivalId; - private String content; - private Integer backgroundId; -} - -// CommentVO.java -@Data -public class CommentVO { - private Long id; - private Integer uid; - private String nickname; - private String avatar; - private String content; - private String createTime; -} - -// CommentRequest.java -@Data -public class CommentRequest { - private String content; -} -``` - ---- - -## 十、开发顺序 - -1. **数据库** - 执行建表SQL(8张表) -2. **后端实体类** - 创建Model、VO、Request类 -3. **后端DAO** - 创建DAO接口和Mapper -4. **后端Service** - 实现业务逻辑(含自动审核) -5. **后端Controller** - 实现管理端API + 移动端API -6. **前端API** - 创建管理端接口文件 -7. **前端路由** - 配置路由并注册 -8. **前端页面** - 实现7个管理页面 -9. **菜单配置** - 执行菜单SQL -10. **移动端改造** - 修改WishTreeActivity,接入API - ---- - -## 十一、关键改动总结 - -| 项目 | 原方案 | 新方案 | -|------|--------|--------| -| 数据存储 | SharedPreferences | MySQL数据库 | -| 数据同步 | 无 | 实时API同步 | -| 心愿数量 | 固定7个 | 无限制 | -| 用户互动 | 无 | 点赞、评论 | -| 内容审核 | 无 | 自动+人工审核 | -| 多端访问 | 单设备 | 多端同步 | -| 数据统计 | 无 | 管理端统计 | -| 节日活动 | 无 | 可配置节日 | diff --git a/模块文档/缘池管理端设计文档.md b/模块文档/缘池管理端设计文档.md deleted file mode 100644 index e3570f12..00000000 --- a/模块文档/缘池管理端设计文档.md +++ /dev/null @@ -1,915 +0,0 @@ -# 缘池管理端设计文档 - -> 版本:V1.0 -> 更新日期:2025-12-30 -> 功能范围:板块管理 + 消息管理 + 自动审核 - ---- - -## 一、功能概述 - -缘池是直播平台的社交社区模块,用户可在不同板块发布消息进行交流。管理端提供板块配置、消息审核、自动审核规则设置等功能。 - -### 1.1 功能结构 - -``` -缘池管理 (/community) -├── 板块管理 - 配置社区板块分类 -├── 消息管理 - 查看/审核/管理用户消息 -└── 审核配置 - 自动审核规则设置 -``` - -### 1.2 自动审核机制 - -``` -用户发布消息 → 敏感词检测 → 自动判定 - ↓ - ┌──────────┼──────────┐ - ↓ ↓ ↓ - 无敏感词 轻度敏感 重度敏感 - ↓ ↓ ↓ - 自动通过 待人工审核 自动拒绝 -``` - ---- - -## 二、前端设计 - -### 2.1 路由配置 - -文件:`Zhibo/admin/src/router/modules/communityManage.js` - -```javascript -import Layout from '@/layout'; - -const communityManageRouter = { - path: '/community', - component: Layout, - redirect: '/community/category', - name: 'Community', - alwaysShow: true, - meta: { - title: '缘池管理', - icon: 'el-icon-s-opportunity', - }, - children: [ - { - path: 'category', - component: () => import('@/views/community/category/index'), - name: 'CommunityCategory', - meta: { title: '板块管理', icon: '' }, - }, - { - path: 'message', - component: () => import('@/views/community/message/index'), - name: 'CommunityMessage', - meta: { title: '消息管理', icon: '' }, - }, - { - path: 'audit-config', - component: () => import('@/views/community/auditConfig/index'), - name: 'CommunityAuditConfig', - meta: { title: '审核配置', icon: '' }, - }, - ], -}; - -export default communityManageRouter; -``` - -### 2.2 API接口 - -文件:`Zhibo/admin/src/api/community.js` - -```javascript -import request from '@/utils/request'; - -// ==================== 板块管理 ==================== - -// 获取板块列表 -export function categoryList(params) { - return request({ - url: '/admin/community/category/list', - method: 'get', - params, - }); -} - -// 保存板块(新增/编辑) -export function categorySave(data) { - return request({ - url: '/admin/community/category/save', - method: 'post', - data, - }); -} - -// 删除板块 -export function categoryDelete(id) { - return request({ - url: `/admin/community/category/delete/${id}`, - method: 'delete', - }); -} - -// 更新板块状态 -export function categoryStatus(data) { - return request({ - url: '/admin/community/category/status', - method: 'post', - data, - }); -} - -// ==================== 消息管理 ==================== - -// 获取消息列表(分页) -export function messageList(data) { - return request({ - url: '/admin/community/message/list', - method: 'post', - data, - }); -} - -// 审核消息 -export function messageAudit(data) { - return request({ - url: '/admin/community/message/audit', - method: 'post', - data, - }); -} - -// 删除消息 -export function messageDelete(id) { - return request({ - url: `/admin/community/message/delete/${id}`, - method: 'delete', - }); -} - -// ==================== 审核配置 ==================== - -// 获取审核配置 -export function getAuditConfig() { - return request({ - url: '/admin/community/audit/config', - method: 'get', - }); -} - -// 保存审核配置 -export function saveAuditConfig(data) { - return request({ - url: '/admin/community/audit/config/save', - method: 'post', - data, - }); -} -``` - -### 2.3 页面设计 - -#### 2.3.1 板块管理页面 - -文件:`Zhibo/admin/src/views/community/category/index.vue` - -``` -┌─────────────────────────────────────────────────────────────┐ -│ [+ 新增板块] │ -├─────────────────────────────────────────────────────────────┤ -│ 图标 │ 名称 │ 排序 │ 状态 │ 创建时间 │ 操作 │ -├──────┼────────┼──────┼────────┼────────────┼───────────────┤ -│ 🎮 │ 游戏 │ 100 │ ●启用 │ 2025-01-01 │ [编辑][删除] │ -│ 🎵 │ 音乐 │ 90 │ ●启用 │ 2025-01-01 │ [编辑][删除] │ -│ 💬 │ 交友 │ 80 │ ○禁用 │ 2025-01-01 │ [编辑][删除] │ -└─────────────────────────────────────────────────────────────┘ -``` - -**功能说明:** -- 新增板块:弹窗表单,填写名称、图标、排序 -- 编辑板块:弹窗表单,修改板块信息 -- 删除板块:确认弹窗后删除 -- 状态切换:开关组件,启用/禁用板块 - -#### 2.3.2 消息管理页面 - -文件:`Zhibo/admin/src/views/community/message/index.vue` - -``` -┌─────────────────────────────────────────────────────────────────────┐ -│ 板块[全部▼] 状态[全部▼] 审核方式[全部▼] 时间[起始-结束] [搜索] │ -├─────────────────────────────────────────────────────────────────────┤ -│ 用户 │ 板块 │ 内容 │ 图片 │ 状态 │ 审核方式│ 操作 │ -├──────────┼──────┼──────────────┼──────┼────────┼─────────┼─────────┤ -│ 👤张三 │ 游戏 │ 今天开黑吗.. │ 🖼x2 │ 已通过 │ 自动 │ [删除] │ -│ 👤李四 │ 交友 │ 有人一起.. │ 🖼x1 │ 待审核 │ - │ [✓][✗] │ -│ 👤王五 │ 音乐 │ 推荐一首.. │ - │ 已拒绝 │ 自动 │ [删除] │ -└─────────────────────────────────────────────────────────────────────┘ -``` - -**筛选条件:** -- 板块:下拉选择板块 -- 状态:全部/待审核/已通过/已拒绝 -- 审核方式:全部/自动/人工 -- 时间范围:日期选择器 - -**操作说明:** -- 待审核消息:显示[通过][拒绝]按钮 -- 已审核消息:显示[删除]按钮 -- 点击内容可展开查看完整内容和图片 - -#### 2.3.3 审核配置页面 - -文件:`Zhibo/admin/src/views/community/auditConfig/index.vue` - -``` -┌─────────────────────────────────────────────────────────────┐ -│ 自动审核配置 │ -├─────────────────────────────────────────────────────────────┤ -│ │ -│ 开启自动审核 [========●] │ -│ 说明:开启后系统自动检测敏感词并审核 │ -│ │ -│ 无敏感词自动通过 [========●] │ -│ 说明:消息不含敏感词时自动通过审核 │ -│ │ -│ 重度敏感词自动拒绝 [========●] │ -│ 说明:消息含违禁词时自动拒绝 │ -│ │ -│ [保存配置] │ -└─────────────────────────────────────────────────────────────┘ -``` - ---- - -## 三、数据库设计 - -### 3.1 板块表 (eb_community_category) - -| 字段 | 类型 | 说明 | -|------|------|------| -| id | int | 板块ID,主键自增 | -| name | varchar(50) | 板块名称 | -| icon | varchar(255) | 板块图标URL | -| sort | int | 排序(越大越靠前) | -| status | tinyint | 状态 0禁用 1启用 | -| create_time | datetime | 创建时间 | -| update_time | datetime | 更新时间 | - -### 3.2 消息表 (eb_community_message) - -| 字段 | 类型 | 说明 | -|------|------|------| -| id | bigint | 消息ID,主键自增 | -| uid | int | 用户ID | -| category_id | int | 板块ID | -| content | text | 消息内容 | -| images | varchar(1000) | 图片URL(逗号分隔) | -| status | tinyint | 状态 0待审核 1通过 2拒绝 | -| audit_type | tinyint | 审核方式 0自动 1人工 | -| audit_remark | varchar(255) | 审核备注 | -| is_delete | tinyint | 是否删除 0否 1是 | -| create_time | datetime | 创建时间 | -| update_time | datetime | 更新时间 | - -### 3.3 审核配置表 (eb_community_audit_config) - -| 字段 | 类型 | 说明 | -|------|------|------| -| id | int | 配置ID,固定为1 | -| auto_audit | tinyint | 开启自动审核 0关闭 1开启 | -| auto_pass | tinyint | 无敏感词自动通过 0否 1是 | -| auto_reject | tinyint | 重度敏感词自动拒绝 0否 1是 | -| update_time | datetime | 更新时间 | - -### 3.4 建表SQL - -```sql --- ============================================ --- 缘池管理数据库表 --- ============================================ - --- 1. 板块表 -CREATE TABLE `eb_community_category` ( - `id` int NOT NULL AUTO_INCREMENT COMMENT '板块ID', - `name` varchar(50) NOT NULL COMMENT '板块名称', - `icon` varchar(255) DEFAULT '' COMMENT '板块图标URL', - `sort` int DEFAULT 0 COMMENT '排序(越大越靠前)', - `status` tinyint DEFAULT 1 COMMENT '状态 0禁用 1启用', - `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='缘池板块表'; - --- 2. 消息表 -CREATE TABLE `eb_community_message` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '消息ID', - `uid` int NOT NULL COMMENT '用户ID', - `category_id` int NOT NULL COMMENT '板块ID', - `content` text COMMENT '消息内容', - `images` varchar(1000) DEFAULT '' COMMENT '图片URL(逗号分隔)', - `status` tinyint DEFAULT 1 COMMENT '状态 0待审核 1通过 2拒绝', - `audit_type` tinyint DEFAULT 0 COMMENT '审核方式 0自动 1人工', - `audit_remark` varchar(255) DEFAULT '' COMMENT '审核备注(敏感词等)', - `is_delete` tinyint DEFAULT 0 COMMENT '是否删除 0否 1是', - `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - PRIMARY KEY (`id`), - KEY `idx_uid` (`uid`), - KEY `idx_category` (`category_id`), - KEY `idx_status` (`status`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='缘池消息表'; - --- 3. 审核配置表 -CREATE TABLE `eb_community_audit_config` ( - `id` int NOT NULL AUTO_INCREMENT, - `auto_audit` tinyint DEFAULT 1 COMMENT '开启自动审核 0关闭 1开启', - `auto_pass` tinyint DEFAULT 1 COMMENT '无敏感词自动通过 0否 1是', - `auto_reject` tinyint DEFAULT 1 COMMENT '重度敏感词自动拒绝 0否 1是', - `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='缘池审核配置表'; - --- 初始化审核配置 -INSERT INTO `eb_community_audit_config` (`id`, `auto_audit`, `auto_pass`, `auto_reject`) -VALUES (1, 1, 1, 1); - --- 初始化默认板块 -INSERT INTO `eb_community_category` (`name`, `icon`, `sort`, `status`) VALUES -('交友', 'el-icon-user', 100, 1), -('游戏', 'el-icon-video-play', 90, 1), -('音乐', 'el-icon-headset', 80, 1), -('运动', 'el-icon-football', 70, 1), -('美食', 'el-icon-food', 60, 1); -``` - ---- - -## 四、后端设计 - -### 4.1 实体类 - -#### CommunityCategory.java - -文件:`crmeb-common/src/main/java/com/zbkj/common/model/community/CommunityCategory.java` - -```java -package com.zbkj.common.model.community; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import java.util.Date; - -@Data -@TableName("eb_community_category") -public class CommunityCategory { - @TableId(type = IdType.AUTO) - private Integer id; - private String name; - private String icon; - private Integer sort; - private Integer status; - private Date createTime; - private Date updateTime; -} -``` - -#### CommunityMessage.java - -文件:`crmeb-common/src/main/java/com/zbkj/common/model/community/CommunityMessage.java` - -```java -package com.zbkj.common.model.community; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import java.util.Date; - -@Data -@TableName("eb_community_message") -public class CommunityMessage { - @TableId(type = IdType.AUTO) - private Long id; - private Integer uid; - private Integer categoryId; - private String content; - private String images; - private Integer status; // 0待审核 1通过 2拒绝 - private Integer auditType; // 0自动 1人工 - private String auditRemark; - private Integer isDelete; - private Date createTime; - private Date updateTime; -} -``` - -#### CommunityAuditConfig.java - -文件:`crmeb-common/src/main/java/com/zbkj/common/model/community/CommunityAuditConfig.java` - -```java -package com.zbkj.common.model.community; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import java.util.Date; - -@Data -@TableName("eb_community_audit_config") -public class CommunityAuditConfig { - @TableId(type = IdType.AUTO) - private Integer id; - private Integer autoAudit; // 开启自动审核 - private Integer autoPass; // 无敏感词自动通过 - private Integer autoReject; // 重度敏感词自动拒绝 - private Date updateTime; -} -``` - -### 4.2 Controller - -文件:`crmeb-admin/src/main/java/com/zbkj/admin/controller/CommunityAdminController.java` - -```java -package com.zbkj.admin.controller; - -import com.github.pagehelper.PageInfo; -import com.zbkj.common.model.community.*; -import com.zbkj.common.request.CommunityMessageRequest; -import com.zbkj.common.request.CommunityAuditRequest; -import com.zbkj.common.response.CommunityMessageVO; -import com.zbkj.common.result.CommonResult; -import com.zbkj.service.service.CommunityService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; -import java.util.List; - -@RestController -@RequestMapping("/admin/community") -@Api(tags = "缘池管理") -public class CommunityAdminController { - - @Autowired - private CommunityService communityService; - - // ==================== 板块管理 ==================== - - @ApiOperation("板块列表") - @GetMapping("/category/list") - public CommonResult> categoryList() { - return CommonResult.success(communityService.getCategoryList()); - } - - @ApiOperation("保存板块") - @PostMapping("/category/save") - public CommonResult categorySave(@RequestBody CommunityCategory category) { - communityService.saveCategory(category); - return CommonResult.success("保存成功"); - } - - @ApiOperation("删除板块") - @DeleteMapping("/category/delete/{id}") - public CommonResult categoryDelete(@PathVariable Integer id) { - communityService.deleteCategory(id); - return CommonResult.success("删除成功"); - } - - @ApiOperation("更新板块状态") - @PostMapping("/category/status") - public CommonResult categoryStatus(@RequestBody CommunityCategory category) { - communityService.updateCategoryStatus(category.getId(), category.getStatus()); - return CommonResult.success("更新成功"); - } - - // ==================== 消息管理 ==================== - - @ApiOperation("消息列表") - @PostMapping("/message/list") - public CommonResult> messageList( - @RequestBody CommunityMessageRequest request) { - return CommonResult.success(communityService.getMessageList(request)); - } - - @ApiOperation("审核消息") - @PostMapping("/message/audit") - public CommonResult messageAudit(@RequestBody CommunityAuditRequest request) { - communityService.auditMessage(request.getId(), request.getStatus(), request.getRemark()); - return CommonResult.success("审核成功"); - } - - @ApiOperation("删除消息") - @DeleteMapping("/message/delete/{id}") - public CommonResult messageDelete(@PathVariable Long id) { - communityService.deleteMessage(id); - return CommonResult.success("删除成功"); - } - - // ==================== 审核配置 ==================== - - @ApiOperation("获取审核配置") - @GetMapping("/audit/config") - public CommonResult getAuditConfig() { - return CommonResult.success(communityService.getAuditConfig()); - } - - @ApiOperation("保存审核配置") - @PostMapping("/audit/config/save") - public CommonResult saveAuditConfig(@RequestBody CommunityAuditConfig config) { - communityService.saveAuditConfig(config); - return CommonResult.success("保存成功"); - } -} -``` - -### 4.3 Service - -文件:`crmeb-service/src/main/java/com/zbkj/service/service/CommunityService.java` - -```java -package com.zbkj.service.service; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; -import com.zbkj.common.model.community.*; -import com.zbkj.common.request.CommunityMessageRequest; -import com.zbkj.common.response.CommunityMessageVO; -import com.zbkj.service.dao.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import java.util.List; - -@Service -public class CommunityService { - - @Autowired - private CommunityCategoryDao categoryDao; - @Autowired - private CommunityMessageDao messageDao; - @Autowired - private CommunityAuditConfigDao auditConfigDao; - @Autowired - private SensitiveWordService sensitiveWordService; - - // ==================== 板块管理 ==================== - - public List getCategoryList() { - return categoryDao.selectList(new QueryWrapper() - .orderByDesc("sort")); - } - - public void saveCategory(CommunityCategory category) { - if (category.getId() != null) { - categoryDao.updateById(category); - } else { - categoryDao.insert(category); - } - } - - public void deleteCategory(Integer id) { - categoryDao.deleteById(id); - } - - public void updateCategoryStatus(Integer id, Integer status) { - CommunityCategory category = new CommunityCategory(); - category.setId(id); - category.setStatus(status); - categoryDao.updateById(category); - } - - // ==================== 消息管理 ==================== - - public PageInfo getMessageList(CommunityMessageRequest request) { - PageHelper.startPage(request.getPage(), request.getLimit()); - List list = messageDao.selectMessageList(request); - return new PageInfo<>(list); - } - - public void auditMessage(Long id, Integer status, String remark) { - CommunityMessage message = new CommunityMessage(); - message.setId(id); - message.setStatus(status); - message.setAuditType(1); // 人工审核 - message.setAuditRemark(remark != null ? remark : (status == 1 ? "人工审核通过" : "人工审核拒绝")); - messageDao.updateById(message); - } - - public void deleteMessage(Long id) { - CommunityMessage message = new CommunityMessage(); - message.setId(id); - message.setIsDelete(1); - messageDao.updateById(message); - } - - // ==================== 自动审核(移动端发布时调用) ==================== - - public void autoAuditMessage(CommunityMessage message) { - CommunityAuditConfig config = getAuditConfig(); - - // 未开启自动审核,待人工审核 - if (config.getAutoAudit() != 1) { - message.setStatus(0); - return; - } - - // 敏感词检测 - String content = message.getContent(); - List sensitiveWords = sensitiveWordService.findAll(content); - - if (sensitiveWords.isEmpty()) { - // 无敏感词 - if (config.getAutoPass() == 1) { - message.setStatus(1); - message.setAuditRemark("自动审核通过"); - } else { - message.setStatus(0); - } - message.setAuditType(0); - } else if (sensitiveWordService.hasSevereWord(sensitiveWords)) { - // 重度敏感词 - if (config.getAutoReject() == 1) { - message.setStatus(2); - message.setAuditRemark("含违禁词自动拒绝"); - } else { - message.setStatus(0); - message.setAuditRemark("含敏感词:" + String.join(",", sensitiveWords)); - } - message.setAuditType(0); - } else { - // 轻度敏感词,待人工审核 - message.setStatus(0); - message.setAuditRemark("含敏感词:" + String.join(",", sensitiveWords)); - message.setAuditType(0); - } - } - - // ==================== 审核配置 ==================== - - public CommunityAuditConfig getAuditConfig() { - return auditConfigDao.selectById(1); - } - - public void saveAuditConfig(CommunityAuditConfig config) { - config.setId(1); - auditConfigDao.updateById(config); - } -} -``` - -### 4.4 DAO层 - -#### CommunityCategoryDao.java - -文件:`crmeb-service/src/main/java/com/zbkj/service/dao/CommunityCategoryDao.java` - -```java -package com.zbkj.service.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.zbkj.common.model.community.CommunityCategory; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface CommunityCategoryDao extends BaseMapper { -} -``` - -#### CommunityMessageDao.java - -文件:`crmeb-service/src/main/java/com/zbkj/service/dao/CommunityMessageDao.java` - -```java -package com.zbkj.service.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.zbkj.common.model.community.CommunityMessage; -import com.zbkj.common.request.CommunityMessageRequest; -import com.zbkj.common.response.CommunityMessageVO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import java.util.List; - -@Mapper -public interface CommunityMessageDao extends BaseMapper { - List selectMessageList(@Param("req") CommunityMessageRequest request); -} -``` - -#### CommunityAuditConfigDao.java - -文件:`crmeb-service/src/main/java/com/zbkj/service/dao/CommunityAuditConfigDao.java` - -```java -package com.zbkj.service.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.zbkj.common.model.community.CommunityAuditConfig; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface CommunityAuditConfigDao extends BaseMapper { -} -``` - -### 4.5 Mapper XML - -文件:`crmeb-service/src/main/resources/mapper/community/CommunityMessageMapper.xml` - -```xml - - - - - - - -``` - -### 4.6 Request/Response类 - -#### CommunityMessageRequest.java - -文件:`crmeb-common/src/main/java/com/zbkj/common/request/CommunityMessageRequest.java` - -```java -package com.zbkj.common.request; - -import lombok.Data; - -@Data -public class CommunityMessageRequest { - private Integer page = 1; - private Integer limit = 20; - private Integer categoryId; // 板块ID - private Integer status; // 状态 - private Integer auditType; // 审核方式 - private String startTime; // 开始时间 - private String endTime; // 结束时间 -} -``` - -#### CommunityAuditRequest.java - -文件:`crmeb-common/src/main/java/com/zbkj/common/request/CommunityAuditRequest.java` - -```java -package com.zbkj.common.request; - -import lombok.Data; - -@Data -public class CommunityAuditRequest { - private Long id; // 消息ID - private Integer status; // 审核状态 1通过 2拒绝 - private String remark; // 审核备注 -} -``` - -#### CommunityMessageVO.java - -文件:`crmeb-common/src/main/java/com/zbkj/common/response/CommunityMessageVO.java` - -```java -package com.zbkj.common.response; - -import lombok.Data; -import java.util.Date; - -@Data -public class CommunityMessageVO { - private Long id; - private Integer uid; - private Integer categoryId; - private String content; - private String images; - private Integer status; - private Integer auditType; - private String auditRemark; - private Date createTime; - // 关联字段 - private String nickname; // 用户昵称 - private String avatar; // 用户头像 - private String categoryName; // 板块名称 -} -``` - ---- - -## 五、文件清单 - -### 5.1 前端文件 - -``` -Zhibo/admin/src/ -├── api/ -│ └── community.js # API接口 -├── router/modules/ -│ └── communityManage.js # 路由配置 -└── views/community/ - ├── category/ - │ └── index.vue # 板块管理页面 - ├── message/ - │ └── index.vue # 消息管理页面 - └── auditConfig/ - └── index.vue # 审核配置页面 -``` - -### 5.2 后端文件 - -``` -Zhibo/zhibo-h/ -├── crmeb-admin/src/main/java/com/zbkj/admin/controller/ -│ └── CommunityAdminController.java # 控制器 -├── crmeb-service/src/main/java/com/zbkj/service/ -│ ├── service/ -│ │ └── CommunityService.java # 服务层 -│ └── dao/ -│ ├── CommunityCategoryDao.java # 板块DAO -│ ├── CommunityMessageDao.java # 消息DAO -│ └── CommunityAuditConfigDao.java # 配置DAO -├── crmeb-service/src/main/resources/mapper/community/ -│ └── CommunityMessageMapper.xml # Mapper XML -└── crmeb-common/src/main/java/com/zbkj/common/ - ├── model/community/ - │ ├── CommunityCategory.java # 板块实体 - │ ├── CommunityMessage.java # 消息实体 - │ └── CommunityAuditConfig.java # 配置实体 - ├── request/ - │ ├── CommunityMessageRequest.java # 消息查询请求 - │ └── CommunityAuditRequest.java # 审核请求 - └── response/ - └── CommunityMessageVO.java # 消息响应VO -``` - -### 5.3 数据库 - -``` -eb_community_category # 板块表 -eb_community_message # 消息表 -eb_community_audit_config # 审核配置表 -``` - ---- - -## 六、菜单配置SQL - -```sql --- 添加缘池管理菜单 -INSERT INTO `eb_system_menu` (`pid`, `name`, `icon`, `perms`, `component`, `menu_type`, `sort`, `is_show`) VALUES -(0, '缘池管理', 'el-icon-s-opportunity', '', '/community', 'M', 140, 1); - -SET @community_id = LAST_INSERT_ID(); - -INSERT INTO `eb_system_menu` (`pid`, `name`, `icon`, `perms`, `component`, `menu_type`, `sort`, `is_show`) VALUES -(@community_id, '板块管理', '', 'admin:community:category', '/community/category', 'C', 3, 1), -(@community_id, '消息管理', '', 'admin:community:message', '/community/message', 'C', 2, 1), -(@community_id, '审核配置', '', 'admin:community:audit', '/community/audit-config', 'C', 1, 1); -``` - ---- - -## 七、开发顺序 - -1. **数据库** - 执行建表SQL -2. **后端实体类** - 创建Model类 -3. **后端DAO** - 创建DAO接口和Mapper -4. **后端Service** - 实现业务逻辑 -5. **后端Controller** - 实现API接口 -6. **前端API** - 创建接口文件 -7. **前端路由** - 配置路由 -8. **前端页面** - 实现三个管理页面 -9. **菜单配置** - 执行菜单SQL