-- 动态生成清理脚本的SQL
-- 运行此查询，它会返回一系列 TRUNCATE 语句
-- 逻辑：
-- 1. 包含所有 hot_ 开头的表
-- 2. 包含 sys_flow_ 开头的表
-- 3. 排除 _config 结尾的配置表
-- 4. 排除 _template 结尾的模板表
-- 5. 排除特定的系统/资源保留表

SELECT CONCAT('TRUNCATE TABLE ', TABLE_NAME, ';') AS cleanup_script
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = (SELECT DATABASE())
  AND (
    -- 规则1：所有 hot_ 开头的表
    (TABLE_NAME LIKE 'hot_%'
        -- 排除配置表
        AND TABLE_NAME NOT LIKE '%_config'
        -- 排除模板表
        AND TABLE_NAME NOT LIKE '%_template'
        -- 排除特定保留表
        AND TABLE_NAME NOT IN (
                               'hot_course_resource',
                               'hot_media_resource',
                               'hot_question_bank',
                               'hot_exam_paper',
                               'hot_system_agreement',
                               'hot_law_regulation',
                               'hot_vehicle_type',
                               'hot_vehicle_brand_model',
                               'hot_company_basic_config',
                               'hot_company_dept_config',
                               'hot_driver_annual_assessment_config',
                               'hot_sign_audit_permission_config',
                               'hot_vehicle_three_inspect_config',
                               'hot_hidden_danger_inspect_store',
                               'hot_hidden_danger_check_config',
                               'hot_company_basic_config',
                               'hot_vehicle_inspection_config',
                               'hot_vehicle_secondary_maintenance_config',
                               'hot_accident_likelihood_level_config',
                               'hot_accident_severity_level_config',
                               'hot_accident_level_config',
                               'hot_risk_level_config',
                               'hot_risk_score_level',
                               'hot_vehicle_brand_model',
                               'hot_system_template',
                               'hot_file_type_config'
            )
        )
        OR
        -- 规则2：流程相关表
    TABLE_NAME IN ('sys_flow_instance', 'sys_flow_task', 'sys_flow_task_his')
    )
ORDER BY TABLE_NAME;
