const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();

async function checkAudio() {
  console.log('\n📊 检查ID 1214的音频：\n');
  
  const chapter = await prisma.bookChapter.findUnique({
    where: { id: 1214 },
    select: {
      id: true,
      title: true,
      level: true,
      audioUrl: true,
      audioDuration: true,
      content: true,
    }
  });
  
  if (!chapter) {
    console.log('❌ 找不到该章节\n');
    await prisma.$disconnect();
    return;
  }
  
  console.log(`章节: ${chapter.title}`);
  console.log(`ID: ${chapter.id}`);
  console.log(`Level: ${chapter.level}`);
  console.log(`audioUrl: ${chapter.audioUrl || '无'}`);
  console.log(`audioDuration: ${chapter.audioDuration || 0}秒`);
  console.log(`内容: ${chapter.content || '无'}\n`);
  
  // 检查AudioRecord
  const audioRecords = await prisma.audioRecord.findMany({
    where: {
      userId: 1,
      status: 'completed'
    },
    orderBy: { createdAt: 'desc' },
    take: 3,
    select: {
      id: true,
      title: true,
      audioUrl: true,
      audioDuration: true,
      createdAt: true,
    }
  });
  
  console.log('最近3个完成的音频记录：\n');
  audioRecords.forEach((record, index) => {
    console.log(`${index + 1}. ${record.title}`);
    console.log(`   ID: ${record.id}`);
    console.log(`   audioUrl: ${record.audioUrl || '无'}`);
    console.log(`   时长: ${record.audioDuration}秒`);
    console.log(`   时间: ${record.createdAt}\n`);
  });
  
  await prisma.$disconnect();
}

checkAudio().catch(console.error);
