-- =====================================================
-- 为用户"道玄"（ID: 121）添加测试数据 - 完整修正版
-- =====================================================

-- =====================================================
-- 1. 搜索历史 (eb_search_history) - 使用 user_id
-- =====================================================
INSERT IGNORE INTO eb_search_history (user_id, 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');

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

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

-- =====================================================
-- 4. 验证所有数据
-- =====================================================
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 user_id = 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 结果;
