diff --git a/code/app/BaseController.php b/code/app/BaseController.php deleted file mode 100644 index 025ed07..0000000 --- a/code/app/BaseController.php +++ /dev/null @@ -1,94 +0,0 @@ -app = $app; - $this->request = $this->app->request; - - // 控制器初始化 - $this->initialize(); - } - - // 初始化 - protected function initialize() - {} - - /** - * 验证数据 - * @access protected - * @param array $data 数据 - * @param string|array $validate 验证器名或者验证规则数组 - * @param array $message 提示信息 - * @param bool $batch 是否批量验证 - * @return array|string|true - * @throws ValidateException - */ - protected function validate(array $data, string|array $validate, array $message = [], bool $batch = false) - { - if (is_array($validate)) { - $v = new Validate(); - $v->rule($validate); - } else { - if (strpos($validate, '.')) { - // 支持场景 - [$validate, $scene] = explode('.', $validate); - } - $class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate); - $v = new $class(); - if (!empty($scene)) { - $v->scene($scene); - } - } - - $v->message($message); - - // 是否批量验证 - if ($batch || $this->batchValidate) { - $v->batch(true); - } - - return $v->failException(true)->check($data); - } - -} diff --git a/code/app/home/controller/Novel.php b/code/app/home/controller/Novel.php index 490b66f..2cce12a 100644 --- a/code/app/home/controller/Novel.php +++ b/code/app/home/controller/Novel.php @@ -14,6 +14,7 @@ use storage\StorageCore; use think\facade\View; use app\Request; use app\task\crawler\zw630\page\ChapterPage; +use PhpOffice\PhpSpreadsheet\Calculation\Category; use template\page\CusteomPage02; class Novel extends BaseController @@ -313,7 +314,7 @@ class Novel extends BaseController // } // } - + /** * 小说详情-kan * @@ -322,7 +323,7 @@ class Novel extends BaseController */ public function getKanNovelInfo(Request $Request) { - + $intNId = $Request->param('n_id'); $boolIsMobile = $Request->param('boolIsMobile'); @@ -372,7 +373,7 @@ class Novel extends BaseController // ConverterMovel::setVal("strNovelName", $strNovel); // $strTitle = $Request->DomainModel->getFomartSubject(getFomartSubjectKey(__METHOD__)); - + // $strTitle = ConverterMovel::convert($strTitle); View::assign([ @@ -417,12 +418,15 @@ class Novel extends BaseController $ChapterModel = new ChapterModel; $arrLatestChapter = $ChapterModel->getLatestChapter($intNId); + $strFocus = ''; // 要点 - $strFocus = strip_tags($arrLatestChapter['content']); - $intCount = mb_strlen($strFocus); - if ($intCount > 300) { - $intPos = mt_rand(0, $intCount - 300); - $strFocus = mb_substr($strFocus, $intPos, 300); + if ($arrLatestChapter) { + $strFocus = strip_tags($arrLatestChapter['content']); + $intCount = mb_strlen($strFocus); + if ($intCount > 300) { + $intPos = mt_rand(0, $intCount - 300); + $strFocus = mb_substr($strFocus, $intPos, 300); + } } // 最近五个章节 @@ -449,7 +453,7 @@ class Novel extends BaseController ConverterMovel::setVal("strNovelName", $strNovel); $strTitle = $Request->DomainModel->getFomartSubject(getFomartSubjectKey(__METHOD__)); - + $strTitle = ConverterMovel::convert($strTitle); View::assign([ @@ -552,13 +556,15 @@ class Novel extends BaseController $arrNextChapter = $ChapterModel->getNextChapter($arrChapter['n_id'], $arrChapter['c_sort_num'], $arrChapter['c_page']); - // 缺少数据 - // 分类:男生和女生所对应的分类,看导航展示 - // 这个小说的 分类拼音 - // 这个小说 是属于 女生还是男生 + // FIXME 分类:男生和女生所对应的分类,看导航展示 + // FIXED BY 已经修复 + $arrCategoryAll = CategoryModel::$arrCategoryAll; - // echo '
';
- // var_dump($arrNovel);
+ // FIXME 这个小说的 分类拼音
+ // FIXED BY 已经修复
+
+ // FIXME 这个小说 是属于 女生还是男生
+ // FIXED BY 已经修复
View::assign([
'arrNovel' => $arrNovel,
@@ -604,7 +610,7 @@ class Novel extends BaseController
['c_sort_num' => 1, 'name' => '第5章', 'created_at' => '作者1'],
['c_sort_num' => 1, 'name' => '第6章', 'created_at' => '作者1'],
-
+
];
View::assign([
diff --git a/code/app/model/CategoryModel.php b/code/app/model/CategoryModel.php
index 55fc671..2166ea6 100644
--- a/code/app/model/CategoryModel.php
+++ b/code/app/model/CategoryModel.php
@@ -28,6 +28,33 @@ class CategoryModel extends MongoModel
9 => '其他小说',
];
+ static $arrCategoryAll = [
+ 'man' => [
+ 'xuanhuan-xiuzhen' => '玄幻修真',
+ 'junshi-xiaoshuo' => '军史小说',
+ 'wangyou-xiaoshuo' => '网游小说',
+ 'kehuan-xiaoshuo' => '科幻小说',
+ ],
+ 'women' => [
+ 'zhongsheng-chuanyue' => '重生穿越',
+ 'dushi-xiaoshuo' => '都市小说',
+ 'lingyi-xiaoshuo' => '灵异小说',
+ 'yanqing-xiaoshuo' => '言情小说',
+ 'qita-xiaoshuo' => '其他小说',
+ ]
+ ];
+
+ /**
+ * Undocumented function
+ *
+ * @param string $strName
+ * @return string
+ */
+ static public function checkSex(string $strName): string
+ {
+ return in_array($strName, self::$arrMan) ? 'man' : 'women';
+ }
+
static $arrCategoryPinYin = [
1 => 'xuanhuan-xiuzhen', // 玄幻-修真
2 => 'junshi-xiaoshuo', // 军史-小说
diff --git a/code/app/model/NovelModel.php b/code/app/model/NovelModel.php
index a94f350..897fbc1 100644
--- a/code/app/model/NovelModel.php
+++ b/code/app/model/NovelModel.php
@@ -121,6 +121,11 @@ class NovelModel extends MongoModel
$arrOptions = self::$arrNovelOptions;
$arrNovel = $this->getOne($arrFilter, $arrOptions);
applyToKeys($arrNovel, ['created_at', 'updated_at'], 'formatMongoDate');
+ if (!empty($arrNovel['og_novel_category'])) {
+ $arrNovel['category_pinyin'] = CategoryModel::getPinYinByZh($arrNovel['og_novel_category']);
+ $arrNovel['category_sex'] = CategoryModel::checkSex($arrNovel['og_novel_category']);
+ }
+
return $arrNovel;
}