-- 检查成长记录表的数据情况

-- 1. 查看表结构
SHOW CREATE TABLE growth_record;

-- 2. 查看所有字段
SHOW FULL COLUMNS FROM growth_record;

-- 3. 统计总记录数
SELECT COUNT(*) AS '总记录数' FROM growth_record;

-- 4. 查看最近的10条成长记录
SELECT 
    id,
    student_id AS '学生ID',
    student_name AS '学生姓名',
    teacher_id AS '陪伴员ID',
    teacher_name AS '陪伴员姓名',
    record_date AS '记录日期',
    content AS '反馈内容',
    CASE 
        WHEN manager_supplement IS NOT NULL AND manager_supplement != '' THEN '已补充'
        ELSE '未补充'
    END AS '管理师补充状态',
    created_at AS '创建时间'
FROM growth_record
ORDER BY id DESC
LIMIT 10;

-- 5. 统计管理师补充情况
SELECT 
    COUNT(*) AS '总记录数',
    SUM(CASE WHEN manager_supplement IS NOT NULL AND manager_supplement != '' THEN 1 ELSE 0 END) AS '已补充数量',
    SUM(CASE WHEN manager_supplement IS NULL OR manager_supplement = '' THEN 1 ELSE 0 END) AS '未补充数量'
FROM growth_record;

-- 6. 按日期统计记录数量
SELECT 
    DATE(record_date) AS '日期',
    COUNT(*) AS '记录数量'
FROM growth_record
GROUP BY DATE(record_date)
ORDER BY DATE(record_date) DESC
LIMIT 10;

-- 7. 查看是否有照片的记录
SELECT 
    id,
    student_name AS '学生',
    teacher_name AS '陪伴员',
    record_date AS '日期',
    CASE 
        WHEN photos IS NOT NULL AND photos != '' THEN '有照片'
        ELSE '无照片'
    END AS '照片状态',
    photos AS '照片路径'
FROM growth_record
WHERE photos IS NOT NULL AND photos != ''
ORDER BY id DESC
LIMIT 5;

-- 8. 查看完整的一条记录示例
SELECT * FROM growth_record ORDER BY id DESC LIMIT 1;
