debug
This commit is contained in:
@@ -41,4 +41,7 @@ Route::group("/novel", function () {
|
||||
Route::group("/site", function () {
|
||||
Route::get("/domain/list", [Domain::class, "getDomainList"])->name("Domain@getDomainList");
|
||||
Route::post("/domain/upload", [Domain::class, "uploadDomain"])->name("Domain@uploadDomain");
|
||||
|
||||
|
||||
Route::get("/tkdarg/list", [Domain::class, "getTKDArgList"])->name("Domain@getDomainList");
|
||||
})->middleware(AdminAuth::class);
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace app\admin\controller;
|
||||
|
||||
use app\admin\BaseController;
|
||||
use app\model\AdminUserModel;
|
||||
use app\model\ConverterMovel;
|
||||
use app\model\DomainModel;
|
||||
use app\Request;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
@@ -14,6 +15,19 @@ use think\Response;
|
||||
class Domain extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* upload site domain info file
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function getTKDArgList(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
return $this->success(ConverterMovel::$arrDescription);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* upload site domain info file
|
||||
*
|
||||
|
||||
@@ -82,8 +82,6 @@ class Novel extends BaseController
|
||||
$intTotal = $Col->countDocuments($arrFilter);
|
||||
|
||||
$arrResult = [
|
||||
'code' => 200,
|
||||
'msg' => '查询成功',
|
||||
'data' => $arrData,
|
||||
'total' => $intTotal,
|
||||
'page' => $intPage,
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace app\home;
|
||||
|
||||
use app\model\ConverterMovel;
|
||||
use think\App;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\View;
|
||||
@@ -54,8 +55,32 @@ abstract class BaseController
|
||||
// View::assign('')
|
||||
}
|
||||
|
||||
// 初始化
|
||||
protected function initialize() {}
|
||||
/**
|
||||
* 初始化
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
|
||||
$this->initSiteTKD();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化网站基本信息到全局替换类里
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function initSiteTKD()
|
||||
{
|
||||
ConverterMovel::setVal([
|
||||
'strSiteTitle' => $this->request->DomainModel->d_title,
|
||||
'strSiteKeywords' => $this->request->DomainModel->d_keywords,
|
||||
'strSiteDescription' => $this->request->DomainModel->d_description,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 验证数据
|
||||
|
||||
@@ -40,18 +40,18 @@ Route::get('/pc/nvsheng-xiaoshuo', [Novel::class, 'getNovelChannel'])->append([
|
||||
*/
|
||||
Route::get('/shuku/all', [Novel::class,'getLibrary'])->append(['boolIsMobile' => true]);
|
||||
Route::get('/pc/shuku/all', [Novel::class,'getLibrary'])->append(['boolIsMobile' => false]);
|
||||
Route::get('/shuku/:strNovelChannel-:strCategory-:strStatus-:intPage', [Novel::class,'getLibrary'])
|
||||
Route::get('/shuku/:intGender-:strCategory-:strStatus-:intPage', [Novel::class,'getLibrary'])
|
||||
->pattern([
|
||||
'strNovelChannel' => '[\w]*',
|
||||
'intGender' => '\d{1}',
|
||||
'strCategory' => '[\w]*',
|
||||
'strStatus' => '[\w]*',
|
||||
'intPage' => '\d+'
|
||||
])
|
||||
->append(['boolIsMobile' => true]);
|
||||
|
||||
Route::get('/pc/shuku/:strNovelChannel-:strCategory-:strStatus-:intPage', [Novel::class,'getLibrary'])
|
||||
Route::get('/pc/shuku/:intGender-:strCategory-:strStatus-:intPage', [Novel::class,'getLibrary'])
|
||||
->pattern([
|
||||
'strNovelChannel' => '[\w]*',
|
||||
'intGender' => '\d{1}',
|
||||
'strCategory' => '[\w]*',
|
||||
'strStatus' => '[\w]*',
|
||||
'intPage' => '\d+'
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace app\home\controller;
|
||||
|
||||
use app\home\BaseController;
|
||||
use app\model\ConverterMovel;
|
||||
use app\model\NovelModel;
|
||||
use storage\StorageCore;
|
||||
use think\facade\View;
|
||||
@@ -132,28 +133,28 @@ class Index extends BaseController
|
||||
|
||||
// 推荐等级为9的完结的 随机12个小说
|
||||
$arrRecommendEndNovel = $NovelModel->getFinishedNovelOnCache($Request->DomainModel->d_domain, 12);
|
||||
|
||||
|
||||
// 男生频道,最新的 随机5个小说
|
||||
$arrBoyNewsNovel = $NovelModel->getSexNovelOnCache($Request->DomainModel->d_domain, 5, 1);
|
||||
|
||||
|
||||
// 男生频道,周排行榜 随机10个小说
|
||||
$arrBoyWeekRankNovel = $NovelModel->getRankNovelOnCache($Request->DomainModel->d_domain, 5, 1, 'weekly');
|
||||
|
||||
// 男生频道,月排行榜 随机10个小说
|
||||
$arrBoyMoonRankNovel = $NovelModel->getRankNovelOnCache($Request->DomainModel->d_domain, 5, 1, 'monthly');
|
||||
|
||||
|
||||
// 男生频道,总排行榜 随机10个小说
|
||||
$arrBoyTotalRankNovel = $NovelModel->getRankNovelOnCache($Request->DomainModel->d_domain, 5, 1, 'total');
|
||||
|
||||
// 女生频道,最新的 随机5个小说
|
||||
$arrGirlNewsNovel = $NovelModel->getSexNovelOnCache($Request->DomainModel->d_domain, 5, 2);
|
||||
|
||||
|
||||
// 女生频道,周排行榜 随机10个小说
|
||||
$arrGirlWeekRankNovel = $NovelModel->getRankNovelOnCache($Request->DomainModel->d_domain, 5, 2, 'weekly');
|
||||
|
||||
// 女生频道,月排行榜 随机10个小说
|
||||
$arrGirlMoonRankNovel = $NovelModel->getRankNovelOnCache($Request->DomainModel->d_domain, 5, 2, 'monthly');
|
||||
|
||||
|
||||
// 女生频道,总排行榜 随机10个小说
|
||||
$arrBGirlTotalRankNovel = $NovelModel->getRankNovelOnCache($Request->DomainModel->d_domain, 5, 2, 'total');
|
||||
|
||||
@@ -176,11 +177,18 @@ class Index extends BaseController
|
||||
'strPageCode' => 'home'
|
||||
]);
|
||||
|
||||
|
||||
$strTitle = '最新小说网-{strSiteTitle}-{strSiteKeywords}';
|
||||
|
||||
$strTitle = ConverterMovel::convert($strTitle);
|
||||
|
||||
echo $strTitle;exit;
|
||||
|
||||
|
||||
if ($boolIsMobile) {
|
||||
return View::fetch();
|
||||
} else {
|
||||
return View::fetch('pc/index');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace app\home\controller;
|
||||
|
||||
use app\home\BaseController;
|
||||
use app\model\ConverterMovel;
|
||||
use app\model\NovelModel;
|
||||
use storage\StorageCore;
|
||||
use think\facade\View;
|
||||
@@ -124,16 +125,34 @@ class Novel extends BaseController
|
||||
* 书库
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param [type] $strNovelChannel 男生/女生 -拼音
|
||||
* @param [type] $strCategory 分类 -拼音
|
||||
* @param [type] $strStatus 连载/完结 -拼音
|
||||
* @param string $strNovelChannel 男生/女生 -拼音
|
||||
* @param string $strCategory 分类 -拼音
|
||||
* @param string $strStatus 连载/完结 -拼音
|
||||
* @param integer $intPage 分页
|
||||
* @return void
|
||||
*/
|
||||
public function getLibrary(Request $Request, $strNovelChannel = 'all', $strCategory = 'all', $strStatus = 'all',$intPage = 1)
|
||||
public function getLibrary(Request $Request) //, $strNovelChannel = 'all', $strCategory = 'all', $strStatus = 'all', $intPage = 1)
|
||||
{
|
||||
$boolIsMobile = $Request->param('boolIsMobile');
|
||||
|
||||
$intGender = (int)$Request->param('intGender',0);
|
||||
$strCategory = (string)$Request->param('strCategory');
|
||||
$strStatus = (string)$Request->param('strStatus');
|
||||
$intPage = (int)$Request->param('intPage');
|
||||
$intLimit = 20;
|
||||
$intLifeTime = 24 * 3600;
|
||||
|
||||
$NovelModel = new NovelModel;
|
||||
|
||||
$strKey = sprintf("Novel:Library:%s:%s:%s:%s", $intGender, $strCategory, $strStatus, $intPage);
|
||||
|
||||
// var_dump($intType);exit;
|
||||
$arrPage = $NovelModel->getCommonNovelPageOnCache($strKey, $intPage, $intLimit, $intLifeTime, $intGender, $strStatus);
|
||||
|
||||
// echo '<pre>';
|
||||
// print_r($arrPage);
|
||||
// exit;
|
||||
|
||||
// 模拟数据
|
||||
$arrNovel = [
|
||||
['n_id' => 1, 'name' => '小说1', 'author' => '作者1'],
|
||||
@@ -149,7 +168,7 @@ class Novel extends BaseController
|
||||
View::assign([
|
||||
'arrNovel' => $arrNovel,
|
||||
'strPageCode' => 'library',
|
||||
'strNovelChannel' => $strNovelChannel,
|
||||
'intGender' => $intGender,
|
||||
'strCategory' => $strCategory,
|
||||
'strStatus' => $strStatus,
|
||||
'intPage' => $intPage,
|
||||
@@ -210,7 +229,7 @@ class Novel extends BaseController
|
||||
$strStuatus = '连载中';
|
||||
|
||||
$arrRecommendSerializationNovel = $NovelModel->getCommonNovelOnCache($strKey, $intLifeTime, $intCount, $intType, $strStuatus);
|
||||
|
||||
|
||||
// 推荐等级为9的,完结的,男生频道/女生频道, 随机8个小说
|
||||
$strKey = sprintf('%s:PC:Novel:Channel:Hot:%s:%s', $Request->DomainModel->d_domain, $intType, 'Finish');
|
||||
$intCount = 8;
|
||||
@@ -222,7 +241,7 @@ class Novel extends BaseController
|
||||
$strKey = sprintf('%s:PC:Novel:Channel:Latest:%s', $Request->DomainModel->d_domain, $intType);
|
||||
$intCount = 20;
|
||||
$arrNewsUpdateNovel = $NovelModel->getCommonNovelOnCache($strKey, $intLifeTime, $intCount, $intType, NULL, ['og_novel_update_time' => -1]);
|
||||
|
||||
|
||||
View::assign([
|
||||
'arrRecommendSerializationNovel' => $arrRecommendSerializationNovel,
|
||||
'arrRecommendEndNovel' => $arrRecommendEndNovel,
|
||||
@@ -314,10 +333,14 @@ class Novel extends BaseController
|
||||
{
|
||||
$intNId = $Request->param('n_id');
|
||||
|
||||
|
||||
|
||||
$boolIsMobile = $Request->param('boolIsMobile');
|
||||
|
||||
|
||||
$strNovel = '斗罗大陆';
|
||||
|
||||
ConverterMovel::setVal("strNovelName",$strNovel);
|
||||
|
||||
|
||||
// 模拟数据-随机推荐数据10条
|
||||
$arrRecommendNovel = [
|
||||
['id' => 1, 'name' => '小说1', 'author' => '作者1'],
|
||||
@@ -336,6 +359,14 @@ class Novel extends BaseController
|
||||
// 最新要点->取新意章节, 随机提取一部分内容 大概150字数
|
||||
|
||||
|
||||
|
||||
|
||||
// $strTitle = '小说详情-{strNovelName}-xxxxx';
|
||||
|
||||
// $strTitle = ConverterMovel::convert($strTitle);
|
||||
|
||||
// echo $strTitle;exit;
|
||||
|
||||
View::assign([
|
||||
'arrRecommendNovel' => $arrRecommendNovel,
|
||||
'strPageCode' => 'boy'
|
||||
@@ -351,7 +382,7 @@ class Novel extends BaseController
|
||||
public function getNovelNewsChapter(Request $Request)
|
||||
{
|
||||
|
||||
|
||||
|
||||
$intNId = $Request->param('n_id');
|
||||
|
||||
|
||||
@@ -385,7 +416,7 @@ class Novel extends BaseController
|
||||
return View::fetch('pc/getNovelChapter');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 小说章节
|
||||
|
||||
@@ -29,28 +29,28 @@
|
||||
<!--选择搜索 开始-->
|
||||
<div class="find">
|
||||
<div class="opt">
|
||||
<div class="optCl" mod="search_channel">
|
||||
<div class="optCl" mod="search_channel">
|
||||
<span class="optTit">所属频道</span>
|
||||
<ul>
|
||||
<li><a class="on" href="/pc/shuku/all-{$strCategory}-{$strStatus}-1" btn="search_category">全部</a></li>
|
||||
<li><a href="/pc/shuku/nansheng-{$strCategory}-{$strStatus}-1" btn="search_category">男生</a></li>
|
||||
<li><a href="/pc/shuku/nvsheng-{$strCategory}-{$strStatus}-1" btn="search_category">女生</a></li>
|
||||
<li><a class="on" href="/pc/shuku/{$intGender}-{$strCategory}-{$strStatus}-{$intPage}.html" btn="search_category">全部</a></li>
|
||||
<li><a href="/pc/shuku/{$intGender}-{$strCategory}-{$strStatus}-{$intPage}" btn="search_category">男生</a></li>
|
||||
<li><a href="/pc/shuku/{$intGender}-{$strCategory}-{$strStatus}-{$intPage}" btn="search_category">女生</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="optCl" mod="search_channel">
|
||||
<span class="optTit">所属分类</span>
|
||||
<ul>
|
||||
<li><a class="on" href="/pc/shuku/{$strNovelChannel}-all-{$strStatus}-1" btn="search_category">全部</a></li>
|
||||
<li><a href="/pc/shuku/{$strNovelChannel}-dushixiuxian-{$strStatus}-1" btn="search_category">都市修仙</a></li>
|
||||
<li><a href="/pc/shuku/{$strNovelChannel}-xuanhuanxiuzhen-{$strStatus}-1" btn="search_category">玄幻修真</a></li>
|
||||
<li><a class="on" href="/pc/shuku/{$intGender}-{$strCategory}-{$strStatus}-{$intPage}" btn="search_category">全部</a></li>
|
||||
<li><a href="/pc/shuku/{$intGender}-{$strCategory}-{$strStatus}-{$intPage}" btn="search_category">都市修仙</a></li>
|
||||
<li><a href="/pc/shuku/{$intGender}-{$strCategory}-{$strStatus}-{$intPage}" btn="search_category">玄幻修真</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="optCl">
|
||||
<span class="optTit">是否完结</span>
|
||||
<ul>
|
||||
<li><a class="on" href="/pc/shuku/{$strNovelChannel}-{$strCategory}-all-1" btn="search_category">全部</a></li>
|
||||
<li><a href="/pc/shuku/{$strNovelChannel}-{$strCategory}-lianzai-1" btn="search_category">连载</a></li>
|
||||
<li><a href="/pc/shuku/{$strNovelChannel}-{$strCategory}-wanben-1" btn="search_category">完本</a></li>
|
||||
<li><a class="on" href="/pc/shuku/{$intGender}-{$strCategory}-{$strStatus}-{$intPage}" btn="search_category">全部</a></li>
|
||||
<li><a href="/pc/shuku/{$intGender}-{$strCategory}-{$strStatus}-{$intPage}" btn="search_category">连载</a></li>
|
||||
<li><a href="/pc/shuku/{$intGender}-{$strCategory}-{$strStatus}-{$intPage}" btn="search_category">完本</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -69,17 +69,17 @@
|
||||
<ul class="pagination">
|
||||
<li class="disabled"><span>«</span></li>
|
||||
<li class="active"><span>1</span></li>
|
||||
<li><a href="/pc/{$strNovelChannel}-{$strCategory}-{$strStatus}-2">2</a></li>
|
||||
<li><a href="/pc/{$strNovelChannel}-{$strCategory}-{$strStatus}-3">3</a></li>
|
||||
<li><a href="/pc/{$strNovelChannel}-{$strCategory}-{$strStatus}-4">4</a></li>
|
||||
<li><a href="/pc/{$strNovelChannel}-{$strCategory}-{$strStatus}-5">5</a></li>
|
||||
<li><a href="/pc/{$strNovelChannel}-{$strCategory}-{$strStatus}-6">6</a></li>
|
||||
<li><a href="/pc/{$strNovelChannel}-{$strCategory}-{$strStatus}-7">7</a></li>
|
||||
<li><a href="/pc/{$strNovelChannel}-{$strCategory}-{$strStatus}-8">8</a></li>
|
||||
<li><a href="/pc/{$intGender}-{$strCategory}-{$strStatus}-2">2</a></li>
|
||||
<li><a href="/pc/{$intGender}-{$strCategory}-{$strStatus}-3">3</a></li>
|
||||
<li><a href="/pc/{$intGender}-{$strCategory}-{$strStatus}-4">4</a></li>
|
||||
<li><a href="/pc/{$intGender}-{$strCategory}-{$strStatus}-5">5</a></li>
|
||||
<li><a href="/pc/{$intGender}-{$strCategory}-{$strStatus}-6">6</a></li>
|
||||
<li><a href="/pc/{$intGender}-{$strCategory}-{$strStatus}-7">7</a></li>
|
||||
<li><a href="/pc/{$intGender}-{$strCategory}-{$strStatus}-8">8</a></li>
|
||||
<li class="disabled"><span>...</span></li>
|
||||
<li><a href="/pc/{$strNovelChannel}-{$strCategory}-{$strStatus}-33">33</a></li>
|
||||
<li><a href="/pc/{$strNovelChannel}-{$strCategory}-{$strStatus}-34">34</a></li>
|
||||
<li><a href="/pc/{$strNovelChannel}-{$strCategory}-{$strStatus}-2">»</a></li>
|
||||
<li><a href="/pc/{$intGender}-{$strCategory}-{$strStatus}-33">33</a></li>
|
||||
<li><a href="/pc/{$intGender}-{$strCategory}-{$strStatus}-34">34</a></li>
|
||||
<li><a href="/pc/{$intGender}-{$strCategory}-{$strStatus}-2">»</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<!--页码切换 结束-->
|
||||
|
||||
81
code/app/model/ConverterMovel.php
Normal file
81
code/app/model/ConverterMovel.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use DateTime;
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class ConverterMovel
|
||||
{
|
||||
static private $arrMap = [
|
||||
'{strSiteTitle}' => '',
|
||||
'{strSiteKeywords}' => '',
|
||||
'{strSiteDescription}' => '',
|
||||
'{strNovelName}' => '',
|
||||
'{strNovelChapterName}' => '',
|
||||
'{strNovelCategoryName}' => '',
|
||||
];
|
||||
|
||||
static public $arrDescription = [
|
||||
'{strSiteTitle}' => '这个是网站标题',
|
||||
'{strSiteKeywords}' => '这个是网站关键字',
|
||||
'{strSiteDescription}' => '这个是网站描述',
|
||||
'{strNovelName}' => '当前页面小说标题',
|
||||
'{strNovelChapterName}' => '当前页面小说章节名字',
|
||||
'{strNovelCategoryName}' => '当前页面小说分类名字',
|
||||
];
|
||||
|
||||
static private function getKey($strKey): string
|
||||
{
|
||||
return '{' . $strKey . '}';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string|array $mixedKey 全局动态变量键或者数组
|
||||
* @param string $strVal 全局动态变量值
|
||||
* @return void
|
||||
*/
|
||||
static public function setVal(string | array $mixedKey, $strVal = NULL)
|
||||
{
|
||||
if (is_string($mixedKey)) {
|
||||
self::$arrMap[self::getKey($mixedKey)] = $strVal;
|
||||
} else if (is_array($mixedKey)) {
|
||||
foreach ($mixedKey as $strKey => $strVal) {
|
||||
if (key_exists(self::getKey($strKey), self::$arrMap)) {
|
||||
self::$arrMap[self::getKey($strKey)] = $strVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $strKey
|
||||
* @return void
|
||||
*/
|
||||
static public function getVal(string $strKey)
|
||||
{
|
||||
return self::$arrMap[self::getKey($strKey)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $strSubject
|
||||
* @return string
|
||||
*/
|
||||
static public function convert(string $strSubject): string
|
||||
{
|
||||
return str_replace(array_keys(self::$arrMap), array_values(self::$arrMap), $strSubject);
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,94 @@ 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 getCommonNovelPageOnCache(
|
||||
string $strKey,
|
||||
int $intPage = 1,
|
||||
int $intLimit = 20,
|
||||
int $intLifeTime = 24 * 3600,
|
||||
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,
|
||||
'skip' => ($intPage - 1) * $intLimit,
|
||||
'limit' => $intLimit,
|
||||
'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);
|
||||
$intTotal = $this->getCol()->countDocuments($arrFilter);
|
||||
|
||||
$arrResult = iterator_to_array($Cursor);
|
||||
|
||||
shuffle($arrResult);
|
||||
|
||||
$arrResult = [
|
||||
'data' => $arrResult,
|
||||
'total' => $intTotal,
|
||||
'page' => $intPage,
|
||||
'limit' => $intLimit,
|
||||
'pages' => ceil($intTotal / $intLimit)
|
||||
];
|
||||
|
||||
if (!empty($arrResult)) {
|
||||
Cache::set($strKey, $arrResult, $intLifeTime);
|
||||
}
|
||||
}
|
||||
|
||||
return $arrResult;
|
||||
} catch (\Exception $e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user