check-content-status.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. const { PrismaClient } = require('@prisma/client');
  2. const prisma = new PrismaClient();
  3. async function checkContentStatus() {
  4. console.log('\n📊 检查contentStatus状态:\n');
  5. const chapterId = 1163;
  6. const chapter = await prisma.bookChapter.findUnique({
  7. where: { id: chapterId }
  8. });
  9. if (!chapter) {
  10. console.log('❌ 找不到该章节\n');
  11. await prisma.$disconnect();
  12. return;
  13. }
  14. console.log(`章节: ${chapter.title}`);
  15. console.log(`ID: ${chapter.id}`);
  16. console.log(`BookId: ${chapter.bookId}`);
  17. console.log(`Level: ${chapter.level}`);
  18. console.log(`内容: ${chapter.content || '无'}`);
  19. console.log(`contentStatus: ${chapter.contentStatus || 'null'}`);
  20. console.log(`audioStatus: ${chapter.audioStatus || 'null'}`);
  21. console.log('');
  22. // 统计该书各状态的小节数量
  23. const statusCount = await prisma.bookChapter.groupBy({
  24. by: ['contentStatus'],
  25. where: {
  26. bookId: chapter.bookId,
  27. level: 3
  28. },
  29. _count: true
  30. });
  31. console.log(`📈 BookId ${chapter.bookId} 小节内容状态统计:\n`);
  32. statusCount.forEach(s => {
  33. console.log(` ${s.contentStatus || 'null'}: ${s._count}个`);
  34. });
  35. console.log('\n');
  36. await prisma.$disconnect();
  37. }
  38. checkContentStatus().catch(console.error);