zhibo/QUICK_FIX.md
2026-01-03 15:32:31 +08:00

162 lines
4.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 关注功能快速修复 - 立即执行
## 问题
数据库缺少 `eb_follow_record` 表,导致关注功能无法工作。
## 解决方案
在服务器上直接执行SQL创建表。
## 立即执行以下命令
### 步骤1SSH连接到服务器
```bash
ssh root@1.15.149.240
```
### 步骤2连接MySQL
```bash
mysql -u root -p
```
输入密码后,执行:
```sql
use crmeb;
```
### 步骤3创建表复制整段执行
```sql
CREATE TABLE IF NOT EXISTS `eb_follow_record` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`follower_id` int(11) NOT NULL COMMENT '关注者用户ID',
`follower_nickname` varchar(50) DEFAULT NULL COMMENT '关注者昵称',
`follower_phone` varchar(20) DEFAULT NULL COMMENT '关注者手机号',
`followed_id` int(11) NOT NULL COMMENT '被关注者用户ID',
`followed_nickname` varchar(50) DEFAULT NULL COMMENT '被关注者昵称',
`followed_phone` varchar(20) DEFAULT NULL COMMENT '被关注者手机号',
`follow_status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '关注状态1-已关注 0-已取消',
`is_deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT '逻辑删除0-未删除 1-已删除',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`ext_field1` varchar(100) DEFAULT NULL COMMENT '扩展字段1',
`ext_field2` int(11) DEFAULT NULL COMMENT '扩展字段2',
`ext_field3` varchar(200) DEFAULT NULL COMMENT '扩展字段3',
`ext_field4` bigint(20) DEFAULT NULL COMMENT '扩展字段4',
`ext_field5` text COMMENT '扩展字段5',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_follower_followed` (`follower_id`,`followed_id`),
KEY `idx_follower_id` (`follower_id`),
KEY `idx_followed_id` (`followed_id`),
KEY `idx_follow_status` (`follow_status`),
KEY `idx_is_deleted` (`is_deleted`),
KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='关注记录表';
```
### 步骤4验证表已创建
```sql
SHOW TABLES LIKE 'eb_follow_record';
DESC eb_follow_record;
```
应该看到表结构信息。
### 步骤5退出MySQL
```sql
exit;
```
### 步骤6重启后端服务
```bash
cd /root/zhibo/Zhibo/zhibo-h
./restart.sh
```
等待服务重启完成约30秒
### 步骤7测试关注功能
1. 打开Android应用
2. 登录账号
3. 进入任意直播间
4. 点击"关注"按钮
5. 应该看到"已关注主播"提示
6. 退出直播间,重新进入
7. 按钮应显示"已关注"状态
### 步骤8验证数据库记录
```bash
mysql -u root -p
use crmeb;
```
```sql
-- 查看最新的关注记录
SELECT
fr.id,
fr.follower_id,
u1.nickname as follower_name,
fr.followed_id,
u2.nickname as followed_name,
fr.follow_status,
fr.create_time
FROM eb_follow_record fr
LEFT JOIN eb_user u1 ON fr.follower_id = u1.uid
LEFT JOIN eb_user u2 ON fr.followed_id = u2.uid
ORDER BY fr.create_time DESC
LIMIT 10;
```
应该能看到刚才的关注记录。
## 如果还是不行
请提供以下信息:
1. **表是否创建成功?**
```sql
SHOW CREATE TABLE eb_follow_record;
```
2. **Android日志**
```bash
adb logcat | grep "RoomDetail"
```
查找包含 "关注" 或 "follow" 的日志行
3. **后端日志**
```bash
tail -100 /root/zhibo/Zhibo/zhibo-h/crmeb-admin/logs/info.log | grep -i follow
```
4. **测试API**
```bash
# 先登录获取token
curl -X POST http://1.15.149.240:30001/api/front/login \
-H "Content-Type: application/json" \
-d '{"phone":"你的手机号","password":"你的密码"}'
# 使用返回的token测试关注接口
curl -X POST http://1.15.149.240:30001/api/front/follow/follow \
-H "Content-Type: application/json" \
-H "Authorization: Bearer 你的token" \
-d '{"userId":主播的用户ID}'
```
## 常见错误
### 错误1Table already exists
说明表已经存在,跳过创建步骤,直接重启服务。
### 错误2Access denied
检查MySQL密码是否正确。
### 错误3Unknown database 'crmeb'
数据库名可能不同,先查看:
```sql
SHOW DATABASES;
```
找到正确的数据库名。
## 完成!
执行完以上步骤后,关注功能应该可以正常工作了。