lh 4 ヶ月 前
コミット
691770bc70

+ 8 - 0
app/Http/Controllers/DeepSeek/DeepSeekController.php

@@ -433,6 +433,14 @@ class DeepSeekController extends BaseController
         $this->deepseekService->exportScript($data);
     }
 
+    public function getBookContent(Request $request) {
+        $data = $request->all();
+        
+        // 直接调用导出服务,该方法会直接输出文件并退出
+        $result = $this->deepseekService->getBookContent($data);
+        return $this->success($result);
+    }
+
     // 新建对话
     public function addChat(Request $request) {
         // 忽略所有超时限制

+ 1 - 1
app/Services/Book/BookService.php

@@ -55,7 +55,7 @@ class BookService
 
         $query = DB::table('books as b')->leftJoin('book_configs as bc', 'b.id', '=', 'bc.bid')
         ->where('b.size', '<', 30000)->where('b.status', 1)
-        ->whereIn('bc.cp_source', ['ycsd', 'yqsd'])->select('bc.bid', 'bc.book_name');
+        ->whereIn('bc.cp_source', ['ycsd', 'yqsd'])->select('bc.bid', 'bc.book_name', DB::raw('(select count(id) from chapters where is_check=1 and is_deleted=0 and bid = b.id) as chapter_count'));
         if ($bid) {
             $query->where('bc.bid', $bid);
         }

+ 12 - 0
app/Services/DeepSeek/DeepSeekService.php

@@ -1855,6 +1855,18 @@ class DeepSeekService
         return true;
     }
 
+    public function getBookContent($data) {
+        $bid = getProp($data, 'bid');
+        $start_sequence = getProp($data, 'start_sequence');
+        $end_sequence = getProp($data, 'end_sequence');
+
+        $chapter_contents = DB::table('chapters as c')->leftJoin('chapter_contents as cc', 'c.chapter_content_id', 'cc.id')->where('c.bid', $bid)->where('c.is_check', 1)->where('c.is_deleted', 0)->whereBetween('c.sequence', [$start_sequence, $end_sequence])
+        ->orderBy('c.sequence')->pluck('cc.content')->toArray();
+        $return_content = filterContent(implode(PHP_EOL, $chapter_contents));
+        
+        return $return_content;
+    }
+
     public function exportScript($data) {
         $filename = getProp($data, 'filename');
         $script_id = getProp($data, 'script_id');

+ 1 - 0
routes/api.php

@@ -102,6 +102,7 @@ Route::group(['middleware' => ['bindToken', 'bindExportToken', 'checkLogin']], f
         Route::get('editEpisode', [DeepSeekController::class, 'editEpisode']);
         Route::get('delEpisode', [DeepSeekController::class, 'delEpisode']);
         Route::get('exportScript', [DeepSeekController::class, 'exportScript']);
+        Route::get('getBookContent', [DeepSeekController::class, 'getBookContent']);
         Route::post('chatWithFile', [DeepSeekController::class, 'chatWithFile']);
         Route::post('chatWithFileStream', [DeepSeekController::class, 'chatWithFileStream']);
         Route::post('saveScript', [DeepSeekController::class, 'saveScript']);