debug
This commit is contained in:
@@ -361,9 +361,9 @@ class Novel extends BaseController
|
||||
// 推荐小说
|
||||
$arrRelateveNId = array_column($arrNovel['n_related_novel'], 'n_id');
|
||||
|
||||
$arrRelateveNovel = $NovelModel->getNovel([
|
||||
$arrRelateveNovel = $NovelModel->getNovel(['n_id' => [
|
||||
'$in' => $arrRelateveNId,
|
||||
], 10);
|
||||
]], 10);
|
||||
|
||||
// echo '<pre>';
|
||||
// var_dump($arrNovel);exit;
|
||||
@@ -442,9 +442,9 @@ class Novel extends BaseController
|
||||
// 推荐小说
|
||||
$arrRelateveNId = array_column($arrNovel['n_related_novel'], 'n_id');
|
||||
|
||||
$arrRelateveNovel = $NovelModel->getNovel([
|
||||
$arrRelateveNovel = $NovelModel->getNovel(['n_id' => [
|
||||
'$in' => $arrRelateveNId,
|
||||
], 10);
|
||||
]], 10);
|
||||
// echo '<pre>';
|
||||
// var_dump($arrNovel);exit;
|
||||
|
||||
@@ -639,7 +639,7 @@ class Novel extends BaseController
|
||||
$strBaseUrl = sprintf('/pc/xiaoshuo/%s-%s/mulu/%s/{page}', $arrNovel['og_novel_pin_yin'], $intNId, $strOrder);
|
||||
$arrPaginator = CusteomPage02::generate($intPage, $arrPage['total'], $intLimit, $strBaseUrl, $intButtomNum);
|
||||
// echo '<pre>';
|
||||
|
||||
|
||||
// print_r($arrPage);
|
||||
// exit;
|
||||
// 章节目录
|
||||
|
||||
@@ -59,46 +59,43 @@ class ChapterModel extends MongoModel
|
||||
): array {
|
||||
try {
|
||||
|
||||
$arrResult = Cache::get($strKey);
|
||||
$arrResult = $this->checkCacheByKey($strKey);
|
||||
if ($arrResult !== NULL) {
|
||||
return $arrResult;
|
||||
}
|
||||
|
||||
// if (empty($arrResult)) {
|
||||
if (true) {
|
||||
$arrOptions = self::$arrChapterOptions;
|
||||
$arrOptions = self::$arrChapterOptions;
|
||||
|
||||
$arrOptions = array_merge($arrOptions, [
|
||||
'sort' => $arrSort,
|
||||
// 'limit' => $intCount * 3,
|
||||
'skip' => ($intPage - 1) * $intLimit,
|
||||
'limit' => $intLimit,
|
||||
]);
|
||||
$arrOptions = array_merge($arrOptions, [
|
||||
'sort' => $arrSort,
|
||||
// 'limit' => $intCount * 3,
|
||||
'skip' => ($intPage - 1) * $intLimit,
|
||||
'limit' => $intLimit,
|
||||
]);
|
||||
|
||||
|
||||
$Cursor = $this->getCol()->find($arrFilter, $arrOptions);
|
||||
$Cursor = $this->getCol()->find($arrFilter, $arrOptions);
|
||||
|
||||
$intTotal = $this->getCol()->countDocuments($arrFilter);
|
||||
$intTotal = $this->getCol()->countDocuments($arrFilter);
|
||||
|
||||
$arrResult = iterator_to_array($Cursor);
|
||||
$arrResult = iterator_to_array($Cursor);
|
||||
|
||||
if (!empty($arrResult)) {
|
||||
foreach($arrResult as &$arrChapter){
|
||||
applyToKeys($arrChapter, ['created_at', 'updated_at'], 'formatMongoDate');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$arrResult = [
|
||||
'data' => $arrResult,
|
||||
'total' => $intTotal,
|
||||
'page' => $intPage,
|
||||
'limit' => $intLimit,
|
||||
'pages' => ceil($intTotal / $intLimit)
|
||||
];
|
||||
|
||||
if (!empty($arrResult)) {
|
||||
Cache::set($strKey, $arrResult, $intLifeTime);
|
||||
if (!empty($arrResult)) {
|
||||
foreach ($arrResult as &$arrChapter) {
|
||||
applyToKeys($arrChapter, ['created_at', 'updated_at'], 'formatMongoDate');
|
||||
}
|
||||
}
|
||||
|
||||
$arrResult = [
|
||||
'data' => $arrResult,
|
||||
'total' => $intTotal,
|
||||
'page' => $intPage,
|
||||
'limit' => $intLimit,
|
||||
'pages' => ceil($intTotal / $intLimit)
|
||||
];
|
||||
|
||||
$this->setCacheByKey($strKey, $arrResult, $intLifeTime);
|
||||
|
||||
return $arrResult;
|
||||
} catch (\Exception $e) {
|
||||
return [];
|
||||
@@ -149,7 +146,7 @@ class ChapterModel extends MongoModel
|
||||
$arrChapter['content'] = StorageCore::getInstance()->read($arrChapter['c_content_path']);
|
||||
}
|
||||
|
||||
return $arrChapter??[];
|
||||
return $arrChapter ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,8 +157,6 @@ class ChapterModel extends MongoModel
|
||||
*/
|
||||
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];
|
||||
|
||||
$arrOptions = self::$arrChapterOptions;
|
||||
|
||||
$arrOptions['sort'] = $arrSort;
|
||||
@@ -173,7 +168,6 @@ class ChapterModel extends MongoModel
|
||||
$arrResult = iterator_to_array($Cursor);
|
||||
|
||||
foreach ($arrResult as &$arrItem) {
|
||||
|
||||
applyToKeys($arrItem, ['created_at', 'updated_at'], 'formatMongoDate');
|
||||
$arrItem['content'] = '';
|
||||
if ($boolReadContent) {
|
||||
|
||||
@@ -4,11 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use DateTime;
|
||||
|
||||
use Exception;
|
||||
use storage\StorageCore;
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
@@ -90,7 +88,6 @@ class NovelModel extends MongoModel
|
||||
|
||||
$arrOptions['limit'] = $intCount;
|
||||
|
||||
$arrFilter = [];
|
||||
|
||||
$Cursor = $this->getCol()->find($arrFilter, $arrOptions);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user