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

-- =====================================================
-- 1. 直播间点赞 (eb_live_room_like) - 使用 user_id 字段
-- =====================================================
INSERT IGNORE INTO eb_live_room_like (user_id, room_id, user_nickname, like_count, create_time) VALUES
(121, 1, '道玄', 15, '2026-01-03 20:35:00'),
(121, 2, '道玄', 28, '2026-01-03 21:15:00'),
(121, 3, '道玄', 8, '2026-01-02 19:10:00'),
(121, 4, '道玄', 42, '2026-01-02 12:30:00'),
(121, 5, '道玄', 20, '2026-01-01 14:30:00');

-- =====================================================
-- 2. 作品关系 (eb_works_relation) - 点赞和收藏
-- =====================================================
-- 点赞作品 (type=1)
INSERT IGNORE INTO eb_works_relation (uid, works_id, type, create_time) VALUES
(121, 1, 1, '2026-01-03 22:05:00'),
(121, 2, 1, '2026-01-03 18:10:00'),
(121, 3, 1, '2026-01-02 16:15:00'),
(121, 4, 1, '2026-01-01 20:00:00'),
(121, 5, 1, '2026-01-01 15:00:00');

-- 收藏作品 (type=2)
INSERT IGNORE INTO eb_works_relation (uid, works_id, type, create_time) VALUES
(121, 1, 2, '2026-01-03 22:06:00'),
(121, 2, 2, '2026-01-03 18:12:00'),
(121, 6, 2, '2026-01-02 10:00:00'),
(121, 7, 2, '2026-01-01 11:00:00');

-- =====================================================
-- 3. 关注记录 (eb_follow_record)
-- =====================================================
INSERT IGNORE INTO eb_follow_record (uid, follow_uid, create_time) VALUES
(121, 100, '2026-01-03 20:00:00'),
(121, 101, '2026-01-03 15:00:00'),
(121, 102, '2026-01-02 18:00:00'),
(121, 103, '2026-01-02 12:00:00'),
(121, 104, '2026-01-01 20:00:00'),
(121, 105, '2026-01-01 10:00:00');

-- 被关注记录
INSERT IGNORE INTO eb_follow_record (uid, follow_uid, create_time) VALUES
(100, 121, '2026-01-03 21:00:00'),
(101, 121, '2026-01-03 16:00:00'),
(106, 121, '2026-01-02 20:00:00'),
(107, 121, '2026-01-02 14:00:00');

-- =====================================================
-- 4. 搜索历史 (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');

-- =====================================================
-- 5. 好友关系 (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');

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

-- =====================================================
-- 7. 验证数据
-- =====================================================
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 uid = 121
UNION ALL
SELECT '粉丝数', COUNT(*) FROM eb_follow_record WHERE follow_uid = 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 结果;
