check-book2.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. const { PrismaClient } = require('@prisma/client');
  2. const prisma = new PrismaClient();
  3. async function checkBook2() {
  4. const book = await prisma.book.findUnique({
  5. where: { id: 2 },
  6. select: {
  7. id: true,
  8. title: true,
  9. status: true,
  10. progress: true,
  11. errorMsg: true,
  12. bookScale: true,
  13. }
  14. });
  15. console.log('Book ID 2 状态:');
  16. console.log(JSON.stringify(book, null, 2));
  17. if (book) {
  18. const chapters = await prisma.bookChapter.count({ where: { bookId: 2, level: 1 } });
  19. const sections = await prisma.bookChapter.count({ where: { bookId: 2, level: 2 } });
  20. const subsections = await prisma.bookChapter.count({ where: { bookId: 2, level: 3 } });
  21. const completed = await prisma.bookChapter.count({ where: { bookId: 2, level: 3, contentStatus: 'completed' } });
  22. console.log(`\n大纲: ${chapters}章, ${sections}节, ${subsections}小节`);
  23. console.log(`已完成内容: ${completed}`);
  24. console.log(`错误信息: ${book.errorMsg || '无'}`);
  25. }
  26. await prisma.$disconnect();
  27. }
  28. checkBook2().catch(console.error);