Merge branch 'dev' of ssh://git.bgbg.live:18150/root/SEONexus into dev
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 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 '<pre>';
|
||||
// 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([
|
||||
|
||||
@@ -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', // 军史-小说
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user