const { prisma } = require('../src/models');

async function check() {
  const tasks = await prisma.ttsTask.findMany({ orderBy: { id: 'asc' } });
  console.log('=== TtsTask 队列表 ===');
  tasks.forEach(t => console.log('  #'+t.id, 'type='+t.taskType, 'status='+t.status, 'ch='+t.chapterId, 'hash='+t.contentHash?.substring(0,10), 'retry='+t.retryCount));
  console.log('  总计:', tasks.length, '个任务\n');

  const book = await prisma.book.findUnique({ where: { id: 30 }, select: { genStage: true, progress: true } });
  console.log('=== 书籍 #30 === genStage:', book?.genStage, 'progress:', book?.progress, '\n');

  const chapters = await prisma.bookChapter.findMany({ where: { bookId: 30 }, orderBy: { id: 'asc' }, select: { id: true, level: true, number: true, title: true, genStage: true, wordCount: true, audioUrl: true } });
  console.log('=== 章节状态 ===');
  chapters.forEach(c => console.log('  #'+c.id, 'L'+c.level, '#'+c.number, (c.title||'').substring(0,25), c.genStage, c.wordCount+'字', c.audioUrl ? '有音频' : '无音频'));

  await prisma.$disconnect();
}
check().catch(e => { console.error(e); process.exit(1); });
