-- 关注功能诊断脚本
-- 用于检查数据库表和数据状态

-- 1. 检查表是否存在
SELECT 
    'eb_user_follow' as table_name,
    CASE WHEN COUNT(*) > 0 THEN '✓ 存在' ELSE '✗ 不存在' END as status
FROM information_schema.tables 
WHERE table_schema = 'crmeb' AND table_name = 'eb_user_follow'
UNION ALL
SELECT 
    'eb_follow_record' as table_name,
    CASE WHEN COUNT(*) > 0 THEN '✓ 存在' ELSE '✗ 不存在' END as status
FROM information_schema.tables 
WHERE table_schema = 'crmeb' AND table_name = 'eb_follow_record';

-- 2. 检查表结构
SHOW CREATE TABLE eb_user_follow\G
SHOW CREATE TABLE eb_follow_record\G

-- 3. 查看数据量
SELECT 'eb_user_follow' as table_name, COUNT(*) as record_count FROM eb_user_follow
UNION ALL
SELECT 'eb_follow_record' as table_name, COUNT(*) as record_count FROM eb_follow_record;

-- 4. 查看最近的关注记录
SELECT 
    'eb_user_follow (最近10条)' as description,
    uf.*
FROM eb_user_follow uf
ORDER BY uf.create_time DESC
LIMIT 10;

SELECT 
    'eb_follow_record (最近10条)' as description,
    fr.*
FROM eb_follow_record fr
ORDER BY fr.create_time DESC
LIMIT 10;

-- 5. 检查用户表
SELECT 
    uid,
    nickname,
    phone,
    is_streamer,
    streamer_level
FROM eb_user
WHERE is_streamer = 1
LIMIT 5;

-- 6. 检查直播间表
SELECT 
    id,
    uid as streamer_id,
    title,
    streamer_name,
    is_live
FROM eb_live_room
LIMIT 5;
