lh 4 hours ago
parent
commit
d1830f2e40
1 changed files with 7 additions and 3 deletions
  1. 7 3
      app/Services/Book/BookService.php

+ 7 - 3
app/Services/Book/BookService.php

@@ -142,6 +142,7 @@ class BookService
         $version_id = getProp($data, 'version_id');
         if (!$bid) Utils::throwError('20003:请选择书籍');
         if (!$version_id) Utils::throwError('20003:请选择版本');
+        $generate_status = getProp($data, 'generate_status');
         $book = DB::table('books as b')->leftJoin('book_configs as bc', 'b.id', '=', 'bc.bid')->where('b.id', $bid)->whereIn('bc.is_on_shelf', [1,2])
         ->select('bc.book_name', 'bc.cover', 'b.size', 'b.chapter_count', 'b.intro')->first();
         if (!$book) Utils::throwError('20003:书籍不存在');
@@ -160,10 +161,13 @@ class BookService
         }else {
             $header['role_info'] = [];
         }
+        $query = DB::table('mp_chapter_audios')->where('bid', $bid)->where('version_id', $version_id)
+        ->select('cid', 'chapter_name', 'sequence', 'size', 'generate_status', 'audio_url', 'remark');
+        if ($generate_status) {
+            $query->where('generate_status', $generate_status);
+        }
         
-        $list = DB::table('mp_chapter_audios')->where('bid', $bid)->where('version_id', $version_id)->orderBy('sequence', 'asc')
-        ->select('cid', 'chapter_name', 'sequence', 'size', 'generate_status', 'audio_url', 'remark')
-        ->paginate();
+        $list = $query->orderBy('sequence', 'asc')->paginate();
 
         return ['header' => $header, 'list' => $list];