|
|
@@ -237,8 +237,15 @@ class BookService
|
|
|
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)
|
|
|
- ->select('bc.book_name', 'bc.cover', 'b.size', 'b.chapter_count', 'b.intro')->first();
|
|
|
+
|
|
|
+ if (strlen($bid) >= 8) { // 兼容海外书籍
|
|
|
+ $version_bid = DB::table('mp_book_translation_version')->where('id', $bid)->value('bid');
|
|
|
+ $book = DB::table('books as b')->leftJoin('book_configs as bc', 'b.id', '=', 'bc.bid')->where('b.id', $version_bid)
|
|
|
+ ->select('bc.book_name', 'bc.cover', 'b.size', 'b.chapter_count', 'b.intro')->first();
|
|
|
+ }else {
|
|
|
+ $book = DB::table('books as b')->leftJoin('book_configs as bc', 'b.id', '=', 'bc.bid')->where('b.id', $bid)
|
|
|
+ ->select('bc.book_name', 'bc.cover', 'b.size', 'b.chapter_count', 'b.intro')->first();
|
|
|
+ }
|
|
|
if (!$book) Utils::throwError('20003:书籍不存在');
|
|
|
$header = (array)$book;
|
|
|
$header['cover'] = addPrefix($header['cover']);
|
|
|
@@ -288,12 +295,17 @@ class BookService
|
|
|
}
|
|
|
|
|
|
public function getChapterContent($data) {
|
|
|
+ $bid = getProp($data, 'bid');
|
|
|
$cid = getProp($data, 'cid');
|
|
|
|
|
|
if (!$cid) Utils::throwError('20003:请选择章节');
|
|
|
- $content = DB::table('chapters as c')->leftJoin('chapter_contents as cc', 'c.chapter_content_id', '=', 'cc.id')->where('c.id', $cid)->value('cc.content');
|
|
|
+ if (strlen($bid) >= 8) {
|
|
|
+ $content = DB::table('chapters_ai_translation')->where('version_id', $bid)->where('id', $cid)->value('translation');
|
|
|
+ }else {
|
|
|
+ $content = DB::table('chapters as c')->leftJoin('chapter_contents as cc', 'c.chapter_content_id', '=', 'cc.id')->where('c.id', $cid)->value('cc.content');
|
|
|
+ $content = filterContent($content);
|
|
|
+ }
|
|
|
if (!$content) Utils::throwError('20003:章节内容不存在');
|
|
|
- $content = filterContent($content);
|
|
|
|
|
|
return $content;
|
|
|
}
|