设计url

This commit is contained in:
make
2025-03-30 16:56:15 +08:00
14 changed files with 343 additions and 266 deletions

View File

@@ -53,6 +53,82 @@ class NovelModel extends MongoModel
return true;
}
/**
* Undocumented function
*
* @param string $strKey
* @param int $intLifeTime
* @param integer $intCount
* @param integer $intType
* @param string $strStatus
* @param array $arrSort
* @return array
*/
public function getCommonNovelOnCache(
string $strKey,
int $intLifeTime = 24 * 3600,
int $intCount = 10,
int $intType = 0,
$strStatus = NULL,
array $arrSort = ['n_level' => -1]
): array {
try {
$arrResult = Cache::get($strKey);
// if (empty($arrResult)) {
if (true) {
$arrFilter = [];
switch ($intType) {
case 1:
$arrCategory = array_values(CategoryModel::getManCategory());
$arrFilter['og_novel_category'] = ['$in' => $arrCategory];
break;
case 2:
$arrCategory = array_values(CategoryModel::getWomenCategory());
$arrFilter['og_novel_category'] = ['$in' => $arrCategory];
break;
}
if ($strStatus !== NULL) {
$arrFilter['og_novel_status'] = $strStatus;
}
$arrOptions = [
'sort' => $arrSort,
'limit' => $intCount * 3,
'projection' => [
'n_id' => 1,
'og_novel_book_name' => 1,
'og_novel_pin_yin' => 1,
'n_cover_path' => 1,
'og_novel_author' => 1,
'og_novel_category' => 1,
'og_description' => 1,
'og_novel_latest_chapter_name' => 1,
'og_novel_update_time' => 1,
],
];
$Cursor = $this->getCol()->find($arrFilter, $arrOptions);
$arrResult = iterator_to_array($Cursor);
shuffle($arrResult);
$arrResult = array_slice($arrResult, 0, $intCount);
if (!empty($arrResult)) {
Cache::set($strKey, $arrResult, $intLifeTime);
}
}
return $arrResult;
} catch (\Exception $e) {
return [];
}
}
/**
* Undocumented function
@@ -63,7 +139,7 @@ class NovelModel extends MongoModel
* @param integer $intLevel
* @return array
*/
public function getHighLevelNovelOnCache(string $strSign, int $intCount = 10, int $intType = 0): array
public function getHighLevelNovelOnCache(string $strSign, int $intCount = 10, int $intType = 0, $strStatus = NULL): array
{
try {
$strKey = sprintf('%s:PC:HOME:FIRST', $strSign);
@@ -74,18 +150,21 @@ class NovelModel extends MongoModel
// if (empty($arrResult)) {
if (true) {
if ($intType == 1) {
$arrCategory = array_values(CategoryModel::getManCategory());
$arrFilter = [
'og_novel_category' => ['$in' => $arrCategory]
];
} elseif ($intType == 2) {
$arrCategory = array_values(CategoryModel::getWomenCategory());
$arrFilter = [
'og_novel_category' => ['$in' => $arrCategory]
];
} else {
$arrFilter = [];
$arrFilter = [];
switch ($intType) {
case 1:
$arrCategory = array_values(CategoryModel::getManCategory());
$arrFilter['og_novel_category'] = ['$in' => $arrCategory];
break;
case 2:
$arrCategory = array_values(CategoryModel::getWomenCategory());
$arrFilter['og_novel_category'] = ['$in' => $arrCategory];
break;
}
if ($strStatus !== NULL) {
$arrFilter['og_novel_status'] = $strStatus;
}
$arrOptions = [