123
This commit is contained in:
@@ -324,22 +324,33 @@ class Novel extends BaseController
|
|||||||
|
|
||||||
$boolIsMobile = $Request->param('boolIsMobile');
|
$boolIsMobile = $Request->param('boolIsMobile');
|
||||||
|
|
||||||
|
|
||||||
$NovelModel = new NovelModel;
|
$NovelModel = new NovelModel;
|
||||||
|
|
||||||
|
// 小说详情
|
||||||
$arrNovel = $NovelModel->getNovelInfo($intNId);
|
$arrNovel = $NovelModel->getNovelInfo($intNId);
|
||||||
|
|
||||||
|
// 最后章节
|
||||||
$ChapterModel = new ChapterModel;
|
$ChapterModel = new ChapterModel;
|
||||||
|
|
||||||
$arrLatestChapter = $ChapterModel->getLatestChapter($intNId);
|
$arrLatestChapter = $ChapterModel->getLatestChapter($intNId);
|
||||||
|
|
||||||
|
// 最近五个章节
|
||||||
|
$arrChapter = $ChapterModel->getChapterAll([
|
||||||
|
'n_id' => $intNId,
|
||||||
|
'c_page' => 0,
|
||||||
|
], 5, ['c_sort_num' => -1]);
|
||||||
|
|
||||||
|
// 点击数
|
||||||
$NovelClicksModel = new NovelClicksModel;
|
$NovelClicksModel = new NovelClicksModel;
|
||||||
$arrNovelClicks = $NovelClicksModel->getStats($intNId);
|
$arrNovelClicks = $NovelClicksModel->getStats($intNId);
|
||||||
|
|
||||||
|
// 推荐小说
|
||||||
|
$arrRelateveNId = array_column($arrNovel['n_related_novel'], 'n_id');
|
||||||
|
|
||||||
|
$arrRelateveNovel = $NovelModel->getNovelAll([
|
||||||
|
'$in' => $arrRelateveNId,
|
||||||
|
], 100);
|
||||||
|
|
||||||
// echo '<pre>';
|
|
||||||
// print_r($arrNovel);
|
|
||||||
// exit;
|
|
||||||
|
|
||||||
$strNovel = '斗罗大陆';
|
$strNovel = '斗罗大陆';
|
||||||
|
|
||||||
|
|||||||
@@ -68,23 +68,31 @@ class ChapterModel extends MongoModel
|
|||||||
* @param integer $intNId
|
* @param integer $intNId
|
||||||
* @return null|array
|
* @return null|array
|
||||||
*/
|
*/
|
||||||
public function getChapterAll(array $arrFilter, array $arrOptions = []): null|array
|
public function getChapterAll(array $arrFilter, int $intCount = 10, array $arrSort = ['c_sort_num' => -1], bool $boolReadContent = false): null|array
|
||||||
{
|
{
|
||||||
// $arrFilter = ['n_id' => $intNId, 'c_page' => 0];
|
// $arrFilter = ['n_id' => $intNId, 'c_page' => 0];
|
||||||
|
|
||||||
// $arrOptions = self::$arrChapterOptions;
|
$arrOptions = self::$arrChapterOptions;
|
||||||
|
|
||||||
// $arrOptions['sort'] = ['c_sort_num' => -1];
|
$arrOptions['sort'] = $arrSort;
|
||||||
|
|
||||||
// $arrChapter = $this->getOne($arrFilter, $arrOptions);
|
$arrOptions['limit'] = $intCount;
|
||||||
|
|
||||||
// if (!empty($arrChapter)) {
|
$arrFilter = [];
|
||||||
// applyToKeys($arrChapter, ['created_at', 'updated_at'], 'formatMongoDate');
|
|
||||||
|
|
||||||
// $arrChapter['content'] = StorageCore::getInstance()->read($arrChapter['c_content_path']);
|
$Cursor = $this->getCol()->find($arrFilter, $arrOptions);
|
||||||
// }
|
|
||||||
|
|
||||||
|
$arrResult = iterator_to_array($Cursor);
|
||||||
|
|
||||||
// return $arrChapter;
|
foreach ($arrResult as &$arrItem) {
|
||||||
|
|
||||||
|
applyToKeys($arrItem, ['created_at', 'updated_at'], 'formatMongoDate');
|
||||||
|
$arrItem['content'] = '';
|
||||||
|
if ($boolReadContent) {
|
||||||
|
$arrItem['content'] = StorageCore::getInstance()->read($arrItem['c_content_path']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $arrResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,30 @@ class NovelModel extends MongoModel
|
|||||||
*/
|
*/
|
||||||
protected $strCollection = 'novel';
|
protected $strCollection = 'novel';
|
||||||
|
|
||||||
|
static public $arrNovelOptions = [
|
||||||
|
'typeMap' => [
|
||||||
|
'root' => 'array',
|
||||||
|
'document' => 'array',
|
||||||
|
'array' => 'array',
|
||||||
|
],
|
||||||
|
'projection' => [
|
||||||
|
'_id' => 0,
|
||||||
|
'og_title' => 0,
|
||||||
|
'n_site_name' => 0,
|
||||||
|
'n_site_code' => 0,
|
||||||
|
'n_site_uuid' => 0,
|
||||||
|
'n_source_id' => 0,
|
||||||
|
'n_page_title' => 0,
|
||||||
|
'og_description' => 0,
|
||||||
|
'og_novel_latest_chapter_name' => 0,
|
||||||
|
'og_image' => 0,
|
||||||
|
'og_novel_latest_chapter_url' => 0,
|
||||||
|
'og_novel_read_url' => 0,
|
||||||
|
'og_type' => 0,
|
||||||
|
'og_url' => 0,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据关键词数组更新小说推荐等级
|
* 根据关键词数组更新小说推荐等级
|
||||||
* @param array $arrKeywords 关键词数组,例如 ["斗罗", "遮天", "凡人"]
|
* @param array $arrKeywords 关键词数组,例如 ["斗罗", "遮天", "凡人"]
|
||||||
@@ -53,29 +77,36 @@ class NovelModel extends MongoModel
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public $arrNovelOptions = [
|
/**
|
||||||
'typeMap' => [
|
* Undocumented function
|
||||||
'root' => 'array',
|
*
|
||||||
'document' => 'array',
|
* @param integer $intNId
|
||||||
'array' => 'array',
|
* @return null|array
|
||||||
],
|
*/
|
||||||
'projection' => [
|
public function getNovelAll(array $arrFilter, int $intCount = 10, array $arrSort = []): null|array
|
||||||
'_id' => 0,
|
{
|
||||||
'og_title' => 0,
|
// $arrFilter = ['n_id' => $intNId, 'c_page' => 0];
|
||||||
'n_site_name' => 0,
|
|
||||||
'n_site_code' => 0,
|
$arrOptions = self::$arrNovelOptions;
|
||||||
'n_site_uuid' => 0,
|
|
||||||
'n_source_id' => 0,
|
$arrOptions['sort'] = $arrSort;
|
||||||
'n_page_title' => 0,
|
|
||||||
'og_description' => 0,
|
$arrOptions['limit'] = $intCount;
|
||||||
'og_novel_latest_chapter_name' => 0,
|
|
||||||
'og_image' => 0,
|
$arrFilter = [];
|
||||||
'og_novel_latest_chapter_url' => 0,
|
|
||||||
'og_novel_read_url' => 0,
|
$Cursor = $this->getCol()->find($arrFilter, $arrOptions);
|
||||||
'og_type' => 0,
|
|
||||||
'og_url' => 0,
|
$arrResult = iterator_to_array($Cursor);
|
||||||
],
|
|
||||||
];
|
foreach ($arrResult as &$arrItem) {
|
||||||
|
|
||||||
|
applyToKeys($arrItem, ['created_at', 'updated_at'], 'formatMongoDate');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $arrResult;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Undocumented function
|
||||||
@@ -89,9 +120,6 @@ class NovelModel extends MongoModel
|
|||||||
$arrOptions = self::$arrNovelOptions;
|
$arrOptions = self::$arrNovelOptions;
|
||||||
$arrNovel = $this->getOne($arrFilter, $arrOptions);
|
$arrNovel = $this->getOne($arrFilter, $arrOptions);
|
||||||
applyToKeys($arrNovel, ['created_at', 'updated_at'], 'formatMongoDate');
|
applyToKeys($arrNovel, ['created_at', 'updated_at'], 'formatMongoDate');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $arrNovel;
|
return $arrNovel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user