From 06ba3c8411a839a1d3e358c943db144c458d09a7 Mon Sep 17 00:00:00 2001 From: Default Date: Tue, 22 Apr 2025 17:52:48 +0800 Subject: [PATCH] fix get static config --- code/app/services/ChapterService.php | 14 ++----- code/app/services/NovelService.php | 57 +++++++--------------------- code/app/services/SiteContext.php | 7 +--- code/app/services/StaticConfig.php | 38 +++++++++++++++++++ 4 files changed, 58 insertions(+), 58 deletions(-) create mode 100644 code/app/services/StaticConfig.php diff --git a/code/app/services/ChapterService.php b/code/app/services/ChapterService.php index be49bfa..1959b58 100644 --- a/code/app/services/ChapterService.php +++ b/code/app/services/ChapterService.php @@ -38,12 +38,6 @@ class ChapterService $this->ChapterModel = ChapterModel::getInstance(); } - public $arrSortType = [ - 'zheng' => '正序', - 'dao' => '倒叙', - ]; - - /** * 获取小说数据 * @@ -129,7 +123,7 @@ class ChapterService 'func' => (string)($arrParams['func']), ]; - if (!in_array($arrParams['sort_type'], array_keys($this->arrSortType))) { + if (!in_array($arrParams['sort_type'], array_keys(StaticConfig::$arrChapterSortType))) { $arrParams['sort_type'] = 'zheng'; } @@ -225,12 +219,12 @@ class ChapterService { // 小说详情 $arrNovel = $this->NovelModel->getNovelByNId($intNId); - + $ChapterModel = ChapterModel::getInstance(); - if($intCSortNum == 0 && $intCPage == 0){ + if ($intCSortNum == 0 && $intCPage == 0) { // 最新章节 $arrChapter = $ChapterModel->getLatestChapterByNId($intNId); - }else{ + } else { // 章节 $arrFilter = ['n_id' => $intNId, 'c_sort_num' => $intCSortNum, 'c_page' => $intCPage]; $arrChapter = $ChapterModel->findOne($arrFilter); diff --git a/code/app/services/NovelService.php b/code/app/services/NovelService.php index 1eb2a45..ff9e4e0 100644 --- a/code/app/services/NovelService.php +++ b/code/app/services/NovelService.php @@ -236,32 +236,6 @@ class NovelService } - public $arrSortType = [ - 'all' => '全部排序', - 'news' => '最新入库', - 'tuijian' => '推荐', - 'update' => '最新更新', - ]; - - static $arrRankSortType = [ - 'daily' => '天', - 'weekly' => '周', - 'monthly' => '月', - 'total' => '总', - ]; - - public $arrStatus = [ - 'all' => '所有', - 'lianzai' => '连载中', - 'wanjie' => '已完结', - ]; - - public $arrSex = [ - 'all' => '所有', - 'man' => '男生', - 'women' => '女生', - ]; - /** * GetCategoryFilter @@ -300,10 +274,10 @@ class NovelService if (!empty($strNStatus)) { switch ($strNStatus) { case 'lianzai': - $arrFilter['n_status'] = $this->arrStatus[$strNStatus]; + $arrFilter['n_status'] = StaticConfig::$arrNovelStatus[$strNStatus]; break; case 'wanjie': - $arrFilter['n_status'] = $this->arrStatus[$strNStatus]; + $arrFilter['n_status'] = StaticConfig::$arrNovelStatus[$strNStatus]; break; } } @@ -400,10 +374,10 @@ class NovelService if (!empty($strNStatus)) { switch ($strNStatus) { case 'lianzai': - $arrFilter['n_status'] = $this->arrStatus[$strNStatus]; + $arrFilter['n_status'] = StaticConfig::$arrNovelStatus[$strNStatus]; break; case 'wanjie': - $arrFilter['n_status'] = $this->arrStatus[$strNStatus]; + $arrFilter['n_status'] = StaticConfig::$arrNovelStatus[$strNStatus]; break; } } @@ -412,10 +386,10 @@ class NovelService if (!empty($strNSex)) { switch ($strNSex) { case 'man': - $arrFilter['n_category_sex_zh'] = $this->arrSex[$strNSex]; + $arrFilter['n_category_sex_zh'] = StaticConfig::$arrNovelSex[$strNSex]; break; case 'women': - $arrFilter['n_category_sex_zh'] = $this->arrSex[$strNSex]; + $arrFilter['n_category_sex_zh'] = StaticConfig::$arrNovelSex[$strNSex]; break; } } @@ -521,10 +495,10 @@ class NovelService if (!empty($strNStatus)) { switch ($strNStatus) { case 'lianzai': - $arrFilter['$and'][] = ['n_status' => $this->arrStatus[$strNStatus]]; + $arrFilter['$and'][] = ['n_status' => StaticConfig::$arrNovelStatus[$strNStatus]]; break; case 'wanjie': - $arrFilter['$and'][] = ['n_status' => $this->arrStatus[$strNStatus]]; + $arrFilter['$and'][] = ['n_status' => StaticConfig::$arrNovelStatus[$strNStatus]]; break; default: $arrParams['n_status'] = 'all'; @@ -536,10 +510,10 @@ class NovelService if (!empty($strNSex)) { switch ($strNSex) { case 'man': - $arrFilter['$and'][] = ['n_category_sex_zh' => $this->arrSex[$strNSex]]; + $arrFilter['$and'][] = ['n_category_sex_zh' => StaticConfig::$arrNovelSex[$strNSex]]; break; case 'women': - $arrFilter['$and'][] = ['n_category_sex_zh' => $this->arrSex[$strNSex]]; + $arrFilter['$and'][] = ['n_category_sex_zh' => StaticConfig::$arrNovelSex[$strNSex]]; break; default: $arrParams['n_sex'] = 'all'; @@ -605,16 +579,16 @@ class NovelService $strNanUrlTemp = $this->SiteContext->DomainModel->getFomartSubject('NAN_SHENG_URL', '', false); $strNanUrl = str_replace("/", "", $strNanUrlTemp); $strCNSex = '全部'; - if($strGender){ + if ($strGender) { $strCNSex = $strGender == $strNanUrl ? '男生' : '女生'; } ConverterMovel::setVal([ 'intPage' => $intPage, 'strNovelSex' => $strCNSex, 'strNovelCategoryName' => empty($strNCategory) ? '' : str_replace("小说", "", $strNCategory), - 'strNovelStatus' => empty($strNStatus) ? '' : $this->arrStatus[$strNStatus], - 'strNovelOrder' => empty($strSortType) ? '' :$this->arrSortType[$strSortType], - 'strSearchKeywords' => $strKey, + 'strNovelStatus' => empty($strNStatus) ? '' : StaticConfig::$arrNovelStatus[$strNStatus], + 'strNovelOrder' => empty($strSortType) ? '' : StaticConfig::$arrNovelSortType[$strSortType], + 'strSearchKeywords' => $strKey, ]); if (empty($arrFilter['$and'])) { @@ -761,7 +735,4 @@ class NovelService return $arrNovel; } - - - } diff --git a/code/app/services/SiteContext.php b/code/app/services/SiteContext.php index eb98334..010514e 100644 --- a/code/app/services/SiteContext.php +++ b/code/app/services/SiteContext.php @@ -314,11 +314,8 @@ class SiteContext $strStatus = $this->Request->param('strStatus'); ConverterMovel::setVal([ 'intPage' => 1, - 'strNovelOrder' => NovelService::$arrRankSortType[$strOrder] , - 'strNovelStatus' => NovelService::$arrStatus[$strStatus] , + 'strNovelOrder' => StaticConfig::$arrNovelRankSortType[$strOrder], + 'strNovelStatus' => StaticConfig::$arrNovelStatus[$strStatus], ]); } - - - } diff --git a/code/app/services/StaticConfig.php b/code/app/services/StaticConfig.php new file mode 100644 index 0000000..39ad6b8 --- /dev/null +++ b/code/app/services/StaticConfig.php @@ -0,0 +1,38 @@ + '全部排序', + 'news' => '最新入库', + 'tuijian' => '推荐', + 'update' => '最新更新', + ]; + + static $arrNovelRankSortType = [ + 'daily' => '天', + 'weekly' => '周', + 'monthly' => '月', + 'total' => '总', + ]; + + static $arrNovelStatus = [ + 'all' => '所有', + 'lianzai' => '连载中', + 'wanjie' => '已完结', + ]; + + static $arrNovelSex = [ + 'all' => '所有', + 'man' => '男生', + 'women' => '女生', + ]; + + static $arrChapterSortType = [ + 'zheng' => '正序', + 'dao' => '倒叙', + ]; +}