debug
This commit is contained in:
@@ -124,4 +124,15 @@ class CategoryModel extends MongoModel
|
||||
{
|
||||
return in_array($strName, self::$arrMan) ? 'man' : 'women';
|
||||
}
|
||||
|
||||
/**
|
||||
* determine the gender of the novel category
|
||||
*
|
||||
* @param string $strName
|
||||
* @return string
|
||||
*/
|
||||
static public function checkSexZh(string $strName): string
|
||||
{
|
||||
return in_array($strName, self::$arrMan) ? '男生' : '女生';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ class ChapterModel extends MongoModel
|
||||
* @param integer $intNId
|
||||
* @return null|array
|
||||
*/
|
||||
public function getLatestChapter(int $intNId): null|array
|
||||
public function getLatestChapter(int $intNId, bool $boolReadContent = true): null|array
|
||||
{
|
||||
$arrFilter = ['n_id' => $intNId, 'c_page' => 0];
|
||||
|
||||
@@ -135,8 +135,10 @@ class ChapterModel extends MongoModel
|
||||
|
||||
if (!empty($arrChapter)) {
|
||||
applyToKeys($arrChapter, ['created_at', 'updated_at'], 'formatMongoDate');
|
||||
|
||||
$arrChapter['content'] = StorageCore::getInstance()->read($arrChapter['c_content_path']);
|
||||
$arrChapter['content'] = '';
|
||||
if ($boolReadContent) {
|
||||
$arrChapter['content'] = StorageCore::getInstance()->read($arrChapter['c_content_path']);
|
||||
}
|
||||
}
|
||||
|
||||
return $arrChapter ?? [];
|
||||
|
||||
@@ -88,6 +88,7 @@ class NovelModel extends MongoModel
|
||||
|
||||
$arrOptions['limit'] = $intCount;
|
||||
|
||||
$arrFilter['n_have_chapter'] = 1;
|
||||
|
||||
$Cursor = $this->getCol()->find($arrFilter, $arrOptions);
|
||||
|
||||
@@ -110,14 +111,11 @@ class NovelModel extends MongoModel
|
||||
*/
|
||||
public function getNovelByNId(int $intNId): null|array
|
||||
{
|
||||
$arrFilter = ['n_id' => $intNId];
|
||||
$arrFilter = ['n_id' => $intNId, 'n_have_chapter' => 1];
|
||||
$arrOptions = self::$arrNovelOptions;
|
||||
$arrNovel = $this->getOne($arrFilter, $arrOptions);
|
||||
applyToKeys($arrNovel, ['created_at', 'updated_at'], 'formatMongoDate');
|
||||
if (!empty($arrNovel['og_novel_category'])) {
|
||||
$arrNovel['category_pinyin'] = CategoryModel::getPinYinByZh($arrNovel['og_novel_category']);
|
||||
$arrNovel['category_sex'] = CategoryModel::checkSex($arrNovel['og_novel_category']);
|
||||
}
|
||||
|
||||
|
||||
return $arrNovel;
|
||||
}
|
||||
@@ -141,6 +139,8 @@ class NovelModel extends MongoModel
|
||||
return $arrResult;
|
||||
}
|
||||
|
||||
$arrFilter['n_have_chapter'] = 1;
|
||||
|
||||
$pipeline = [
|
||||
['$match' => $arrFilter],
|
||||
['$sample' => ['size' => $intCount]]
|
||||
@@ -180,7 +180,7 @@ class NovelModel extends MongoModel
|
||||
$strStatus = NULL,
|
||||
array $arrSort = ['n_level' => -1]
|
||||
): array {
|
||||
$arrFilter = [];
|
||||
$arrFilter = ['n_have_chapter' => 1,];
|
||||
|
||||
switch ($intType) {
|
||||
case 1:
|
||||
@@ -219,6 +219,7 @@ class NovelModel extends MongoModel
|
||||
int $intLifeTime = 24 * 3600,
|
||||
): array {
|
||||
try {
|
||||
$arrFilter['n_have_chapter'] = 1;
|
||||
|
||||
$arrResult = $this->checkCacheByKey($strKey);
|
||||
if ($arrResult !== NULL) {
|
||||
@@ -295,7 +296,7 @@ class NovelModel extends MongoModel
|
||||
return $arrResult;
|
||||
}
|
||||
|
||||
$arrFilter = [];
|
||||
$arrFilter = ['n_have_chapter' => 1,];
|
||||
|
||||
switch ($intType) {
|
||||
case 1:
|
||||
@@ -362,12 +363,12 @@ class NovelModel extends MongoModel
|
||||
$intLifeTime = 24 * 3600;
|
||||
|
||||
$arrResult = $this->checkCacheByKey($strKey);
|
||||
|
||||
|
||||
if ($arrResult !== NULL) {
|
||||
return $arrResult;
|
||||
}
|
||||
|
||||
$arrFilter = [];
|
||||
$arrFilter = ['n_have_chapter' => 1,];
|
||||
switch ($intType) {
|
||||
case 1:
|
||||
$arrCategory = array_values(CategoryModel::getManCategory());
|
||||
@@ -398,10 +399,10 @@ class NovelModel extends MongoModel
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
|
||||
$Cursor = $this->getCol()->find($arrFilter, $arrOptions);
|
||||
$arrResult = iterator_to_array($Cursor);
|
||||
|
||||
|
||||
shuffle($arrResult);
|
||||
|
||||
$arrResult = array_slice($arrResult, 0, $intCount);
|
||||
@@ -435,6 +436,7 @@ class NovelModel extends MongoModel
|
||||
}
|
||||
$arrFilter = [
|
||||
'og_novel_status' => "已完结",
|
||||
'n_have_chapter' => 1,
|
||||
];
|
||||
|
||||
$arrOptions = [
|
||||
@@ -487,19 +489,16 @@ class NovelModel extends MongoModel
|
||||
if ($arrResult !== NULL) {
|
||||
return $arrResult;
|
||||
}
|
||||
|
||||
$arrFilter = ['n_have_chapter' => 1,];
|
||||
|
||||
if ($intType == 1) {
|
||||
$arrCategory = array_values(CategoryModel::getManCategory());
|
||||
$arrFilter = [
|
||||
'og_novel_category' => ['$in' => $arrCategory]
|
||||
];
|
||||
$arrFilter['og_novel_category'] = ['$in' => $arrCategory];
|
||||
} elseif ($intType == 2) {
|
||||
$arrCategory = array_values(CategoryModel::getWomenCategory());
|
||||
$arrFilter = [
|
||||
'og_novel_category' => ['$in' => $arrCategory]
|
||||
];
|
||||
} else {
|
||||
$arrFilter = [];
|
||||
}
|
||||
$arrFilter['og_novel_category'] = ['$in' => $arrCategory];
|
||||
}
|
||||
|
||||
$arrOptions = [
|
||||
'sort' => ['og_novel_update_time' => -1],
|
||||
|
||||
Reference in New Issue
Block a user