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

async function checkAudioResult() {
  const audioUuid = '34efb5a1-ed88-42da-ad17-7adfc9fbb6df';
  
  const audio = await prisma.audioRecord.findUnique({
    where: { audioId: audioUuid },
    select: {
      id: true,
      status: true,
      audioUrl: true,
      audioDuration: true,
      errorMsg: true,
      title: true,
      wordCount: true,
    }
  });
  
  console.log('\n🎵 音频生成结果：\n');
  
  if (!audio) {
    console.log('❌ 未找到音频记录');
    await prisma.$disconnect();
    return;
  }
  
  console.log(`音频ID: ${audio.id}`);
  console.log(`标题: ${audio.title}`);
  console.log(`字数: ${audio.wordCount}字`);
  console.log(`状态: ${audio.status}`);
  console.log(`时长: ${audio.audioDuration || 0}秒`);
  console.log(`音频URL: ${audio.audioUrl || '未生成'}`);
  
  if (audio.errorMsg) {
    console.log(`错误信息: ${audio.errorMsg}`);
  }
  
  if (audio.status === 'completed' && audio.audioUrl) {
    console.log('\n✅ 音频生成成功！');
    console.log(`\n💡 可以在前端访问:`);
    console.log(`   http://localhost:5173/#/pages/book-generator/chapter-detail?bookId=5&chapter=1214`);
  } else if (audio.status === 'failed') {
    console.log('\n❌ 音频生成失败');
  } else {
    console.log('\n⏳ 音频生成中...');
  }
  
  await prisma.$disconnect();
}

checkAudioResult().catch(console.error);
