فهرست منبع

fix: getBookTitle 回退查询用 where 替代 whereBetween

whereBetween 需两元素数组,传标量会抛 TypeError;改为 where 精确匹配
顶层 para。同时移除多余的 $chapters 赋值,并在 PaliTextService 占位
getChildrenChapters()。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
visuddhinanda 4 هفته پیش
والد
کامیت
d1edf0ec22
2فایلهای تغییر یافته به همراه19 افزوده شده و 8 حذف شده
  1. 2 2
      api-v13/app/Http/Controllers/Library/BookController.php
  2. 17 6
      api-v13/app/Services/PaliTextService.php

+ 2 - 2
api-v13/app/Http/Controllers/Library/BookController.php

@@ -194,13 +194,13 @@ class BookController extends Controller
     private function getBookTitle(int $book, int $paragraph, string $channelId)
     {
         $bookTopPara = $this->paliTextService->getBookPara($book, $paragraph)->paragraph;
-        $title = $chapters = ProgressChapter::where('book', $book)
+        $title = ProgressChapter::where('book', $book)
             ->where('para', $bookTopPara)
             ->where('channel_id', $channelId)
             ->value('title');
         if (empty($title)) {
             $title = PaliText::where('book', $book)
-                ->whereBetween('paragraph', $bookTopPara)
+                ->where('paragraph', $bookTopPara)
                 ->value('toc');
         }
 

+ 17 - 6
api-v13/app/Services/PaliTextService.php

@@ -11,11 +11,12 @@ class PaliTextService
     public function getParent(int $book, int $para)
     {
         $parent = PaliText::where('book', $book)
-            ->where('paragraph',  $para)->value('parent');
+            ->where('paragraph', $para)->value('parent');
 
         return $parent ? PaliText::where('book', $book)
-            ->where('paragraph',  $parent)->first() : null;
+            ->where('paragraph', $parent)->first() : null;
     }
+
     public function getCurrChapter(int $book, int $para)
     {
         $paragraph = PaliText::where('book', $book)
@@ -28,22 +29,28 @@ class PaliTextService
             return null;
         }
     }
+
+    public function getChildrenChapters(int $book, int $para) {}
+
     public function getBookPara(int $book, int $para)
     {
         $paragraph = PaliText::where('book', $book)
             ->where('paragraph', '<=', $para)
             ->where('level', 1)
             ->orderBy('paragraph', 'asc')->first();
-        if (!$paragraph) {
+        if (! $paragraph) {
             Log::warning('not found book ', ['book' => $book, 'para' => $para]);
+
             return null;
         }
+
         return $paragraph;
     }
+
     public function getParaCategoryTags(int $book, int $para): array
     {
         $bookPara = self::getBookPara($book, $para);
-        if (!$bookPara) {
+        if (! $bookPara) {
             return [];
         }
         if (Str::isUuid($bookPara->uid)) {
@@ -52,20 +59,24 @@ class PaliTextService
             Log::error('book uid not uuid', [
                 'book' => $book,
                 'para' => $para,
-                'uid' => $bookPara->uid
+                'uid' => $bookPara->uid,
             ]);
+
             return [];
         }
     }
+
     public function getParaInfo(int $book, int $para)
     {
         return PaliText::where('book', $book)
-            ->where('paragraph',  $para)
+            ->where('paragraph', $para)
             ->first();
     }
+
     public function getParaPathTitle(int $book, int $para)
     {
         $para = self::getParaInfo($book, $para);
+
         return array_map(function ($item) {
             return $item->title;
         }, json_decode($para->path));