Merge branch 'dev' of ssh://git.bgbg.live:18150/root/SEONexus into dev

This commit is contained in:
make
2025-04-01 22:21:23 +08:00
2 changed files with 53 additions and 9 deletions

View File

@@ -445,7 +445,7 @@ class Novel extends BaseController
/**
* 小说章节
* 章节详情
*
* @param Request $Request
* @param integer $intNovelId 小说id
@@ -457,6 +457,24 @@ class Novel extends BaseController
{
$boolIsMobile = $Request->param('boolIsMobile');
// 小说详情
$NovelModel = new NovelModel;
$intNId = $intNovelId;
$arrNovel = $NovelModel->getNovelInfo($intNId);
// 章节
$ChapterModel = new ChapterModel;
$arrFilter = ['n_id' => $intNId, 'c_sort_num' => $intChapterSort, 'c_page' => $intChapterPage];
$arrChapter = $ChapterModel->getChapter($arrFilter);
// 上一章节和下一章节
$arrPreChapter = $ChapterModel->getPreChapter($arrChapter['n_id'], $arrChapter['c_sort_num'], $arrChapter['c_page']);
$arrNextChapter = $ChapterModel->getNextChapter($arrChapter['n_id'], $arrChapter['c_sort_num'], $arrChapter['c_page']);
// 模拟数据
$arrNewsNovel = [
['id' => 1, 'name' => '小说1', 'author' => '作者1'],

View File

@@ -36,6 +36,28 @@ class ChapterModel extends MongoModel
],
];
/**
* Undocumented function
*
* @param array $arrFilter
* @return null|array
*/
public function getChapter(array $arrFilter): null|array
{
$arrOptions = self::$arrChapterOptions;
$arrChapter = $this->getOne($arrFilter, $arrOptions);
if (!empty($arrChapter)) {
applyToKeys($arrChapter, ['created_at', 'updated_at'], 'formatMongoDate');
$arrChapter['content'] = StorageCore::getInstance()->read($arrChapter['c_content_path']);
}
return $arrChapter;
}
/**
* Undocumented function
*
@@ -110,13 +132,13 @@ class ChapterModel extends MongoModel
['c_sort_num' => ['$lt' => $intCSortNum]],
[
'$and' => [
['c_sort_num' => ['$eq' => $intCSortNum]],
['c_page' => ['$lt' => $intCPage]]
['c_sort_num' => ['$eq' => $intCSortNum]],
['c_page' => ['$lt' => $intCPage]]
]
]
]
],
['n_id' => $intNId]
['n_id' => $intNId]
]
];
@@ -125,7 +147,9 @@ class ChapterModel extends MongoModel
'c_sort_num' => -1,
'c_page' => -1,
];
return $this->getChapterAll($arrFilter, 1, $arrSort);
$arrChapterAll = $this->getChapterAll($arrFilter, 1, $arrSort);
return $arrChapterAll[0] ?? [];
}
/**
@@ -145,13 +169,13 @@ class ChapterModel extends MongoModel
['c_sort_num' => ['$gt' => $intCSortNum]],
[
'$and' => [
['c_sort_num' => ['$eq' => $intCSortNum]],
['c_page' => ['$gt' => $intCPage]]
['c_sort_num' => ['$eq' => $intCSortNum]],
['c_page' => ['$gt' => $intCPage]]
]
]
]
],
['n_id' => $intNId]
['n_id' => $intNId]
]
];
@@ -160,6 +184,8 @@ class ChapterModel extends MongoModel
'c_sort_num' => 1,
'c_page' => 1,
];
return $this->getChapterAll($arrFilter, 1, $arrSort);
$arrChapterAll = $this->getChapterAll($arrFilter, 1, $arrSort);
return $arrChapterAll[0] ?? [];
}
}