debug
This commit is contained in:
@@ -1,94 +0,0 @@
|
|||||||
<?php
|
|
||||||
declare (strict_types = 1);
|
|
||||||
|
|
||||||
namespace app;
|
|
||||||
|
|
||||||
use think\App;
|
|
||||||
use think\exception\ValidateException;
|
|
||||||
use think\Validate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 控制器基础类
|
|
||||||
*/
|
|
||||||
abstract class BaseController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Request实例
|
|
||||||
* @var \think\Request
|
|
||||||
*/
|
|
||||||
protected $request;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 应用实例
|
|
||||||
* @var \think\App
|
|
||||||
*/
|
|
||||||
protected $app;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否批量验证
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
protected $batchValidate = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 控制器中间件
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $middleware = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构造方法
|
|
||||||
* @access public
|
|
||||||
* @param App $app 应用对象
|
|
||||||
*/
|
|
||||||
public function __construct(App $app)
|
|
||||||
{
|
|
||||||
$this->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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -14,6 +14,7 @@ use storage\StorageCore;
|
|||||||
use think\facade\View;
|
use think\facade\View;
|
||||||
use app\Request;
|
use app\Request;
|
||||||
use app\task\crawler\zw630\page\ChapterPage;
|
use app\task\crawler\zw630\page\ChapterPage;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Calculation\Category;
|
||||||
use template\page\CusteomPage02;
|
use template\page\CusteomPage02;
|
||||||
|
|
||||||
class Novel extends BaseController
|
class Novel extends BaseController
|
||||||
@@ -417,13 +418,16 @@ class Novel extends BaseController
|
|||||||
$ChapterModel = new ChapterModel;
|
$ChapterModel = new ChapterModel;
|
||||||
$arrLatestChapter = $ChapterModel->getLatestChapter($intNId);
|
$arrLatestChapter = $ChapterModel->getLatestChapter($intNId);
|
||||||
|
|
||||||
|
$strFocus = '';
|
||||||
// 要点
|
// 要点
|
||||||
|
if ($arrLatestChapter) {
|
||||||
$strFocus = strip_tags($arrLatestChapter['content']);
|
$strFocus = strip_tags($arrLatestChapter['content']);
|
||||||
$intCount = mb_strlen($strFocus);
|
$intCount = mb_strlen($strFocus);
|
||||||
if ($intCount > 300) {
|
if ($intCount > 300) {
|
||||||
$intPos = mt_rand(0, $intCount - 300);
|
$intPos = mt_rand(0, $intCount - 300);
|
||||||
$strFocus = mb_substr($strFocus, $intPos, 300);
|
$strFocus = mb_substr($strFocus, $intPos, 300);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 最近五个章节
|
// 最近五个章节
|
||||||
$arrChapter = $ChapterModel->getChapterAll([
|
$arrChapter = $ChapterModel->getChapterAll([
|
||||||
@@ -552,13 +556,15 @@ class Novel extends BaseController
|
|||||||
$arrNextChapter = $ChapterModel->getNextChapter($arrChapter['n_id'], $arrChapter['c_sort_num'], $arrChapter['c_page']);
|
$arrNextChapter = $ChapterModel->getNextChapter($arrChapter['n_id'], $arrChapter['c_sort_num'], $arrChapter['c_page']);
|
||||||
|
|
||||||
|
|
||||||
// 缺少数据
|
// FIXME 分类:男生和女生所对应的分类,看导航展示
|
||||||
// 分类:男生和女生所对应的分类,看导航展示
|
// FIXED BY 已经修复
|
||||||
// 这个小说的 分类拼音
|
$arrCategoryAll = CategoryModel::$arrCategoryAll;
|
||||||
// 这个小说 是属于 女生还是男生
|
|
||||||
|
|
||||||
// echo '<pre>';
|
// FIXME 这个小说的 分类拼音
|
||||||
// var_dump($arrNovel);
|
// FIXED BY 已经修复
|
||||||
|
|
||||||
|
// FIXME 这个小说 是属于 女生还是男生
|
||||||
|
// FIXED BY 已经修复
|
||||||
|
|
||||||
View::assign([
|
View::assign([
|
||||||
'arrNovel' => $arrNovel,
|
'arrNovel' => $arrNovel,
|
||||||
|
|||||||
@@ -28,6 +28,33 @@ class CategoryModel extends MongoModel
|
|||||||
9 => '其他小说',
|
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 = [
|
static $arrCategoryPinYin = [
|
||||||
1 => 'xuanhuan-xiuzhen', // 玄幻-修真
|
1 => 'xuanhuan-xiuzhen', // 玄幻-修真
|
||||||
2 => 'junshi-xiaoshuo', // 军史-小说
|
2 => 'junshi-xiaoshuo', // 军史-小说
|
||||||
|
|||||||
@@ -121,6 +121,11 @@ class NovelModel extends MongoModel
|
|||||||
$arrOptions = self::$arrNovelOptions;
|
$arrOptions = self::$arrNovelOptions;
|
||||||
$arrNovel = $this->getOne($arrFilter, $arrOptions);
|
$arrNovel = $this->getOne($arrFilter, $arrOptions);
|
||||||
applyToKeys($arrNovel, ['created_at', 'updated_at'], 'formatMongoDate');
|
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;
|
return $arrNovel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user