-- =====================================================
-- 为用户"道玄"（ID: 121）添加测试数据 - 最终版
-- =====================================================

-- =====================================================
-- 1. 关注记录 (eb_follow_record) - 使用 follower_id 和 followed_id
-- =====================================================
-- 道玄关注其他用户 (follower_id=121)
INSERT IGNORE INTO eb_follow_record (follower_id, follower_nickname, followed_id, followed_nickname, follow_status, create_time) VALUES
(121, '道玄', 100, '测试用户100', '关注', '2026-01-03 20:00:00'),
(121, '道玄', 101, '测试用户101', '关注', '2026-01-03 15:00:00'),
(121, '道玄', 102, '测试用户102', '关注', '2026-01-02 18:00:00'),
(121, '道玄', 103, '测试用户103', '关注', '2026-01-02 12:00:00'),
(121, '道玄', 104, '测试用户104', '关注', '2026-01-01 20:00:00'),
(121, '道玄', 105, '测试用户105', '关注', '2026-01-01 10:00:00');

-- 其他用户关注道玄 (followed_id=121)
INSERT IGNORE INTO eb_follow_record (follower_id, follower_nickname, followed_id, followed_nickname, follow_status, create_time) VALUES
(100, '测试用户100', 121, '道玄', '关注', '2026-01-03 21:00:00'),
(101, '测试用户101', 121, '道玄', '关注', '2026-01-03 16:00:00'),
(106, '测试用户106', 121, '道玄', '关注', '2026-01-02 20:00:00'),
(107, '测试用户107', 121, '道玄', '关注', '2026-01-02 14:00:00');

-- =====================================================
-- 2. 搜索历史 (eb_search_history)
-- =====================================================
INSERT IGNORE INTO eb_search_history (uid, keyword, search_type, search_count, create_time) VALUES
(121, '游戏直播', 1, 3, '2026-01-03 20:00:00'),
(121, '音乐', 1, 2, '2026-01-03 19:00:00'),
(121, '美食教程', 2, 1, '2026-01-02 11:00:00'),
(121, '旅行Vlog', 2, 2, '2026-01-02 10:00:00'),
(121, '编程学习', 1, 4, '2026-01-01 13:00:00'),
(121, '户外运动', 1, 1, '2026-01-01 09:00:00');

-- =====================================================
-- 3. 好友关系 (eb_friend)
-- =====================================================
INSERT IGNORE INTO eb_friend (uid, friend_uid, remark, create_time) VALUES
(121, 100, '游戏主播', '2026-01-03 21:35:00'),
(121, 101, '音乐达人', '2026-01-03 16:10:00'),
(100, 121, '道玄', '2026-01-03 21:35:00'),
(101, 121, '道玄', '2026-01-03 16:10:00');

-- =====================================================
-- 4. 更新用户余额和积分
-- =====================================================
UPDATE eb_user SET 
    now_money = 500.00,
    integral = 1200,
    experience = 350
WHERE uid = 121;

-- =====================================================
-- 5. 验证数据
-- =====================================================
SELECT '直播间点赞' as 类型, COUNT(*) as 数量 FROM eb_live_room_like WHERE user_id = 121
UNION ALL
SELECT '作品点赞', COUNT(*) FROM eb_works_relation WHERE uid = 121 AND type = 1
UNION ALL
SELECT '作品收藏', COUNT(*) FROM eb_works_relation WHERE uid = 121 AND type = 2
UNION ALL
SELECT '关注数', COUNT(*) FROM eb_follow_record WHERE follower_id = 121
UNION ALL
SELECT '粉丝数', COUNT(*) FROM eb_follow_record WHERE followed_id = 121
UNION ALL
SELECT '搜索历史', COUNT(*) FROM eb_search_history WHERE uid = 121
UNION ALL
SELECT '好友数', COUNT(*) FROM eb_friend WHERE uid = 121;

SELECT uid, nickname, now_money as 余额, integral as 积分, experience as 经验 
FROM eb_user WHERE uid = 121;

SELECT '数据插入完成！' as 结果;
