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