-- =====================================================
-- 举报表检查和测试数据脚本
-- =====================================================

-- 1. 检查表是否存在
SELECT '=== 检查举报表 ===' as step;
SHOW TABLES LIKE 'eb_report';

-- 2. 查看表结构
SELECT '=== 表结构 ===' as step;
DESCRIBE eb_report;

-- 3. 查看现有数据
SELECT '=== 现有数据 ===' as step;
SELECT COUNT(*) as total FROM eb_report;

-- 4. 查看详细数据
SELECT * FROM eb_report ORDER BY id DESC LIMIT 10;

-- 5. 如果没有数据，插入测试数据
INSERT IGNORE INTO `eb_report` 
(`uid`, `nickname`, `target_type`, `target_id`, `target_name`, `reason_type`, `reason`, `images`, `status`, `create_time`) 
VALUES
(121, '测试用户1', 1, 122, '被举报用户A', 1, '该用户发布色情低俗内容', '[]', 0, NOW()),
(121, '测试用户1', 2, 1, '违规直播间', 2, '直播间存在广告骚扰行为', '[]', 0, NOW()),
(122, '测试用户2', 3, 1, '违规动态', 5, '动态内容存在人身攻击', '[]', 0, DATE_SUB(NOW(), INTERVAL 1 DAY)),
(123, '测试用户3', 1, 124, '被举报用户B', 6, '该用户涉嫌欺诈骗钱', '[]', 2, DATE_SUB(NOW(), INTERVAL 2 DAY));

-- 6. 再次查看数据
SELECT '=== 插入后数据 ===' as step;
SELECT r.*, 
    CASE r.target_type WHEN 1 THEN '用户' WHEN 2 THEN '房间' WHEN 3 THEN '动态' WHEN 4 THEN '评论' ELSE '其他' END as type_text,
    CASE r.status WHEN 0 THEN '待处理' WHEN 1 THEN '处理中' WHEN 2 THEN '已处理' WHEN 3 THEN '已忽略' ELSE '未知' END as status_text
FROM eb_report r 
ORDER BY r.id DESC;

-- 7. 统计
SELECT '=== 统计 ===' as step;
SELECT 
    COUNT(*) as total,
    SUM(CASE WHEN status = 0 THEN 1 ELSE 0 END) as pending,
    SUM(CASE WHEN status = 2 THEN 1 ELSE 0 END) as processed
FROM eb_report;
