debug
This commit is contained in:
36
code/app/admin/AdminServiceProvider.php
Normal file
36
code/app/admin/AdminServiceProvider.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin;
|
||||
|
||||
use app\admin\model\AdminUserModel;
|
||||
use app\admin\service\AdminUserAuth;
|
||||
use app\Request;
|
||||
use think\Container;
|
||||
|
||||
class AdminServiceProvider extends \think\Service
|
||||
{
|
||||
/**
|
||||
* 注册服务
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
|
||||
Container::getInstance()->bind(AdminUserModel::class, function (Request $Request) {
|
||||
return AdminUserModel::getUserByToken($Request->header("admin-token"));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行服务
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
107
code/app/admin/BaseController.php
Normal file
107
code/app/admin/BaseController.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin;
|
||||
|
||||
use app\admin\middleware\AdminResponse;
|
||||
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, $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);
|
||||
}
|
||||
|
||||
|
||||
public function success($arrData = [], $strMsg = "", $strCode = "1000")
|
||||
{
|
||||
return AdminResponse::create($strCode, $strMsg, $arrData);
|
||||
}
|
||||
|
||||
public function error($strCode = "9999", $strMsg = "", $arrData = [])
|
||||
{
|
||||
return AdminResponse::create($strCode, $strMsg, $arrData);
|
||||
}
|
||||
}
|
||||
38
code/app/admin/config/error.php
Normal file
38
code/app/admin/config/error.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
return [
|
||||
#用户组
|
||||
'1000' => '成功',
|
||||
|
||||
'1001' => '用户不存在!',
|
||||
'1002' => '密码错误!',
|
||||
'1003' => '用户名不能为空!',
|
||||
'1004' => '密码不能为空!',
|
||||
|
||||
#权限节点组
|
||||
'1011' => '权限节点路径不能为空!',
|
||||
'1012' => '权限节点名不能为空!',
|
||||
'1013' => '权限节点是否显示不能为空!',
|
||||
'1014' => '权限节点ID不能为空!',
|
||||
'1015' => '权限节点集合不能为空!',
|
||||
'1016' => '该部门下存在成员无法删除!',
|
||||
'1017' => '角色名不能为空!',
|
||||
'1018' => '角色ID不能为空!',
|
||||
|
||||
|
||||
|
||||
#其他组
|
||||
'9900' => '参数错误!',
|
||||
'9901' => '获取PHP程序位置失败!',
|
||||
'9991' => '你没有这个权限!',
|
||||
'9992' => '远程密钥错误!',
|
||||
'9993' => '未查询到相关数据!',
|
||||
'9994' => '信息输入有误!',
|
||||
'9995' => '请先登录!',
|
||||
'9996' => '无效令牌!',
|
||||
'9997' => '地址错误!',
|
||||
'9998' => '请求对象未定义!',
|
||||
'9999' => '系统异常!',
|
||||
];
|
||||
60
code/app/admin/config/router.php
Normal file
60
code/app/admin/config/router.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use app\admin\middleware\AdminAuth;
|
||||
use think\facade\Route;
|
||||
|
||||
Route::group("/guest", function () {
|
||||
Route::post("/login", "Guest/Login")->name("Guest@Login");
|
||||
Route::post("/logout", "Guest/Logout")->name("Guest@Logout");
|
||||
});
|
||||
|
||||
|
||||
# 系统配置
|
||||
Route::group("/system", function () {
|
||||
Route::get("/user/info", "AdminUser/Info")->name("AdminUser@Info");
|
||||
Route::get("/user/list", "AdminUser/getAdminUserList")->name("AdminUser@getAdminUserList");
|
||||
Route::post("/user/save", "AdminUser/saveAdminUser")->name("AdminUser@saveAdminUser");
|
||||
Route::post("/user/del", "AdminUser/delAdminUser")->name("AdminUser@delAdminUser");
|
||||
|
||||
Route::get("/config/list", "SystemConfig/getSystemConfigList")->name("SystemConfig@getSystemConfigList");
|
||||
Route::post("/config/save", "SystemConfig/saveSystemConfig")->name("SystemConfig@saveSystemConfig");
|
||||
|
||||
Route::get("/cjpz/list", "SystemConfig/getCaiJiPeiZhiList")->name("SystemConfig@getCaiJiPeiZhiList");
|
||||
Route::post("/cjpz/save", "SystemConfig/saveCaiJiPeiZhi")->name("SystemConfig@saveCaiJiPeiZhi");
|
||||
|
||||
Route::get("/zydd/list", "SystemConfig/getZiYuanDuanDianList")->name("SystemConfig@getZiYuanDuanDianList");
|
||||
Route::post("/zydd/save", "SystemConfig/saveZiYuanDuanDian")->name("SystemConfig@saveZiYuanDuanDian");
|
||||
|
||||
Route::get("/plan/list", "SystemConfig/getPlanTaskList")->name("SystemConfig@getPlanTaskList");
|
||||
Route::post("/plan/save", "SystemConfig/savePlanTask")->name("SystemConfig@savePlanTask");
|
||||
|
||||
Route::get("/keyword/list", "SeoKeywords/getSeoKeywordList")->name("SeoKeywords@getSeoKeywordList");
|
||||
Route::post("/keyword/save", "SeoKeywords/saveSeoKeyword")->name("SeoKeywords@saveSeoKeyword");
|
||||
Route::post("/keyword/del", "SeoKeywords/delSeoKeyword")->name("SeoKeywords@delSeoKeyword");
|
||||
})->middleware(AdminAuth::class);
|
||||
|
||||
# 广告
|
||||
Route::group("/guanggao", function () {
|
||||
# 主
|
||||
Route::get("/main/group/list", "GuangGao/getGuangGaoFenZuList")->name("GuangGao@getGuangGaoFenZuList");
|
||||
Route::post("/main/group/save", "GuangGao/saveGuangGaoFenZu")->name("GuangGao@saveGuangGaoFenZu");
|
||||
Route::post("/main/group/del", "GuangGao/delGuangGaoFenZu")->name("GuangGao@delGuangGaoFenZu");
|
||||
Route::get("/main/list", "GuangGao/getGuangGaoList")->name("GuangGao@getGuangGaoList");
|
||||
Route::post("/main/save", "GuangGao/saveGuangGao")->name("GuangGao@saveGuangGao");
|
||||
Route::post("/main/del", "GuangGao/delGuangGao")->name("GuangGao@delGuangGao");
|
||||
|
||||
# 广告配置
|
||||
Route::get("/ggpz/list", "GuangGao/getGuangGaoPeiZhiList")->name("GuangGao@getGuangGaoPeiZhiList");
|
||||
Route::post("/ggpz/save", "GuangGao/saveGuangGaoPeiZhi")->name("GuangGao@saveGuangGaoPeiZhi");
|
||||
|
||||
})->middleware(AdminAuth::class);
|
||||
|
||||
# 小说
|
||||
Route::group("/xiaoshuo", function () {
|
||||
Route::get("/main/list", "XiaoShuo/getXiaoShuoList")->name("XiaoShuo@getXiaoShuoList");
|
||||
Route::get("/zhangjie/list", "XiaoShuo/getXiaoShuoZhangJieList")->name("XiaoShuo@getXiaoShuoZhangJieList");
|
||||
Route::get("/fenlei/list", "XiaoShuo/getXiaoShuoFenLeiList")->name("XiaoShuo@getXiaoShuoFenLeiList");
|
||||
})->middleware(AdminAuth::class);
|
||||
|
||||
153
code/app/admin/controller/AdminUser.php
Normal file
153
code/app/admin/controller/AdminUser.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\BaseController;
|
||||
use app\admin\model\AdminUserModel;
|
||||
use app\admin\service\AdminUserAuth;
|
||||
use app\Request;
|
||||
use think\facade\Cache;
|
||||
use think\Response;
|
||||
|
||||
class AdminUser extends BaseController
|
||||
{
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function Info(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrResult = [
|
||||
'admin_user' => $AdminUserModel,
|
||||
];
|
||||
|
||||
return $this->success($arrResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function getAdminUserList(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"page" => $Request->get('page', 1),
|
||||
"limit" => $Request->get('limit', 10),
|
||||
"key" => $Request->get('key'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'page' => 'require|number',
|
||||
'limit' => 'require|number',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$AdminUserModel = AdminUserModel::alias('au');
|
||||
|
||||
if (!empty($arrData['key'])) {
|
||||
$strKey = $arrData['key'];
|
||||
$AdminUserModel->where(function ($AdminUserModel) use ($strKey) {
|
||||
$AdminUserModel->whereOr([
|
||||
['au.au_name', 'like', "%" . $strKey . "%"],
|
||||
['au.au_id', 'like', "%" . $strKey . "%"],
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
$Paginate = $AdminUserModel->paginate([
|
||||
'list_rows' => $arrData['limit'],
|
||||
'page' => $arrData['page'],
|
||||
]);
|
||||
|
||||
$arrResult = [
|
||||
'items' => $Paginate->items(),
|
||||
'total' => $Paginate->total(),
|
||||
'current_page' => $Paginate->currentPage(),
|
||||
'total_pages' => $Paginate->lastPage(),
|
||||
];
|
||||
|
||||
return $this->success($arrResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置管理员
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function saveAdminUser(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"au_id" => $Request->post('au_id'),
|
||||
"au_status" => $Request->post('au_status'),
|
||||
"au_name" => $Request->post('au_name'),
|
||||
"au_pwd" => $Request->post('au_pwd'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
// 'au_id' => 'require',
|
||||
'au_status' => 'require',
|
||||
'au_name' => 'require',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
if ($arrData['au_id'] == NULL) {
|
||||
$AdminUserModel = new AdminUserModel;
|
||||
} else {
|
||||
$AdminUserModel = AdminUserModel::where('au_id', $arrData['au_id'])->find();
|
||||
|
||||
if (empty($AdminUserModel)) {
|
||||
return $this->error('9993');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($arrData['au_pwd']) && !empty($arrData['au_pwd'])) {
|
||||
$arrData['au_pwd'] = md5($arrData['au_pwd']);
|
||||
} else {
|
||||
unset($arrData['au_pwd']);
|
||||
}
|
||||
|
||||
$AdminUserModel->fill($arrData);
|
||||
|
||||
$AdminUserModel->save();
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除管理员
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function delAdminUser(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"au_id" => $Request->post('au_id'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'au_id' => 'require',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$arrData['au_id'] = explode(',', $arrData['au_id']);
|
||||
|
||||
AdminUserModel::whereIn('au_id', $arrData['au_id'])->delete();
|
||||
|
||||
|
||||
return $this->success();
|
||||
}
|
||||
}
|
||||
359
code/app/admin/controller/GuangGao.php
Normal file
359
code/app/admin/controller/GuangGao.php
Normal file
@@ -0,0 +1,359 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\BaseController;
|
||||
use app\admin\model\AdminUserModel;
|
||||
use app\admin\model\FenLeiModel;
|
||||
use app\admin\model\GuangGaoFenZuModel;
|
||||
use app\admin\model\GuangGaoModel;
|
||||
use app\admin\model\GuangGaoPeiZhiModel;
|
||||
use app\admin\model\NvYouModel;
|
||||
use app\admin\model\ShiPinModel;
|
||||
use app\Request;
|
||||
use think\Response;
|
||||
|
||||
class GuangGao extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 廣告分組列表
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function getGuangGaoFenZuList(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"page" => $Request->get('page', 1),
|
||||
"limit" => $Request->get('limit', 10),
|
||||
"key" => $Request->get('key'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'page' => 'require|number',
|
||||
'limit' => 'require|number',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$GuangGaoFenZuModel = GuangGaoFenZuModel::alias('ggfz');
|
||||
|
||||
if (!empty($arrData['key'])) {
|
||||
$strKey = $arrData['key'];
|
||||
$GuangGaoFenZuModel->where(function ($GuangGaoFenZuModel) use ($strKey) {
|
||||
$GuangGaoFenZuModel->whereOr([
|
||||
['ggfz.ggfz_name', 'like', "%" . $strKey . "%"],
|
||||
['ggfz.ggfz_id', 'like', "%" . $strKey . "%"],
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
$Paginate = $GuangGaoFenZuModel->paginate([
|
||||
'list_rows' => $arrData['limit'],
|
||||
'page' => $arrData['page'],
|
||||
]);
|
||||
|
||||
$arrResult = [
|
||||
'items' => $Paginate->items(),
|
||||
'total' => $Paginate->total(),
|
||||
'current_page' => $Paginate->currentPage(),
|
||||
'total_pages' => $Paginate->lastPage(),
|
||||
];
|
||||
|
||||
return $this->success($arrResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置广告分组
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function saveGuangGaoFenZu(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"ggfz_id" => $Request->post('ggfz_id'),
|
||||
"ggfz_code" => $Request->post('ggfz_code'),
|
||||
"ggfz_name" => $Request->post('ggfz_name'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
// 'ggfz_id' => 'require',
|
||||
'ggfz_code' => 'require',
|
||||
'ggfz_name' => 'require',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
if ($arrData['ggfz_id'] == NULL) {
|
||||
$GuangGaoFenZuModel = new GuangGaoFenZuModel;
|
||||
} else {
|
||||
$GuangGaoFenZuModel = GuangGaoFenZuModel::where('ggfz_id', $arrData['ggfz_id'])->find();
|
||||
|
||||
if (empty($GuangGaoFenZuModel)) {
|
||||
return $this->error('9993');
|
||||
}
|
||||
}
|
||||
|
||||
$GuangGaoFenZuModel->fill($arrData);
|
||||
|
||||
$GuangGaoFenZuModel->save();
|
||||
GuangGaoModel::flushCache();
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除广告分组
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function delGuangGaoFenZu(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"ggfz_id" => $Request->post('ggfz_id'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'ggfz_id' => 'require',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$arrData['ggfz_id'] = explode(',', $arrData['ggfz_id']);
|
||||
|
||||
GuangGaoFenZuModel::whereIn('ggfz_id', $arrData['ggfz_id'])->delete();
|
||||
|
||||
GuangGaoModel::whereIn('ggfz_id', $arrData['ggfz_id'])->delete();
|
||||
GuangGaoModel::flushCache();
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function getGuangGaoList(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"page" => $Request->get('page', 1),
|
||||
"limit" => $Request->get('limit', 10),
|
||||
"key" => $Request->get('key'),
|
||||
"ggfz_id" => $Request->get('ggfz_id'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'page' => 'require|number',
|
||||
'limit' => 'require|number',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$GuangGaoModel = GuangGaoModel::alias('gg')
|
||||
->leftJoin('guang_gao_fen_zu ggfz', 'ggfz.ggfz_id = gg.ggfz_id')
|
||||
->field(['gg.*', 'ggfz.ggfz_name'])
|
||||
->order('ggfz.ggfz_id','desc')
|
||||
->order('gg.gg_sort','desc');
|
||||
|
||||
if ($arrData['ggfz_id'] !== NULL) {
|
||||
$GuangGaoModel = $GuangGaoModel->where('gg.ggfz_id', $arrData['ggfz_id']);
|
||||
}
|
||||
|
||||
|
||||
if (!empty($arrData['key'])) {
|
||||
$strKey = $arrData['key'];
|
||||
$GuangGaoModel->where(function ($GuangGaoModel) use ($strKey) {
|
||||
$GuangGaoModel = $GuangGaoModel->whereOr([
|
||||
['gg.gg_wen_zi', 'like', "%" . $strKey . "%"],
|
||||
['gg.gg_id', 'like', "%" . $strKey . "%"],
|
||||
['ggfz.ggfz_name', 'like', "%" . $strKey . "%"],
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
$Paginate = $GuangGaoModel->paginate([
|
||||
'list_rows' => $arrData['limit'],
|
||||
'page' => $arrData['page'],
|
||||
]);
|
||||
|
||||
$arrResult = [
|
||||
'items' => $Paginate->items(),
|
||||
'total' => $Paginate->total(),
|
||||
'current_page' => $Paginate->currentPage(),
|
||||
'total_pages' => $Paginate->lastPage(),
|
||||
];
|
||||
|
||||
return $this->success($arrResult);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置广告
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function saveGuangGao(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"gg_id" => $Request->post('gg_id'),
|
||||
"ggfz_id" => $Request->post('ggfz_id'),
|
||||
"gg_lei_xing" => $Request->post('gg_lei_xing'),
|
||||
"gg_tu_pian" => $Request->post('gg_tu_pian'),
|
||||
"gg_wen_zi" => $Request->post('gg_wen_zi'),
|
||||
"gg_tiao_zhuan_di_zhi" => $Request->post('gg_tiao_zhuan_di_zhi'),
|
||||
"gg_sort" => $Request->post('gg_sort'),
|
||||
"gg_status" => $Request->post('gg_status'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
// 'gg_id' => 'require',
|
||||
'ggfz_id' => 'require',
|
||||
'gg_lei_xing' => 'require',
|
||||
'gg_status' => 'require',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
if ($arrData['gg_id'] == NULL) {
|
||||
$GuangGaoModel = new GuangGaoModel;
|
||||
} else {
|
||||
$GuangGaoModel = GuangGaoModel::where('gg_id', $arrData['gg_id'])->find();
|
||||
|
||||
if (empty($GuangGaoModel)) {
|
||||
return $this->error('9993');
|
||||
}
|
||||
}
|
||||
|
||||
$GuangGaoModel->fill($arrData);
|
||||
|
||||
$GuangGaoModel->save();
|
||||
GuangGaoModel::flushCache();
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除广告
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function delGuangGao(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"gg_id" => $Request->post('gg_id'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'gg_id' => 'require',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$arrData['gg_id'] = explode(',', $arrData['gg_id']);
|
||||
|
||||
GuangGaoModel::whereIn('gg_id', $arrData['gg_id'])->delete();
|
||||
|
||||
GuangGaoModel::flushCache();
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 广告配置列表
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function getGuangGaoPeiZhiList(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"page" => $Request->get('page', 1),
|
||||
"limit" => $Request->get('limit', 10),
|
||||
"key" => $Request->get('key'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'page' => 'require|number',
|
||||
'limit' => 'require|number',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$GuangGaoPeiZhiModel = GuangGaoPeiZhiModel::alias('ggpz');
|
||||
|
||||
if (!empty($arrData['key'])) {
|
||||
$strKey = $arrData['key'];
|
||||
$GuangGaoPeiZhiModel->where(function ($GuangGaoPeiZhiModel) use ($strKey) {
|
||||
$GuangGaoPeiZhiModel->whereOr([
|
||||
['ggpz.ggpz_code', 'like', "%" . $strKey . "%"],
|
||||
['ggpz.ggpz_id', 'like', "%" . $strKey . "%"],
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
$Paginate = $GuangGaoPeiZhiModel->paginate([
|
||||
'list_rows' => $arrData['limit'],
|
||||
'page' => $arrData['page'],
|
||||
]);
|
||||
|
||||
$arrResult = [
|
||||
'items' => $Paginate->items(),
|
||||
'total' => $Paginate->total(),
|
||||
'current_page' => $Paginate->currentPage(),
|
||||
'total_pages' => $Paginate->lastPage(),
|
||||
];
|
||||
|
||||
return $this->success($arrResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置广告配置
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function saveGuangGaoPeiZhi(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"ggpz_id" => $Request->post('ggpz_id'),
|
||||
"ggpz_val" => $Request->post('ggpz_val'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'ggpz_id' => 'require',
|
||||
'ggpz_val' => 'require',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$GuangGaoPeiZhiModel = GuangGaoPeiZhiModel::where('ggpz_id', $arrData['ggpz_id'])->find();
|
||||
|
||||
if (empty($GuangGaoPeiZhiModel)) {
|
||||
return $this->error('9993');
|
||||
}
|
||||
|
||||
$GuangGaoPeiZhiModel->fill($arrData);
|
||||
|
||||
$GuangGaoPeiZhiModel->save();
|
||||
|
||||
GuangGaoPeiZhiModel::flushCache();
|
||||
|
||||
return $this->success();
|
||||
}
|
||||
}
|
||||
70
code/app/admin/controller/Guest.php
Normal file
70
code/app/admin/controller/Guest.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\BaseController;
|
||||
use app\admin\model\AdminUserModel;
|
||||
use app\admin\service\AdminUserAuth;
|
||||
use app\Request;
|
||||
use think\facade\Cache;
|
||||
use think\Response;
|
||||
|
||||
class Guest extends BaseController
|
||||
{
|
||||
/**
|
||||
* 登录
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function Login(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"au_name" => $Request->post('au_name'),
|
||||
"au_pwd" => $Request->post('au_pwd'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'au_name' => 'require|max:25',
|
||||
'au_pwd' => 'require|min:6',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$arrData['au_pwd'] = md5(trim($arrData['au_pwd']));
|
||||
|
||||
$AdminUserModel = AdminUserModel::where('au_name', $arrData['au_name'])
|
||||
->where('au_pwd', $arrData['au_pwd'])
|
||||
->where('au_status', 0)
|
||||
->find();
|
||||
|
||||
if (empty($AdminUserModel)) {
|
||||
return $this->error("1002");
|
||||
}
|
||||
|
||||
$arrResult = [
|
||||
'admin-token' => $AdminUserModel->createToken(),
|
||||
];
|
||||
|
||||
return $this->success($arrResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function Logout(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$strToken = $Request->header("admin-token");
|
||||
|
||||
if ($strToken) {
|
||||
Cache::delete($strToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
154
code/app/admin/controller/SeoKeywords.php
Normal file
154
code/app/admin/controller/SeoKeywords.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\BaseController;
|
||||
use app\admin\model\AdminUserModel;
|
||||
use app\admin\model\BaoYangRuZhuModel;
|
||||
use app\admin\model\CaiJiPeiZhiModel;
|
||||
use app\admin\model\DaLiWanFanKuiModel;
|
||||
use app\admin\model\DaLiWanModel;
|
||||
use app\admin\model\GuanFangZiYingModel;
|
||||
use app\admin\model\LouFengModel;
|
||||
use app\admin\model\PlanTaskModel;
|
||||
use app\admin\model\SeoKeywordsModel;
|
||||
use app\admin\model\SystemConfigModel;
|
||||
use app\admin\model\ZiYuanDuanDianModel;
|
||||
use app\Request;
|
||||
use think\Response;
|
||||
|
||||
class SeoKeywords extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 系统配置列表
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function getSeoKeywordList(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"page" => $Request->get('page', 1),
|
||||
"limit" => $Request->get('limit', 10),
|
||||
"key" => $Request->get('key'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'page' => 'require|number',
|
||||
'limit' => 'require|number',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$SeoKeywordsModel = SeoKeywordsModel::alias('sw');
|
||||
|
||||
if (!empty($arrData['key'])) {
|
||||
$strKey = $arrData['key'];
|
||||
$SeoKeywordsModel->where(function ($SeoKeywordsModel) use ($strKey) {
|
||||
$SeoKeywordsModel->whereOr([
|
||||
['sw.sw_title', 'like', "%" . $strKey . "%"],
|
||||
['sw.sw_id', 'like', "%" . $strKey . "%"],
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
$Paginate = $SeoKeywordsModel->paginate([
|
||||
'list_rows' => $arrData['limit'],
|
||||
'page' => $arrData['page'],
|
||||
]);
|
||||
|
||||
$arrResult = [
|
||||
'items' => $Paginate->items(),
|
||||
'total' => $Paginate->total(),
|
||||
'current_page' => $Paginate->currentPage(),
|
||||
'total_pages' => $Paginate->lastPage(),
|
||||
];
|
||||
|
||||
return $this->success($arrResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置系统配置
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function saveSeoKeyword(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"sw_id" => $Request->post('sw_id'),
|
||||
"sw_title" => $Request->post('sw_title'),
|
||||
"sw_status" => $Request->post('sw_status'),
|
||||
"sw_html_path" => $Request->post('sw_html_path') ?? '',
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
// 'sw_id' => 'require',
|
||||
'sw_title' => 'require',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
if ($arrData['sw_id'] == NULL) {
|
||||
$SeoKeywordsModel = new SeoKeywordsModel;
|
||||
} else {
|
||||
$SeoKeywordsModel = SeoKeywordsModel::where('sw_id', $arrData['sw_id'])->find();
|
||||
|
||||
if (empty($SeoKeywordsModel)) {
|
||||
return $this->error('9993');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($arrData['sw_status']) && empty($arrData['sw_status']) && $arrData['sw_status'] != 0) {
|
||||
unset($arrData['sw_status']);
|
||||
}
|
||||
if (isset($arrData['sw_html_path']) && empty($arrData['sw_html_path'])) {
|
||||
unset($arrData['sw_html_path']);
|
||||
}
|
||||
|
||||
$SeoKeywordsModel->fill($arrData);
|
||||
|
||||
$SeoKeywordsModel->save();
|
||||
$strHtmlPath = $SeoKeywordsModel->sw_html_path;
|
||||
|
||||
if(!empty($strHtmlPath)){
|
||||
SeoKeywordsModel::flushCache($strHtmlPath);
|
||||
}
|
||||
|
||||
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param SeoKeywordsModel|null $SeoKeywordsModel
|
||||
* @return Response
|
||||
*/
|
||||
public function delSeoKeyword(Request $Request, ?SeoKeywordsModel $SeoKeywordsModel)
|
||||
{
|
||||
$arrData = [
|
||||
"sw_id" => $Request->post('sw_id'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'sw_id' => 'require',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$arrData['sw_id'] = explode(',', $arrData['sw_id']);
|
||||
|
||||
SeoKeywordsModel::whereIn('sw_id', $arrData['sw_id'])->delete();
|
||||
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
367
code/app/admin/controller/SystemConfig.php
Normal file
367
code/app/admin/controller/SystemConfig.php
Normal file
@@ -0,0 +1,367 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\BaseController;
|
||||
use app\admin\model\AdminUserModel;
|
||||
use app\admin\model\BaoYangRuZhuModel;
|
||||
use app\admin\model\CaiJiPeiZhiModel;
|
||||
use app\admin\model\DaLiWanFanKuiModel;
|
||||
use app\admin\model\DaLiWanModel;
|
||||
use app\admin\model\GuanFangZiYingModel;
|
||||
use app\admin\model\LouFengModel;
|
||||
use app\admin\model\PlanTaskModel;
|
||||
use app\admin\model\SystemConfigModel;
|
||||
use app\admin\model\ZiYuanDuanDianModel;
|
||||
use app\Request;
|
||||
use think\Response;
|
||||
|
||||
class SystemConfig extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 采集配置列表
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function getCaiJiPeiZhiList(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"page" => $Request->get('page', 1),
|
||||
"limit" => $Request->get('limit', 10),
|
||||
"key" => $Request->get('key'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'page' => 'require|number',
|
||||
'limit' => 'require|number',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$CaiJiPeiZhiModel = CaiJiPeiZhiModel::alias('cjpz');
|
||||
|
||||
if (!empty($arrData['key'])) {
|
||||
$strKey = $arrData['key'];
|
||||
$CaiJiPeiZhiModel->where(function ($CaiJiPeiZhiModel) use ($strKey) {
|
||||
$CaiJiPeiZhiModel->whereOr([
|
||||
['cjpz.cjpz_code', 'like', "%" . $strKey . "%"],
|
||||
['cjpz.cjpz_id', 'like', "%" . $strKey . "%"],
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
$Paginate = $CaiJiPeiZhiModel->paginate([
|
||||
'list_rows' => $arrData['limit'],
|
||||
'page' => $arrData['page'],
|
||||
]);
|
||||
|
||||
$arrResult = [
|
||||
'items' => $Paginate->items(),
|
||||
'total' => $Paginate->total(),
|
||||
'current_page' => $Paginate->currentPage(),
|
||||
'total_pages' => $Paginate->lastPage(),
|
||||
];
|
||||
|
||||
return $this->success($arrResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置采集配置
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function saveCaiJiPeiZhi(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"cjpz_id" => $Request->post('cjpz_id'),
|
||||
"cjpz_val" => $Request->post('cjpz_val'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'cjpz_id' => 'require',
|
||||
'cjpz_val' => 'require',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$CaiJiPeiZhiModel = CaiJiPeiZhiModel::where('cjpz_id', $arrData['cjpz_id'])->find();
|
||||
|
||||
if (empty($CaiJiPeiZhiModel)) {
|
||||
return $this->error('9993');
|
||||
}
|
||||
|
||||
$CaiJiPeiZhiModel->fill($arrData);
|
||||
|
||||
$CaiJiPeiZhiModel->save();
|
||||
|
||||
CaiJiPeiZhiModel::flushCache();
|
||||
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 系统配置列表
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function getSystemConfigList(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"page" => $Request->get('page', 1),
|
||||
"limit" => $Request->get('limit', 10),
|
||||
"key" => $Request->get('key'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'page' => 'require|number',
|
||||
'limit' => 'require|number',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$SystemConfigModel = SystemConfigModel::alias('sc');
|
||||
|
||||
if (!empty($arrData['key'])) {
|
||||
$strKey = $arrData['key'];
|
||||
$SystemConfigModel->where(function ($SystemConfigModel) use ($strKey) {
|
||||
$SystemConfigModel->whereOr([
|
||||
['sc.sc_code', 'like', "%" . $strKey . "%"],
|
||||
['sc.sc_id', 'like', "%" . $strKey . "%"],
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
$Paginate = $SystemConfigModel->paginate([
|
||||
'list_rows' => $arrData['limit'],
|
||||
'page' => $arrData['page'],
|
||||
]);
|
||||
|
||||
$arrResult = [
|
||||
'items' => $Paginate->items(),
|
||||
'total' => $Paginate->total(),
|
||||
'current_page' => $Paginate->currentPage(),
|
||||
'total_pages' => $Paginate->lastPage(),
|
||||
];
|
||||
|
||||
return $this->success($arrResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置系统配置
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function saveSystemConfig(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"sc_id" => $Request->post('sc_id'),
|
||||
"sc_val" => $Request->post('sc_val'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'sc_id' => 'require',
|
||||
'sc_val' => 'require',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$SystemConfigModel = SystemConfigModel::where('sc_id', $arrData['sc_id'])->find();
|
||||
|
||||
if (empty($SystemConfigModel)) {
|
||||
return $this->error('9993');
|
||||
}
|
||||
|
||||
$SystemConfigModel->fill($arrData);
|
||||
|
||||
$SystemConfigModel->save();
|
||||
|
||||
SystemConfigModel::flushCache();
|
||||
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 资源端点列表
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function getZiYuanDuanDianList(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"page" => $Request->get('page', 1),
|
||||
"limit" => $Request->get('limit', 10),
|
||||
"key" => $Request->get('key'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'page' => 'require|number',
|
||||
'limit' => 'require|number',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$ZiYuanDuanDianModel = ZiYuanDuanDianModel::alias('zydd');
|
||||
|
||||
if (!empty($arrData['key'])) {
|
||||
$strKey = $arrData['key'];
|
||||
$ZiYuanDuanDianModel->where(function ($ZiYuanDuanDianModel) use ($strKey) {
|
||||
$ZiYuanDuanDianModel->whereOr([
|
||||
['zydd.zydd_ming_zi', 'like', "%" . $strKey . "%"],
|
||||
['zydd.zydd_id', 'like', "%" . $strKey . "%"],
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
$Paginate = $ZiYuanDuanDianModel->paginate([
|
||||
'list_rows' => $arrData['limit'],
|
||||
'page' => $arrData['page'],
|
||||
]);
|
||||
|
||||
$arrResult = [
|
||||
'items' => $Paginate->items(),
|
||||
'total' => $Paginate->total(),
|
||||
'current_page' => $Paginate->currentPage(),
|
||||
'total_pages' => $Paginate->lastPage(),
|
||||
];
|
||||
|
||||
return $this->success($arrResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置资源端点
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function saveZiYuanDuanDian(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"zydd_id" => $Request->post('zydd_id'),
|
||||
"zydd_domain" => $Request->post('zydd_domain'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'zydd_id' => 'require',
|
||||
'zydd_domain' => 'require',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$ZiYuanDuanDianModel = ZiYuanDuanDianModel::where('zydd_id', $arrData['zydd_id'])->find();
|
||||
|
||||
if (empty($ZiYuanDuanDianModel)) {
|
||||
return $this->error('9993');
|
||||
}
|
||||
|
||||
$ZiYuanDuanDianModel->fill($arrData);
|
||||
|
||||
$ZiYuanDuanDianModel->save();
|
||||
|
||||
ZiYuanDuanDianModel::flushCache();
|
||||
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 计划任务列表
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function getPlanTaskList(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"page" => $Request->get('page', 1),
|
||||
"limit" => $Request->get('limit', 10),
|
||||
"key" => $Request->get('key'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'page' => 'require|number',
|
||||
'limit' => 'require|number',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$PlanTaskModel = PlanTaskModel::alias('pt');
|
||||
|
||||
if (!empty($arrData['key'])) {
|
||||
$strKey = $arrData['key'];
|
||||
$PlanTaskModel->where(function ($PlanTaskModel) use ($strKey) {
|
||||
$PlanTaskModel->whereOr([
|
||||
['pt.pt_name', 'like', "%" . $strKey . "%"],
|
||||
['pt.pt_id', 'like', "%" . $strKey . "%"],
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
$Paginate = $PlanTaskModel->paginate([
|
||||
'list_rows' => $arrData['limit'],
|
||||
'page' => $arrData['page'],
|
||||
]);
|
||||
|
||||
$arrResult = [
|
||||
'items' => $Paginate->items(),
|
||||
'total' => $Paginate->total(),
|
||||
'current_page' => $Paginate->currentPage(),
|
||||
'total_pages' => $Paginate->lastPage(),
|
||||
];
|
||||
|
||||
return $this->success($arrResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置计划任务
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function savePlanTask(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"pt_id" => $Request->post('pt_id'),
|
||||
"pt_enable" => $Request->post('pt_enable'),
|
||||
"pt_limit" => $Request->post('pt_limit'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'pt_id' => 'require|number',
|
||||
'pt_enable' => 'require|number',
|
||||
'pt_limit' => 'require|number',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$PlanTaskModel = PlanTaskModel::where('pt_id', $arrData['pt_id'])->find();
|
||||
|
||||
if (empty($PlanTaskModel)) {
|
||||
return $this->error('9993');
|
||||
}
|
||||
|
||||
$PlanTaskModel->fill($arrData);
|
||||
|
||||
$PlanTaskModel->save();
|
||||
|
||||
return $this->success();
|
||||
}
|
||||
}
|
||||
179
code/app/admin/controller/XiaoShuo.php
Normal file
179
code/app/admin/controller/XiaoShuo.php
Normal file
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\BaseController;
|
||||
use app\admin\model\AdminUserModel;
|
||||
use app\admin\model\BaoYangRuZhuModel;
|
||||
use app\admin\model\DaLiWanFanKuiModel;
|
||||
use app\admin\model\DaLiWanModel;
|
||||
use app\admin\model\GuanFangZiYingModel;
|
||||
use app\admin\model\LouFengModel;
|
||||
use app\admin\model\SystemConfigModel;
|
||||
use app\admin\model\XiaoShuoFenLeiModel;
|
||||
use app\admin\model\XiaoShuoModel;
|
||||
use app\admin\model\XiaoShuoXiangQingModel;
|
||||
use app\admin\model\XiaoShuoZhangJieModel;
|
||||
use app\Request;
|
||||
use think\Response;
|
||||
|
||||
class XiaoShuo extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function getXiaoShuoList(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"page" => $Request->get('page', 1),
|
||||
"limit" => $Request->get('limit', 10),
|
||||
"key" => $Request->get('key'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'page' => 'require|number',
|
||||
'limit' => 'require|number',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$XiaoShuoXiangQingModel = XiaoShuoXiangQingModel::alias('xsxq');
|
||||
|
||||
if (!empty($arrData['key'])) {
|
||||
$strKey = $arrData['key'];
|
||||
$XiaoShuoXiangQingModel->where(function ($XiaoShuoXiangQingModel) use ($strKey) {
|
||||
$XiaoShuoXiangQingModel->whereOr([
|
||||
['xsxq.xsxq_ming_zi', 'like', "%" . $strKey . "%"],
|
||||
['xsxq.xsxq_id', 'like', "%" . $strKey . "%"],
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
$Paginate = $XiaoShuoXiangQingModel->paginate([
|
||||
'list_rows' => $arrData['limit'],
|
||||
'page' => $arrData['page'],
|
||||
]);
|
||||
|
||||
$arrResult = [
|
||||
'items' => $Paginate->items(),
|
||||
'total' => $Paginate->total(),
|
||||
'current_page' => $Paginate->currentPage(),
|
||||
'total_pages' => $Paginate->lastPage(),
|
||||
];
|
||||
|
||||
return $this->success($arrResult);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function getXiaoShuoZhangJieList(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"page" => $Request->get('page', 1),
|
||||
"limit" => $Request->get('limit', 10),
|
||||
"key" => $Request->get('key'),
|
||||
"xsxq_id" => $Request->get('xsxq_id'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'page' => 'require|number',
|
||||
'limit' => 'require|number',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$XiaoShuoZhangJieModel = XiaoShuoZhangJieModel::alias('xszj');
|
||||
|
||||
if (!empty($arrData['key'])) {
|
||||
$strKey = $arrData['key'];
|
||||
$XiaoShuoZhangJieModel->where(function ($XiaoShuoZhangJieModel) use ($strKey) {
|
||||
$XiaoShuoZhangJieModel->whereOr([
|
||||
['xszj.xszj_ming_zi', 'like', "%" . $strKey . "%"],
|
||||
['xszj.xszj_id', 'like', "%" . $strKey . "%"],
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
if (!empty($arrData['xsxq_id'])) {
|
||||
$XiaoShuoZhangJieModel->where('xszj.xsxq_id', $arrData['xsxq_id']);
|
||||
$XiaoShuoZhangJieModel->order('xszj.xszj_pai_xu', 'desc');
|
||||
}
|
||||
|
||||
$Paginate = $XiaoShuoZhangJieModel->paginate([
|
||||
'list_rows' => $arrData['limit'],
|
||||
'page' => $arrData['page'],
|
||||
]);
|
||||
|
||||
$arrResult = [
|
||||
'items' => $Paginate->items(),
|
||||
'total' => $Paginate->total(),
|
||||
'current_page' => $Paginate->currentPage(),
|
||||
'total_pages' => $Paginate->lastPage(),
|
||||
];
|
||||
|
||||
return $this->success($arrResult);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param Request $Request
|
||||
* @param AdminUserModel|null $AdminUserModel
|
||||
* @return Response
|
||||
*/
|
||||
public function getXiaoShuoFenLeiList(Request $Request, ?AdminUserModel $AdminUserModel)
|
||||
{
|
||||
$arrData = [
|
||||
"page" => $Request->get('page', 1),
|
||||
"limit" => $Request->get('limit', 10),
|
||||
"key" => $Request->get('key'),
|
||||
];
|
||||
|
||||
$arrRule = [
|
||||
'page' => 'require|number',
|
||||
'limit' => 'require|number',
|
||||
];
|
||||
|
||||
$this->validate($arrData, $arrRule);
|
||||
|
||||
$XiaoShuoFenLeiModel = XiaoShuoFenLeiModel::alias('xsfl');
|
||||
|
||||
if (!empty($arrData['key'])) {
|
||||
$strKey = $arrData['key'];
|
||||
$XiaoShuoFenLeiModel->where(function ($XiaoShuoFenLeiModel) use ($strKey) {
|
||||
$XiaoShuoFenLeiModel->whereOr([
|
||||
['xsfl.xsfl_name', 'like', "%" . $strKey . "%"],
|
||||
['xsfl.xsfl_id', 'like', "%" . $strKey . "%"],
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
$Paginate = $XiaoShuoFenLeiModel->paginate([
|
||||
'list_rows' => $arrData['limit'],
|
||||
'page' => $arrData['page'],
|
||||
]);
|
||||
|
||||
$arrResult = [
|
||||
'items' => $Paginate->items(),
|
||||
'total' => $Paginate->total(),
|
||||
'current_page' => $Paginate->currentPage(),
|
||||
'total_pages' => $Paginate->lastPage(),
|
||||
];
|
||||
|
||||
return $this->success($arrResult);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
<?php
|
||||
// 这是系统自动生成的middleware定义文件
|
||||
return [
|
||||
|
||||
use app\admin\middleware\AdminCors;
|
||||
|
||||
return [
|
||||
AdminCors::class,
|
||||
think\middleware\LoadLangPack::class,
|
||||
];
|
||||
|
||||
34
code/app/admin/middleware/AdminAuth.php
Normal file
34
code/app/admin/middleware/AdminAuth.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\middleware;
|
||||
|
||||
use app\admin\model\AdminUserModel;
|
||||
use app\admin\service\AdminUserAuth;
|
||||
use app\Request;
|
||||
use think\Response;
|
||||
use think\facade\App;
|
||||
|
||||
class AdminAuth
|
||||
{
|
||||
public function handle(Request $Request, \Closure $Next)
|
||||
{
|
||||
try {
|
||||
/**@var AdminUserModel */
|
||||
$AdminUserModel = App::make(AdminUserModel::class);
|
||||
|
||||
if (empty($AdminUserModel)) {
|
||||
return AdminResponse::create("9995");
|
||||
}
|
||||
|
||||
if ($AdminUserModel->checkRole() == false) {
|
||||
return AdminResponse::create("9991");
|
||||
}
|
||||
|
||||
return $Next($Request);
|
||||
} catch (\Throwable $T) {
|
||||
return AdminResponse::createByErr($T);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
code/app/admin/middleware/AdminCors.php
Normal file
22
code/app/admin/middleware/AdminCors.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\middleware;
|
||||
|
||||
use app\admin\model\AdminUserModel;
|
||||
use app\admin\service\AdminUserAuth;
|
||||
use app\Request;
|
||||
use think\Response;
|
||||
use think\facade\App;
|
||||
use think\middleware\AllowCrossDomain;
|
||||
|
||||
class AdminCors extends AllowCrossDomain
|
||||
{
|
||||
protected $header = [
|
||||
'Access-Control-Allow-Credentials' => 'true',
|
||||
'Access-Control-Max-Age' => 3600,
|
||||
'Access-Control-Allow-Methods' => '*',
|
||||
'Access-Control-Allow-Headers' => '*',
|
||||
];
|
||||
}
|
||||
17
code/app/admin/middleware/AdminException.php
Normal file
17
code/app/admin/middleware/AdminException.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\middleware;
|
||||
|
||||
use think\exception\Handle;
|
||||
use think\Response;
|
||||
use Throwable;
|
||||
|
||||
class AdminException extends Handle
|
||||
{
|
||||
public function render($Request, Throwable $T): Response
|
||||
{
|
||||
return AdminResponse::createByErr($T);
|
||||
}
|
||||
}
|
||||
57
code/app/admin/middleware/AdminResponse.php
Normal file
57
code/app/admin/middleware/AdminResponse.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\middleware;
|
||||
|
||||
use app\admin\service\AdminUserAuth;
|
||||
use app\Request;
|
||||
use think\exception\ValidateException;
|
||||
use think\Response;
|
||||
use think\facade\App;
|
||||
|
||||
class AdminResponse
|
||||
{
|
||||
static public function create($strCode = "1000", $strMsg = "", $arrData = [])
|
||||
{
|
||||
$arrError = config("error");
|
||||
|
||||
if (!key_exists($strCode, $arrError)) {
|
||||
$strCode = "9999";
|
||||
}
|
||||
|
||||
if ($strMsg == "") {
|
||||
$strMsg = $arrError[$strCode];
|
||||
}
|
||||
|
||||
$arrData = [
|
||||
'code' => $strCode,
|
||||
'msg' => $strMsg,
|
||||
'data' => $arrData,
|
||||
];
|
||||
|
||||
return json($arrData, 200, [], [JSON_UNESCAPED_UNICODE]);
|
||||
}
|
||||
|
||||
static $arrExceptionMap = [
|
||||
ValidateException::class => "9900",
|
||||
];
|
||||
|
||||
static public function createByErr(\Throwable $T)
|
||||
{
|
||||
$strCode = $T->getCode();
|
||||
|
||||
if ($T instanceof ValidateException) {
|
||||
$strCode = "9900";
|
||||
}
|
||||
|
||||
foreach (self::$arrExceptionMap as $ExceptionClass => $strExceptonCode) {
|
||||
if ($T instanceof $ExceptionClass) {
|
||||
$strCode = $strExceptonCode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return self::create($strCode, $T->getMessage());
|
||||
}
|
||||
}
|
||||
15
code/app/admin/model/AdminNodeModel.php
Normal file
15
code/app/admin/model/AdminNodeModel.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class AdminNodeModel extends BaseModel
|
||||
{
|
||||
protected $name = 'admin_node';
|
||||
protected $pk = 'an_id';
|
||||
}
|
||||
47
code/app/admin/model/AdminRoleModel.php
Normal file
47
code/app/admin/model/AdminRoleModel.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\facade\Cache;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class AdminRoleModel extends BaseModel
|
||||
{
|
||||
protected $name = 'admin_role';
|
||||
protected $pk = 'ar_id';
|
||||
|
||||
public function getRoleNodeByCache($intArId)
|
||||
{
|
||||
$strCacheKey = 'Admin:Role:Node:'.$intArId;
|
||||
|
||||
$arrRoleNode = Cache::get($strCacheKey);
|
||||
|
||||
if($arrRoleNode === NULL)
|
||||
{
|
||||
$AdminRoleNodeModel = new AdminRoleNodeModel();
|
||||
|
||||
$AdminRoleNodeModel = $AdminRoleNodeModel->alias('arn')
|
||||
->field('an.an_url')
|
||||
->leftjoin('admin_node an','an.an_id=arn.an_id');
|
||||
|
||||
if($intArId>0)
|
||||
{
|
||||
$AdminRoleNodeModel = $AdminRoleNodeModel->where('arn.ar_id',$intArId);
|
||||
}
|
||||
|
||||
$arrRoleNode = $AdminRoleNodeModel
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$arrRoleNode = array_column($arrRoleNode, 'an_url');
|
||||
|
||||
// Cache::set($strCacheKey,$arrRoleNode);
|
||||
}
|
||||
|
||||
return $arrRoleNode;
|
||||
}
|
||||
}
|
||||
15
code/app/admin/model/AdminRoleNodeModel.php
Normal file
15
code/app/admin/model/AdminRoleNodeModel.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class AdminRoleNodeModel extends BaseModel
|
||||
{
|
||||
protected $name = 'admin_role_node';
|
||||
protected $pk = 'arn_id';
|
||||
}
|
||||
92
code/app/admin/model/AdminUserModel.php
Normal file
92
code/app/admin/model/AdminUserModel.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
use think\helper\Str;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class AdminUserModel extends BaseModel
|
||||
{
|
||||
protected $name = 'admin_user';
|
||||
|
||||
protected $pk = 'au_id';
|
||||
|
||||
protected $token = "";
|
||||
|
||||
// protected $hidden = ['au_pwd'];
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $strToken
|
||||
* @return AdminUserModel|NULL
|
||||
*/
|
||||
static public function getUserByToken($strToken = "")
|
||||
{
|
||||
if ($strToken == "") {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$strKey = "AdminToken:" . $strToken;
|
||||
|
||||
$intAuId = Cache::get($strKey);
|
||||
|
||||
if (empty($intAuId)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$AdminUserModel = self::getAdminUserModelByCache($intAuId);
|
||||
|
||||
$AdminUserModel->token = $strToken;
|
||||
|
||||
$AdminUserModel->refreshToken();
|
||||
|
||||
return $AdminUserModel;
|
||||
}
|
||||
|
||||
public function checkRole()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function createToken()
|
||||
{
|
||||
$this->token = Str::random(32);
|
||||
|
||||
$this->refreshToken();
|
||||
|
||||
return $this->token;
|
||||
}
|
||||
|
||||
public function refreshToken()
|
||||
{
|
||||
Cache::set("AdminToken:" . $this->token, $this->au_id, 3600);
|
||||
}
|
||||
|
||||
static public function getAdminUserModelByCache($intAuId, $boolForceUpdate = false)
|
||||
{
|
||||
$strKey = "AdminUser:Id:" . $intAuId;
|
||||
|
||||
$AdminUserModel = Cache::get($strKey);
|
||||
|
||||
if (empty($AdminUserModel) || $boolForceUpdate == true) {
|
||||
$AdminUserModel = self::where('au_id', $intAuId)->find();
|
||||
|
||||
if (empty($AdminUserModel)) {
|
||||
throw new \Exception("用户不存在", 9999);
|
||||
}
|
||||
$AdminUserModel->au_pwd = "";
|
||||
|
||||
Cache::set($strKey, $AdminUserModel);
|
||||
}
|
||||
|
||||
return $AdminUserModel;
|
||||
}
|
||||
}
|
||||
21
code/app/admin/model/BaseModel.php
Normal file
21
code/app/admin/model/BaseModel.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class BaseModel extends Model
|
||||
{
|
||||
public function fill($arrData)
|
||||
{
|
||||
foreach ($arrData as $strKey => $strVal) {
|
||||
$this->$strKey = $strVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
39
code/app/admin/model/CaiJiPeiZhiModel.php
Normal file
39
code/app/admin/model/CaiJiPeiZhiModel.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class CaiJiPeiZhiModel extends BaseModel
|
||||
{
|
||||
protected $name = 'cai_ji_pei_zhi';
|
||||
protected $pk = 'cjpz_id';
|
||||
|
||||
static $arrCaiJiPeiZhi = [];
|
||||
|
||||
static public function getValByCode($strCode)
|
||||
{
|
||||
if (self::$arrCaiJiPeiZhi == []) {
|
||||
self::$arrCaiJiPeiZhi = Cache::get('CaiJiPeiZhi');
|
||||
|
||||
if (empty(self::$arrCaiJiPeiZhi)) {
|
||||
self::flushCache();
|
||||
self::$arrCaiJiPeiZhi = Cache::get('CaiJiPeiZhi');
|
||||
}
|
||||
}
|
||||
|
||||
return self::$arrCaiJiPeiZhi[$strCode] ?? NULL;
|
||||
}
|
||||
|
||||
static public function flushCache()
|
||||
{
|
||||
$arrCaiJiPeiZhi = self::column('cjpz_val', 'cjpz_code');
|
||||
Cache::tag('CaiJiPeiZhi')->set('CaiJiPeiZhi', $arrCaiJiPeiZhi);
|
||||
}
|
||||
}
|
||||
70
code/app/admin/model/ContentStatsModel.php
Normal file
70
code/app/admin/model/ContentStatsModel.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class ContentStatsModel extends BaseModel
|
||||
{
|
||||
protected $name = 'content_stats';
|
||||
protected $pk = 'cs_id';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static public function add($arrData): self
|
||||
{
|
||||
try {
|
||||
$existingRecord = self::where([
|
||||
'cs_md5' => $arrData['cs_md5'],
|
||||
])->find();
|
||||
if ($existingRecord) {
|
||||
$existingRecord->cs_pv = $arrData['cs_pv'];
|
||||
$existingRecord->cs_uv = $arrData['cs_uv'];
|
||||
$existingRecord->updated_at = $arrData['updated_at'];
|
||||
// 尝试保存数据
|
||||
if (!$existingRecord->save()) {
|
||||
// 数据保存失败,抛出异常
|
||||
throw new \RuntimeException('数据保存失败:' . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
// 返回模型实例
|
||||
return $existingRecord;
|
||||
// return $existingRecord->save();
|
||||
// return $existingRecord->save($arrData);
|
||||
} else {
|
||||
// 插入新记录
|
||||
return self::create($arrData);
|
||||
}
|
||||
// if ($existingRecord) {
|
||||
// // 更新记录
|
||||
// $existingRecord->cs_pv = $arrData['cs_pv'];
|
||||
// $existingRecord->cs_uv = $arrData['cs_uv'];
|
||||
// $existingRecord->updated_at = $arrData['updated_at'];
|
||||
// $existingRecord->save();
|
||||
|
||||
// return $existingRecord;
|
||||
// }
|
||||
|
||||
// $existingRecord = new self;
|
||||
// $existingRecord->save($arrData);
|
||||
// return $existingRecord;
|
||||
|
||||
} catch (\Throwable $T) {
|
||||
var_dump($T);
|
||||
if ($T->getCode() == 10501) {
|
||||
//return self::addVideoLeixin($arrData);
|
||||
}
|
||||
throw $T;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
133
code/app/admin/model/FenLeiModel.php
Normal file
133
code/app/admin/model/FenLeiModel.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class FenLeiModel extends BaseModel
|
||||
{
|
||||
protected $name = 'fen_lei';
|
||||
protected $pk = 'fl_id';
|
||||
|
||||
static $arrFenLei = [];
|
||||
|
||||
static public function addFenlei($intFlId, $intFlPId = 0, $strFlMingzi)
|
||||
{
|
||||
try {
|
||||
|
||||
if (empty($strFlMingzi)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$FenLeiModel = self::where('fl_pid',$intFlPId)->where('fl_mingzi',$strFlMingzi)->find();
|
||||
|
||||
if ($FenLeiModel) {
|
||||
return $FenLeiModel;
|
||||
}
|
||||
|
||||
$FenLeiModel = new self;
|
||||
// $FenLeiModel->fl_id = $intFlId;
|
||||
$FenLeiModel->fl_leixing = 0;
|
||||
$FenLeiModel->fl_pid = $intFlPId;
|
||||
$FenLeiModel->fl_mingzi = $strFlMingzi;
|
||||
$FenLeiModel->save();
|
||||
return $FenLeiModel;
|
||||
} catch (\Throwable $T) {
|
||||
}
|
||||
|
||||
if ($T->getCode() == 10501) {
|
||||
return self::addFenlei($intFlId, $intFlPId, $strFlMingzi);
|
||||
}
|
||||
throw $T;
|
||||
}
|
||||
|
||||
static public function getAllFenLei()
|
||||
{
|
||||
if (self::$arrFenLei == []) {
|
||||
self::$arrFenLei = Cache::get('SHI_PIN_FEN_LEI');
|
||||
|
||||
if (empty(self::$arrFenLei)) {
|
||||
self::flushCache();
|
||||
self::$arrFenLei = Cache::get('SHI_PIN_FEN_LEI');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return self::$arrFenLei;
|
||||
}
|
||||
|
||||
|
||||
static public function getFenLeiByFlId($intFlId)
|
||||
{
|
||||
if (self::$arrFenLei == []) {
|
||||
self::$arrFenLei = Cache::get('SHI_PIN_FEN_LEI');
|
||||
|
||||
if (empty(self::$arrFenLei)) {
|
||||
self::flushCache();
|
||||
self::$arrFenLei = Cache::get('SHI_PIN_FEN_LEI');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return self::$arrFenLei[$intFlId] ?? "";
|
||||
}
|
||||
|
||||
static public function getFenLeiMingZiByFlId($intFlId, $intZiFlId)
|
||||
{
|
||||
if (empty(self::$arrFenLei)) {
|
||||
self::$arrFenLei = Cache::get('SHI_PIN_FEN_LEI');
|
||||
|
||||
if (empty(self::$arrFenLei)) {
|
||||
self::flushCache();
|
||||
self::$arrFenLei = Cache::get('SHI_PIN_FEN_LEI');
|
||||
}
|
||||
}
|
||||
|
||||
if ($intZiFlId == 0) {
|
||||
return self::$arrFenLei[$intFlId]['fl_mingzi'] ?? '';
|
||||
} else {
|
||||
$arrFenLeiChild = self::$arrFenLei[$intFlId]['child'] ?? [];
|
||||
foreach ($arrFenLeiChild as $item) {
|
||||
if ($item['fl_id'] == $intZiFlId) {
|
||||
return $item['fl_mingzi'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
static public function flushCache()
|
||||
{
|
||||
// $arrFenLei = self::select()->toArray();
|
||||
$arrFenLei = self::order('fl_sort', 'desc')->select()->toArray();
|
||||
|
||||
$arrFenLei = static::buildTree($arrFenLei);
|
||||
|
||||
Cache::tag('SHI_PIN_FEN_LEI')->set('SHI_PIN_FEN_LEI', $arrFenLei);
|
||||
}
|
||||
|
||||
static public function buildTree(array $elements, $parentId = 0)
|
||||
{
|
||||
$branch = [];
|
||||
|
||||
foreach ($elements as $element) {
|
||||
if ($element['fl_pid'] == $parentId) {
|
||||
$children = static::buildTree($elements, $element['fl_id']);
|
||||
if ($children) {
|
||||
$element['child'] = $children;
|
||||
}
|
||||
$branch[$element['fl_id']] = $element;
|
||||
}
|
||||
}
|
||||
|
||||
return $branch;
|
||||
}
|
||||
}
|
||||
76
code/app/admin/model/GanRaoMaModel.php
Normal file
76
code/app/admin/model/GanRaoMaModel.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class GanRaoMaModel extends BaseModel
|
||||
{
|
||||
protected $name = 'gan_rao_ma';
|
||||
protected $pk = 'grm_id';
|
||||
|
||||
/**
|
||||
* 根据 HTML 路径获取值
|
||||
* @param string $strHtmlPath
|
||||
* @return string|null
|
||||
*/
|
||||
public static function getValByHtmlPath(string $strHtmlPath): ?string
|
||||
{
|
||||
// 尝试从缓存获取
|
||||
$strGamRaoMa = Cache::get($strHtmlPath);
|
||||
|
||||
// 如果缓存不存在,刷新缓存
|
||||
if (!$strGamRaoMa) {
|
||||
self::flushCache($strHtmlPath);
|
||||
$strGamRaoMa = Cache::get($strHtmlPath);
|
||||
}
|
||||
|
||||
return $strGamRaoMa ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新缓存数据
|
||||
* @param string $strHtmlPath
|
||||
* @return void
|
||||
*/
|
||||
public static function flushCache(string $strHtmlPath): void
|
||||
{
|
||||
// 初始化缓存
|
||||
$cache = Cache::tag('GanRaoMaTag');
|
||||
|
||||
// 尝试从数据库获取
|
||||
$strGamRaoMa = self::where('site_id',config('app.default_app_id'))->where('grm_html_path', $strHtmlPath)->value('grm_neirong');
|
||||
|
||||
if ($strGamRaoMa) {
|
||||
// 设置缓存
|
||||
$cache->set($strHtmlPath, $strGamRaoMa);
|
||||
} else {
|
||||
// 如果数据库中没有记录,生成随机内容
|
||||
$fallbackKeyword = generateRandomHTML(3, 15);
|
||||
|
||||
if ($fallbackKeyword) {
|
||||
$arrGanRaoMa = [
|
||||
'grm_html_path' => $strHtmlPath,
|
||||
'grm_neirong' => $fallbackKeyword,
|
||||
'site_id' => config('app.default_app_id'),
|
||||
];
|
||||
|
||||
// 保存到数据库
|
||||
$model = new self();
|
||||
$model->save($arrGanRaoMa);
|
||||
|
||||
// 设置缓存
|
||||
$cache->set($strHtmlPath, $fallbackKeyword);
|
||||
} else {
|
||||
// 记录日志或其他处理逻辑
|
||||
// Log::warning("No fallback keyword generated for path: $strHtmlPath");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
17
code/app/admin/model/GuangGaoFenZuModel.php
Normal file
17
code/app/admin/model/GuangGaoFenZuModel.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class GuangGaoFenZuModel extends BaseModel
|
||||
{
|
||||
protected $name = 'guang_gao_fen_zu';
|
||||
protected $pk = 'ggfz_id';
|
||||
}
|
||||
59
code/app/admin/model/GuangGaoModel.php
Normal file
59
code/app/admin/model/GuangGaoModel.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class GuangGaoModel extends BaseModel
|
||||
{
|
||||
protected $name = 'guang_gao';
|
||||
protected $pk = 'gg_id';
|
||||
|
||||
static $arrGuangGao = [];
|
||||
|
||||
static public function getAdByCache($strGGFZCode, $intLimit = 10, $strSort = 'asc')
|
||||
{
|
||||
if (self::$arrGuangGao == []) {
|
||||
self::$arrGuangGao = Cache::get('GuangGao');
|
||||
if (empty(self::$arrGuangGao)) {
|
||||
self::flushCache();
|
||||
self::$arrGuangGao = Cache::get('GuangGao');
|
||||
}
|
||||
}
|
||||
$arrTemp = self::$arrGuangGao[$strGGFZCode] ?? [];
|
||||
|
||||
if ($strSort == 'rand') {
|
||||
shuffle($arrTemp);
|
||||
}
|
||||
|
||||
return array_slice($arrTemp, 0, $intLimit);
|
||||
}
|
||||
|
||||
static public function flushCache()
|
||||
{
|
||||
$arrGuangGao = [];
|
||||
$arrGGFZCode = GuangGaoFenZuModel::column('ggfz_code', 'ggfz_id');
|
||||
$GuangGaoModelAll = self::where('site_id',config('app.default_app_id'))->order('ggfz_id', 'desc')->order('gg_sort', 'desc')->where('gg_status',0)->select();
|
||||
|
||||
foreach ($GuangGaoModelAll as $GuangGaoModel) {
|
||||
$GuangGaoModel->ggfz_id;
|
||||
if (!key_exists($GuangGaoModel->ggfz_id, $arrGGFZCode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!key_exists($arrGGFZCode[$GuangGaoModel->ggfz_id], $arrGuangGao)) {
|
||||
$arrGuangGao[$arrGGFZCode[$GuangGaoModel->ggfz_id]] = [];
|
||||
}
|
||||
|
||||
$arrGuangGao[$arrGGFZCode[$GuangGaoModel->ggfz_id]][] = $GuangGaoModel->toArray();
|
||||
}
|
||||
|
||||
Cache::tag('GuangGao')->set('GuangGao', $arrGuangGao);
|
||||
}
|
||||
}
|
||||
40
code/app/admin/model/GuangGaoPeiZhiModel.php
Normal file
40
code/app/admin/model/GuangGaoPeiZhiModel.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class GuangGaoPeiZhiModel extends BaseModel
|
||||
{
|
||||
protected $name = 'guang_gao_pei_zhi';
|
||||
protected $pk = 'ggpz_id';
|
||||
|
||||
static $arrGuangGaoPeiZhi = [];
|
||||
|
||||
static public function getValByCode($strCode)
|
||||
{
|
||||
self::flushCache();
|
||||
if (self::$arrGuangGaoPeiZhi == []) {
|
||||
self::$arrGuangGaoPeiZhi = Cache::get('GuangGaoPeiZhi');
|
||||
|
||||
if (empty(self::$arrGuangGaoPeiZhi)) {
|
||||
self::flushCache();
|
||||
self::$arrGuangGaoPeiZhi = Cache::get('GuangGaoPeiZhi');
|
||||
}
|
||||
}
|
||||
|
||||
return self::$arrGuangGaoPeiZhi[$strCode] ?? NULL;
|
||||
}
|
||||
|
||||
static public function flushCache()
|
||||
{
|
||||
$arrGuangGaoPeiZhi = self::column('ggpz_val', 'ggpz_code');
|
||||
Cache::tag('GuangGaoPeiZhi')->set('GuangGaoPeiZhi', $arrGuangGaoPeiZhi);
|
||||
}
|
||||
}
|
||||
41
code/app/admin/model/NovelInfoSeoModel.php
Normal file
41
code/app/admin/model/NovelInfoSeoModel.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class NovelInfoSeoModel extends BaseModel
|
||||
{
|
||||
protected $name = 'novel_info_seo';
|
||||
protected $pk = 'nis_id';
|
||||
|
||||
|
||||
|
||||
static public function addXiaoShuoXiangQingSeo($arrData): self
|
||||
{
|
||||
|
||||
try {
|
||||
$XiaoShuoXiangQingModel = self::where('nis_md5', $arrData['nis_md5'])->find();
|
||||
|
||||
if ($XiaoShuoXiangQingModel) {
|
||||
|
||||
return $XiaoShuoXiangQingModel;
|
||||
}
|
||||
|
||||
$XiaoShuoXiangQingModel = new self;
|
||||
|
||||
$XiaoShuoXiangQingModel->save($arrData);
|
||||
return $XiaoShuoXiangQingModel;
|
||||
} catch (\Throwable $T) {
|
||||
|
||||
throw $T; // 超过重试次数后抛出异常
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
17
code/app/admin/model/PlanTaskModel.php
Normal file
17
code/app/admin/model/PlanTaskModel.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class PlanTaskModel extends BaseModel
|
||||
{
|
||||
protected $name = 'plan_task';
|
||||
protected $pk = 'pt_id';
|
||||
}
|
||||
42
code/app/admin/model/ReSouFenZuModel.php
Normal file
42
code/app/admin/model/ReSouFenZuModel.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class ReSouFenZuModel extends BaseModel
|
||||
{
|
||||
protected $name = 're_sou_fen_zu';
|
||||
protected $pk = 'rsfz_id';
|
||||
|
||||
static public function addReSouFenZu($arrData): self
|
||||
{
|
||||
try {
|
||||
if (empty($arrData['rsfz_ming_zi'])) {
|
||||
throw new \Exception("热搜词分组信息不全!");
|
||||
}
|
||||
|
||||
$ReSouFenZuModel = self::where('rsfz_ming_zi', $arrData['rsfz_ming_zi'])->find();
|
||||
if ($ReSouFenZuModel) {
|
||||
return $ReSouFenZuModel;
|
||||
}
|
||||
|
||||
$ReSouFenZuModel = new self;
|
||||
$ReSouFenZuModel->rsfz_pai_xu = $arrData['rsfz_pai_xu'];
|
||||
$ReSouFenZuModel->rsfz_ming_zi = $arrData['rsfz_ming_zi'];
|
||||
$ReSouFenZuModel->save();
|
||||
return $ReSouFenZuModel;
|
||||
} catch (\Throwable $T) {
|
||||
|
||||
if ($T->getCode() == 10501) {
|
||||
return self::addReSouFenZu($arrData);
|
||||
}
|
||||
throw $T;
|
||||
}
|
||||
}
|
||||
}
|
||||
101
code/app/admin/model/ReSouModel.php
Normal file
101
code/app/admin/model/ReSouModel.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class ReSouModel extends BaseModel
|
||||
{
|
||||
protected $name = 're_sou';
|
||||
protected $pk = 'rs_id';
|
||||
|
||||
static $arrReSou = [];
|
||||
|
||||
static $arrReSouAll = [];
|
||||
|
||||
static public function addReSou($arrData): self
|
||||
{
|
||||
try {
|
||||
if (empty($arrData['rs_ming_zi']) || empty($arrData['rsfz_id'])) {
|
||||
throw new \Exception("热搜词信息不全!");
|
||||
}
|
||||
|
||||
$ReSouModel = self::where('rs_ming_zi', $arrData['rs_ming_zi'])->find();
|
||||
if ($ReSouModel) {
|
||||
return $ReSouModel;
|
||||
}
|
||||
|
||||
$ReSouModel = new self;
|
||||
$ReSouModel->rs_ming_zi = $arrData['rs_ming_zi'];
|
||||
$ReSouModel->rsfz_id = $arrData['rsfz_id'];
|
||||
$ReSouModel->save();
|
||||
return $ReSouModel;
|
||||
} catch (\Throwable $T) {
|
||||
if ($T->getCode() == 10501) {
|
||||
return self::addReSou($arrData);
|
||||
}
|
||||
throw $T;
|
||||
}
|
||||
}
|
||||
|
||||
static public function getRsByCache($intLimit = 2, $strSort = 'asc')
|
||||
{
|
||||
if (self::$arrReSouAll == []) {
|
||||
self::$arrReSouAll = Cache::get('RE_SOU_ALL');
|
||||
|
||||
if (empty(self::$arrReSouAll)) {
|
||||
self::flushCache();
|
||||
self::$arrReSouAll = Cache::get('RE_SOU_ALL');
|
||||
}
|
||||
}
|
||||
$arrTemp = self::$arrReSouAll;
|
||||
|
||||
if ($strSort == 'rand') {
|
||||
shuffle($arrTemp);
|
||||
}
|
||||
|
||||
return array_slice($arrTemp, 0, $intLimit);
|
||||
}
|
||||
|
||||
static public function getFomartDataByCache()
|
||||
{
|
||||
if (self::$arrReSou == []) {
|
||||
self::$arrReSou = Cache::get('RE_SOU');
|
||||
|
||||
if (empty(self::$arrReSou)) {
|
||||
self::flushCache();
|
||||
self::$arrReSou = Cache::get('RE_SOU');
|
||||
}
|
||||
}
|
||||
|
||||
return self::$arrReSou;
|
||||
}
|
||||
|
||||
static public function flushCache()
|
||||
{
|
||||
$FenZu = ReSouFenZuModel::order('rsfz_pai_xu', 'asc')->select();
|
||||
$arrFenZu = [];
|
||||
foreach ($FenZu as $FenZuOne) {
|
||||
$arrFenZu[$FenZuOne->rsfz_id] = $FenZuOne->toArray();
|
||||
$arrFenZu[$FenZuOne->rsfz_id]['child'] = [];
|
||||
}
|
||||
|
||||
|
||||
$ReSou = self::select();
|
||||
|
||||
foreach ($ReSou as $ReSouOne) {
|
||||
$arrFenZu[$ReSouOne->rsfz_id]['child'][] = $ReSouOne->toArray();
|
||||
}
|
||||
|
||||
$arrFenZu = array_values($arrFenZu);
|
||||
|
||||
Cache::tag('RE_SOU')->set('RE_SOU', $arrFenZu);
|
||||
Cache::tag('RE_SOU_ALL')->set('RE_SOU_ALL', $ReSou->toArray());
|
||||
}
|
||||
}
|
||||
63
code/app/admin/model/SeoHtmlModel.php
Normal file
63
code/app/admin/model/SeoHtmlModel.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class SeoHtmlModel extends BaseModel
|
||||
{
|
||||
protected $name = 'seo_html';
|
||||
protected $pk = 'sh_id';
|
||||
|
||||
public static function getValByHtmlPath(string $strHtmlPath): ?string
|
||||
{
|
||||
|
||||
$strSeoKeyword = Cache::get($strHtmlPath);;
|
||||
|
||||
if (!$strSeoKeyword) {
|
||||
|
||||
self::flushCache($strHtmlPath);
|
||||
|
||||
$strSeoKeyword = Cache::get($strHtmlPath);;
|
||||
}
|
||||
|
||||
return $strSeoKeyword ?? null;
|
||||
}
|
||||
|
||||
public static function flushCache(string $strHtmlPath): void
|
||||
{
|
||||
$cache = Cache::tag('SeoKeywords');
|
||||
|
||||
$strSeoKeyword = self::where('sw_html_path', $strHtmlPath)->value('sw_title');
|
||||
|
||||
if ($strSeoKeyword) {
|
||||
|
||||
$cache->set($strHtmlPath, $strSeoKeyword);
|
||||
|
||||
} else {
|
||||
|
||||
$fallbackKeyword = self::where('sw_status', 0)->find();
|
||||
|
||||
if ($fallbackKeyword) {
|
||||
|
||||
$fallbackKeyword->sw_status = 1;
|
||||
|
||||
$fallbackKeyword->sw_html_path = $strHtmlPath;
|
||||
|
||||
$fallbackKeyword->save();
|
||||
|
||||
$cache->set($strHtmlPath, $fallbackKeyword->sw_title);
|
||||
} else {
|
||||
// 如果连 sw_status = 0 的记录也没有,则可以选择不进行任何操作或进行日志记录
|
||||
// Log::warning("No available SEO keyword found for fallback.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
63
code/app/admin/model/SeoKeywordsModel.php
Normal file
63
code/app/admin/model/SeoKeywordsModel.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class SeoKeywordsModel extends BaseModel
|
||||
{
|
||||
protected $name = 'seo_keywords';
|
||||
protected $pk = 'sw_id';
|
||||
|
||||
public static function getValByHtmlPath(string $strHtmlPath): ?string
|
||||
{
|
||||
|
||||
$strSeoKeyword = Cache::get($strHtmlPath);;
|
||||
|
||||
if (!$strSeoKeyword) {
|
||||
|
||||
self::flushCache($strHtmlPath);
|
||||
|
||||
$strSeoKeyword = Cache::get($strHtmlPath);;
|
||||
}
|
||||
|
||||
return $strSeoKeyword ?? null;
|
||||
}
|
||||
|
||||
public static function flushCache(string $strHtmlPath): void
|
||||
{
|
||||
$cache = Cache::tag('SeoKeywords');
|
||||
|
||||
$strSeoKeyword = self::where('sw_html_path', $strHtmlPath)->value('sw_title');
|
||||
|
||||
if ($strSeoKeyword) {
|
||||
|
||||
$cache->set($strHtmlPath, $strSeoKeyword);
|
||||
|
||||
} else {
|
||||
|
||||
$fallbackKeyword = self::where('sw_status', 0)->find();
|
||||
|
||||
if ($fallbackKeyword) {
|
||||
|
||||
$fallbackKeyword->sw_status = 1;
|
||||
|
||||
$fallbackKeyword->sw_html_path = $strHtmlPath;
|
||||
|
||||
$fallbackKeyword->save();
|
||||
|
||||
$cache->set($strHtmlPath, $fallbackKeyword->sw_title);
|
||||
} else {
|
||||
// 如果连 sw_status = 0 的记录也没有,则可以选择不进行任何操作或进行日志记录
|
||||
// Log::warning("No available SEO keyword found for fallback.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
63
code/app/admin/model/SeoTdkConfigModel.php
Normal file
63
code/app/admin/model/SeoTdkConfigModel.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class SeoTdkConfigModel extends BaseModel
|
||||
{
|
||||
protected $name = 'seo_tdk_config';
|
||||
protected $pk = 'stc_id';
|
||||
|
||||
static $arrSeoTdkConfig = [];
|
||||
|
||||
static public function getValByCode($strCode)
|
||||
{
|
||||
|
||||
//self::flushCache();
|
||||
if (self::$arrSeoTdkConfig == []) {
|
||||
self::$arrSeoTdkConfig = Cache::get('seoTdkTonfig');
|
||||
|
||||
if (empty(self::$arrSeoTdkConfig)) {
|
||||
self::flushCache();
|
||||
self::$arrSeoTdkConfig = Cache::get('seoTdkTonfig');
|
||||
}
|
||||
}
|
||||
return self::$arrSeoTdkConfig[$strCode] ?? NULL;
|
||||
}
|
||||
|
||||
// 标签使用
|
||||
static public function getValByCodeByValCode($strCode,$strValCode)
|
||||
{
|
||||
|
||||
if (self::$arrSeoTdkConfig == []) {
|
||||
self::$arrSeoTdkConfig = Cache::get('seoTdkTonfig');
|
||||
|
||||
if (empty(self::$arrSeoTdkConfig)) {
|
||||
self::flushCache();
|
||||
self::$arrSeoTdkConfig = Cache::get('seoTdkTonfig');
|
||||
}
|
||||
}
|
||||
return self::$arrSeoTdkConfig[$strCode][$strValCode] ?? NULL;
|
||||
}
|
||||
|
||||
static public function flushCache()
|
||||
{
|
||||
// 查询所有数据
|
||||
$arrSeoTdkConfig = self::where('site_id',config('app.default_app_id'))->select()->toArray();
|
||||
|
||||
// 按照 'stc_code' 进行键值映射
|
||||
$arrSeoTdkConfig = array_column($arrSeoTdkConfig, null, 'stc_code');
|
||||
// var_dump($arrSeoTdkConfig);
|
||||
// $arrSeoTdkConfig = self::select();
|
||||
// $arrSeoTdkConfig = self::column('stc_title', 'stc_code');
|
||||
// var_dump($arrSeoTdkConfig);
|
||||
Cache::tag('seoTdkTonfig')->set('seoTdkTonfig', $arrSeoTdkConfig);
|
||||
}
|
||||
}
|
||||
82
code/app/admin/model/SiteModel.php
Normal file
82
code/app/admin/model/SiteModel.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class SiteModel extends BaseModel
|
||||
{
|
||||
protected $name = 'site';
|
||||
protected $pk = 'site_id';
|
||||
|
||||
static $arrSite = [];
|
||||
|
||||
static public function addSite($arrData): self
|
||||
{
|
||||
|
||||
try {
|
||||
$SiteModel = self::where('site_name', $arrData['site_name'])->find();
|
||||
|
||||
if ($SiteModel) {
|
||||
|
||||
return $SiteModel;
|
||||
}
|
||||
|
||||
$SiteModel = new self;
|
||||
|
||||
$SiteModel->save($arrData);
|
||||
return $SiteModel;
|
||||
} catch (\Throwable $T) {
|
||||
|
||||
throw $T; // 超过重试次数后抛出异常
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static public function getValById($intSiteId)
|
||||
{
|
||||
|
||||
//self::flushCache();
|
||||
if (self::$arrSite == []) {
|
||||
self::$arrSite = Cache::get('site');
|
||||
|
||||
if (empty(self::$arrSite)) {
|
||||
self::flushCache();
|
||||
self::$arrSite = Cache::get('site');
|
||||
}
|
||||
}
|
||||
return self::$arrSite[$intSiteId] ?? NULL;
|
||||
}
|
||||
|
||||
// 标签使用
|
||||
static public function getValBySiteIdByValCode($strValCode)
|
||||
{
|
||||
|
||||
if (self::$arrSite == []) {
|
||||
self::$arrSite = Cache::get('site');
|
||||
|
||||
if (empty(self::$arrSite)) {
|
||||
self::flushCache();
|
||||
self::$arrSite = Cache::get('site');
|
||||
}
|
||||
}
|
||||
return self::$arrSite[config('app.default_app_id')][$strValCode] ?? NULL;
|
||||
}
|
||||
|
||||
static public function flushCache()
|
||||
{
|
||||
// 查询所有数据 where('site_id',config('app.default_app_id'))
|
||||
$arrSite = self::select()->toArray();
|
||||
|
||||
// 按照 'stc_code' 进行键值映射
|
||||
$arrSite = array_column($arrSite, null, 'site_id');
|
||||
|
||||
Cache::tag('site')->set('site', $arrSite);
|
||||
}
|
||||
}
|
||||
39
code/app/admin/model/SystemConfigModel.php
Normal file
39
code/app/admin/model/SystemConfigModel.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class SystemConfigModel extends BaseModel
|
||||
{
|
||||
protected $name = 'system_config';
|
||||
protected $pk = 'sc_id';
|
||||
|
||||
static $arrSystemConfig = [];
|
||||
|
||||
static public function getValByCode($strCode)
|
||||
{
|
||||
if (self::$arrSystemConfig == []) {
|
||||
self::$arrSystemConfig = Cache::get('Config');
|
||||
|
||||
if (empty(self::$arrSystemConfig)) {
|
||||
self::flushCache();
|
||||
self::$arrSystemConfig = Cache::get('Config');
|
||||
}
|
||||
}
|
||||
|
||||
return self::$arrSystemConfig[$strCode] ?? NULL;
|
||||
}
|
||||
|
||||
static public function flushCache()
|
||||
{
|
||||
$arrSystemConfig = self::column('sc_val', 'sc_code');
|
||||
Cache::tag('Config')->set('Config', $arrSystemConfig);
|
||||
}
|
||||
}
|
||||
112
code/app/admin/model/VideoClassModel.php
Normal file
112
code/app/admin/model/VideoClassModel.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class VideoClassModel extends BaseModel
|
||||
{
|
||||
protected $name = 'video_class';
|
||||
protected $pk = 'vc_id';
|
||||
|
||||
static $arrVideoShuoFenLei = [];
|
||||
|
||||
static public function addVideoFenLei($arrData): self
|
||||
{
|
||||
try {
|
||||
if (empty($arrData['vc_name'])) {
|
||||
throw new \Exception("分类信息不全!");
|
||||
}
|
||||
|
||||
$VideoFenLeiModel = self::where('vc_name', $arrData['vc_name'])->find();
|
||||
if ($VideoFenLeiModel) {
|
||||
return $VideoFenLeiModel;
|
||||
}
|
||||
|
||||
$VideoFenLeiModel = new self;
|
||||
$VideoFenLeiModel->vc_name = $arrData['vc_name'];
|
||||
$VideoFenLeiModel->save();
|
||||
return $VideoFenLeiModel;
|
||||
} catch (\Throwable $T) {
|
||||
|
||||
if ($T->getCode() == 10501) {
|
||||
return self::addVideoFenLei($arrData);
|
||||
}
|
||||
throw $T;
|
||||
}
|
||||
}
|
||||
|
||||
static public function getIdByName($strName)
|
||||
{
|
||||
$intId = 0;
|
||||
foreach (self::$arrVideoShuoFenLei as $arrFenLei) {
|
||||
if ($arrFenLei['vc_name'] == $strName) {
|
||||
$intId = $arrFenLei['vc_id'];
|
||||
}
|
||||
}
|
||||
return $intId;
|
||||
}
|
||||
|
||||
static public function getNameById($intId)
|
||||
{
|
||||
static::getDataByCache();
|
||||
$strName = '未知';
|
||||
foreach (self::$arrVideoShuoFenLei as $arrFenLei) {
|
||||
if ($arrFenLei['vc_id'] === $intId) {
|
||||
$strName = $arrFenLei['vc_name'];
|
||||
}
|
||||
}
|
||||
return $strName;
|
||||
}
|
||||
|
||||
static public function getInfoById($intId)
|
||||
{
|
||||
$arrDefault = ['vc_id' => 1, 'vc_name' => '电影' , 'vc_necheng' => 'dy'];
|
||||
foreach (self::$arrVideoShuoFenLei as $arrFenLei) {
|
||||
if ($arrFenLei['vc_id'] == $intId) {
|
||||
$arrDefault = $arrFenLei;
|
||||
}
|
||||
}
|
||||
return $arrDefault;
|
||||
}
|
||||
|
||||
static public function getInfoByNeCheng($strNeCheng)
|
||||
{
|
||||
$arrDefault = ['vc_id' => 1, 'vc_source_id' => 1,'vc_name' => '电影' , 'vc_necheng' => 'dy'];
|
||||
|
||||
foreach (self::$arrVideoShuoFenLei as $arrFenLei) {
|
||||
if ($arrFenLei['vc_nicheng'] == $strNeCheng) {
|
||||
$arrDefault = $arrFenLei;
|
||||
}
|
||||
}
|
||||
return $arrDefault;
|
||||
}
|
||||
|
||||
|
||||
static public function getDataByCache()
|
||||
{
|
||||
if (self::$arrVideoShuoFenLei == []) {
|
||||
self::$arrVideoShuoFenLei = Cache::get('VIDEO_FEN_LEI');
|
||||
|
||||
if (empty(self::$arrVideoShuoFenLei)) {
|
||||
self::flushCache();
|
||||
self::$arrVideoShuoFenLei = Cache::get('VIDEO_FEN_LEI');
|
||||
}
|
||||
}
|
||||
|
||||
return self::$arrVideoShuoFenLei;
|
||||
}
|
||||
|
||||
static public function flushCache()
|
||||
{
|
||||
$arrVideoShuoFenLei = self::where('vc_status', 1)->where('site_id',config('app.default_app_id'))->order('vc_sort', 'asc')->select()->toArray();
|
||||
self::$arrVideoShuoFenLei = $arrVideoShuoFenLei;
|
||||
Cache::tag('VIDEO_FEN_LEI')->set('VIDEO_FEN_LEI', $arrVideoShuoFenLei);
|
||||
}
|
||||
}
|
||||
90
code/app/admin/model/VideoDiquModel.php
Normal file
90
code/app/admin/model/VideoDiquModel.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class VideoDiquModel extends BaseModel
|
||||
{
|
||||
protected $name = 'video_diqu';
|
||||
protected $pk = 'vd_id';
|
||||
|
||||
static $arrVideoShuoFenLei = [];
|
||||
|
||||
static public function add($arrData): self
|
||||
{
|
||||
try {
|
||||
if (empty($arrData['vd_name'])) {
|
||||
throw new \Exception("地区信息不全!");
|
||||
}else{
|
||||
$VideoFenLeiModel = self::where('vd_name', $arrData['vd_name'])->where('vc_id', $arrData['vc_id'])->find();
|
||||
if ($VideoFenLeiModel) {
|
||||
return $VideoFenLeiModel;
|
||||
}
|
||||
|
||||
$VideoFenLeiModel = new self;
|
||||
$VideoFenLeiModel->save($arrData);
|
||||
return $VideoFenLeiModel;
|
||||
}
|
||||
|
||||
|
||||
} catch (\Throwable $T) {
|
||||
|
||||
if ($T->getCode() == 10501) {
|
||||
//return self::add($arrData);
|
||||
}
|
||||
throw $T;
|
||||
}
|
||||
}
|
||||
|
||||
static public function getIdByName($strName)
|
||||
{
|
||||
$intId = 0;
|
||||
foreach (self::$arrVideoShuoFenLei as $arrFenLei) {
|
||||
if ($arrFenLei['vd_name'] == $strName) {
|
||||
$intId = $arrFenLei['vd_id'];
|
||||
}
|
||||
}
|
||||
return $intId;
|
||||
}
|
||||
|
||||
static public function getNameById($intId)
|
||||
{
|
||||
static::getDataByCache();
|
||||
$strName = '未知';
|
||||
// var_dump(self::$arrXiaoShuoFenLei);
|
||||
foreach (self::$arrVideoShuoFenLei as $arrFenLei) {
|
||||
if ($arrFenLei['vd_id'] === $intId) {
|
||||
$strName = $arrFenLei['vd_name'];
|
||||
}
|
||||
}
|
||||
return $strName;
|
||||
}
|
||||
|
||||
static public function getDataByCache()
|
||||
{
|
||||
if (self::$arrVideoShuoFenLei == []) {
|
||||
self::$arrVideoShuoFenLei = Cache::get('VIDEO_DI_QU');
|
||||
|
||||
if (empty(self::$arrVideoShuoFenLei)) {
|
||||
self::flushCache();
|
||||
self::$arrVideoShuoFenLei = Cache::get('VIDEO_DI_QU');
|
||||
}
|
||||
}
|
||||
|
||||
return self::$arrVideoShuoFenLei;
|
||||
}
|
||||
|
||||
static public function flushCache()
|
||||
{
|
||||
$arrVideoShuoFenLei = self::select()->toArray();
|
||||
|
||||
Cache::tag('VIDEO_DI_QU')->set('VIDEO_DI_QU', $arrVideoShuoFenLei);
|
||||
}
|
||||
}
|
||||
119
code/app/admin/model/VideoInfoModel.php
Normal file
119
code/app/admin/model/VideoInfoModel.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
use app\admin\model\XiaoShuoFenLeiModel;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class VideoInfoModel extends BaseModel
|
||||
{
|
||||
protected $name = 'video_info';
|
||||
protected $pk = 'v_id';
|
||||
|
||||
protected $append = [
|
||||
'video_feng_mian_url',
|
||||
'vc_name',
|
||||
'arr_daoyan',
|
||||
'arr_zhuyan',
|
||||
'arr_juqing',
|
||||
];
|
||||
|
||||
public function getArrDaoyanAttr($value, $data)
|
||||
{
|
||||
if(!empty($data['v_daoyan'])){
|
||||
$arrDaoyan = explode(",", $data['v_daoyan']);
|
||||
return $arrDaoyan;
|
||||
}
|
||||
}
|
||||
|
||||
public function getArrZhuyanAttr($value, $data)
|
||||
{
|
||||
if(!empty($data['v_zhuyan'])){
|
||||
$arrZhuyan = explode(",", $data['v_zhuyan']);
|
||||
return $arrZhuyan;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getArrJuqingAttr($value, $data)
|
||||
{
|
||||
if(!empty($data['v_juqing'])){
|
||||
$arrJuqing = explode(",", $data['v_juqing']);
|
||||
return $arrJuqing;
|
||||
}
|
||||
}
|
||||
|
||||
public function getVideoFengMianUrlAttr($value, $data)
|
||||
{
|
||||
// 检查 v_cover 字段是否存在并解析 JSON 数据
|
||||
$arrUrl = isset($data['v_cover']) ? json_decode($data['v_cover'], true) : null;
|
||||
|
||||
if (json_last_error() !== JSON_ERROR_NONE || !is_array($arrUrl)) {
|
||||
// 如果 JSON 解析失败或结果不是数组,返回默认值
|
||||
return null; // 或者返回一个默认图片地址,例如: '/static/images/default.png'
|
||||
}
|
||||
|
||||
// 解析域名 (可替换成动态域名获取逻辑)
|
||||
// $strDomain = ZiYuanDuanDianModel::getDomainByCode($arrUrl['code']);
|
||||
// $strDomain = "https://www.123yqw.com";
|
||||
|
||||
// 构造完整的封面 URL
|
||||
$uri = $arrUrl['uri'] ?? null;
|
||||
|
||||
if (!$uri) {
|
||||
// 如果没有 URI 字段,返回默认值
|
||||
return null; // 或默认图片地址
|
||||
}
|
||||
|
||||
// 返回完整 URL (如果需要加域名,可在此处理)
|
||||
return $uri; // 或 "{$strDomain}{$uri}" 如果域名需要拼接
|
||||
}
|
||||
|
||||
|
||||
public function getXsxqTagAttr($value, $data)
|
||||
{
|
||||
return json_decode($data['xsxq_tag'], true);
|
||||
}
|
||||
|
||||
public function getXsflNameAttr($value, $data)
|
||||
{
|
||||
$strXiaoShuoFenLeiName = XiaoShuoFenLeiModel::getNameById($data['xsfl_id']);
|
||||
|
||||
return $strXiaoShuoFenLeiName;
|
||||
}
|
||||
|
||||
static public function addVideoXiangQing($arrData): array
|
||||
{
|
||||
try {
|
||||
$VideoXiangQingModel = self::where('v_md5', $arrData['v_md5'])->find();
|
||||
|
||||
if ($VideoXiangQingModel) {
|
||||
|
||||
return [
|
||||
'model' => $VideoXiangQingModel,
|
||||
'isNew' => false, // 已存在
|
||||
];
|
||||
}
|
||||
$VideoXiangQingModel = new self;
|
||||
$VideoXiangQingModel->save($arrData);
|
||||
return [
|
||||
'model' => $VideoXiangQingModel,
|
||||
'isNew' => true, // 新增
|
||||
];
|
||||
|
||||
} catch (\Throwable $T) {
|
||||
|
||||
throw $T; // 超过重试次数后抛出异常
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
41
code/app/admin/model/VideoInfoSeoModel.php
Normal file
41
code/app/admin/model/VideoInfoSeoModel.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class VideoInfoSeoModel extends BaseModel
|
||||
{
|
||||
protected $name = 'video_info_seo';
|
||||
protected $pk = 'vis_id';
|
||||
|
||||
|
||||
|
||||
static public function addVideoSeo($arrData): self
|
||||
{
|
||||
|
||||
try {
|
||||
$VideoModel = self::where('vis_md5', $arrData['vis_md5'])->find();
|
||||
|
||||
if ($VideoModel) {
|
||||
|
||||
return $VideoModel;
|
||||
}
|
||||
|
||||
$VideoModel = new self;
|
||||
|
||||
$VideoModel->save($arrData);
|
||||
return $VideoModel;
|
||||
} catch (\Throwable $T) {
|
||||
|
||||
throw $T; // 超过重试次数后抛出异常
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
90
code/app/admin/model/VideoJuqingModel.php
Normal file
90
code/app/admin/model/VideoJuqingModel.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class VideoJuqingModel extends BaseModel
|
||||
{
|
||||
protected $name = 'video_juqing';
|
||||
protected $pk = 'vj_id';
|
||||
|
||||
static $arrVideoShuoFenLei = [];
|
||||
|
||||
static public function add($arrData): self
|
||||
{
|
||||
try {
|
||||
if (empty($arrData['vj_name'])) {
|
||||
throw new \Exception("剧情信息不全!");
|
||||
}else{
|
||||
$VideoFenLeiModel = self::where('vj_name', $arrData['vj_name'])->where('vc_id', $arrData['vc_id'])->find();
|
||||
if ($VideoFenLeiModel) {
|
||||
return $VideoFenLeiModel;
|
||||
}
|
||||
|
||||
$VideoFenLeiModel = new self;
|
||||
$VideoFenLeiModel->save($arrData);
|
||||
return $VideoFenLeiModel;
|
||||
}
|
||||
|
||||
|
||||
} catch (\Throwable $T) {
|
||||
|
||||
if ($T->getCode() == 10501) {
|
||||
//return self::add($arrData);
|
||||
}
|
||||
throw $T;
|
||||
}
|
||||
}
|
||||
|
||||
static public function getIdByName($strName)
|
||||
{
|
||||
$intId = 0;
|
||||
foreach (self::$arrVideoShuoFenLei as $arrFenLei) {
|
||||
if ($arrFenLei['vj_name'] == $strName) {
|
||||
$intId = $arrFenLei['vj_id'];
|
||||
}
|
||||
}
|
||||
return $intId;
|
||||
}
|
||||
|
||||
static public function getNameById($intId)
|
||||
{
|
||||
static::getDataByCache();
|
||||
$strName = '未知';
|
||||
// var_dump(self::$arrXiaoShuoFenLei);
|
||||
foreach (self::$arrVideoShuoFenLei as $arrFenLei) {
|
||||
if ($arrFenLei['vj_id'] === $intId) {
|
||||
$strName = $arrFenLei['vj_name'];
|
||||
}
|
||||
}
|
||||
return $strName;
|
||||
}
|
||||
|
||||
static public function getDataByCache()
|
||||
{
|
||||
if (self::$arrVideoShuoFenLei == []) {
|
||||
self::$arrVideoShuoFenLei = Cache::get('VIDEO_JU_QING');
|
||||
|
||||
if (empty(self::$arrVideoShuoFenLei)) {
|
||||
self::flushCache();
|
||||
self::$arrVideoShuoFenLei = Cache::get('VIDEO_JU_QING');
|
||||
}
|
||||
}
|
||||
|
||||
return self::$arrVideoShuoFenLei;
|
||||
}
|
||||
|
||||
static public function flushCache()
|
||||
{
|
||||
$arrVideoShuoFenLei = self::select()->toArray();
|
||||
|
||||
Cache::tag('VIDEO_JU_QING')->set('VIDEO_JU_QING', $arrVideoShuoFenLei);
|
||||
}
|
||||
}
|
||||
90
code/app/admin/model/VideoLeixinModel.php
Normal file
90
code/app/admin/model/VideoLeixinModel.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class VideoLeixinModel extends BaseModel
|
||||
{
|
||||
protected $name = 'video_leixin';
|
||||
protected $pk = 'vl_id';
|
||||
|
||||
static $arrVideoShuoFenLei = [];
|
||||
|
||||
static public function addVideoLeixin($arrData): self
|
||||
{
|
||||
try {
|
||||
if (empty($arrData['vl_name'])) {
|
||||
throw new \Exception("类型信息不全!");
|
||||
}else{
|
||||
$VideoFenLeiModel = self::where('vl_name', $arrData['vl_name'])->where('vc_id', $arrData['vc_id'])->find();
|
||||
if ($VideoFenLeiModel) {
|
||||
return $VideoFenLeiModel;
|
||||
}
|
||||
|
||||
$VideoFenLeiModel = new self;
|
||||
$VideoFenLeiModel->save($arrData);
|
||||
return $VideoFenLeiModel;
|
||||
}
|
||||
|
||||
|
||||
} catch (\Throwable $T) {
|
||||
|
||||
if ($T->getCode() == 10501) {
|
||||
//return self::addVideoLeixin($arrData);
|
||||
}
|
||||
throw $T;
|
||||
}
|
||||
}
|
||||
|
||||
static public function getIdByName($strName)
|
||||
{
|
||||
$intId = 0;
|
||||
foreach (self::$arrVideoShuoFenLei as $arrFenLei) {
|
||||
if ($arrFenLei['vl_name'] == $strName) {
|
||||
$intId = $arrFenLei['vl_id'];
|
||||
}
|
||||
}
|
||||
return $intId;
|
||||
}
|
||||
|
||||
static public function getNameById($intId)
|
||||
{
|
||||
static::getDataByCache();
|
||||
$strName = '未知';
|
||||
// var_dump(self::$arrXiaoShuoFenLei);
|
||||
foreach (self::$arrVideoShuoFenLei as $arrFenLei) {
|
||||
if ($arrFenLei['vl_id'] === $intId) {
|
||||
$strName = $arrFenLei['vl_name'];
|
||||
}
|
||||
}
|
||||
return $strName;
|
||||
}
|
||||
|
||||
static public function getDataByCache()
|
||||
{
|
||||
if (self::$arrVideoShuoFenLei == []) {
|
||||
self::$arrVideoShuoFenLei = Cache::get('VIDEO_LEI_XIN');
|
||||
|
||||
if (empty(self::$arrVideoShuoFenLei)) {
|
||||
self::flushCache();
|
||||
self::$arrVideoShuoFenLei = Cache::get('VIDEO_LEI_XIN');
|
||||
}
|
||||
}
|
||||
|
||||
return self::$arrVideoShuoFenLei;
|
||||
}
|
||||
|
||||
static public function flushCache()
|
||||
{
|
||||
$arrVideoShuoFenLei = self::select()->toArray();
|
||||
|
||||
Cache::tag('VIDEO_LEI_XIN')->set('VIDEO_LEI_XIN', $arrVideoShuoFenLei);
|
||||
}
|
||||
}
|
||||
96
code/app/admin/model/VideoPlayurlModel.php
Normal file
96
code/app/admin/model/VideoPlayurlModel.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class VideoPlayurlModel extends BaseModel
|
||||
{
|
||||
protected $name = 'video_playurl';
|
||||
protected $pk = 'vp_id';
|
||||
|
||||
protected $append = [
|
||||
'http_m3u8_url',
|
||||
];
|
||||
|
||||
public function getHttpM3u8UrlAttr($value, $data)
|
||||
{
|
||||
$arrUrl = json_decode($data['vp_url'], true);
|
||||
|
||||
// $strDomain = ZiYuanDuanDianModel::getDomainByCode($arrUrl['code']);
|
||||
|
||||
// $strDomain = "https://www.123yqw.com";
|
||||
|
||||
return $arrUrl['uri'] ?? '';
|
||||
}
|
||||
|
||||
static public function add($arrData): array
|
||||
{
|
||||
try {
|
||||
// 查询是否已存在
|
||||
$XiaoShuoZhangJieModel = self::where('vp_md5', $arrData['vp_md5'])->find();
|
||||
|
||||
// 如果已存在,返回已有模型
|
||||
if ($XiaoShuoZhangJieModel) {
|
||||
return [
|
||||
'model' => $XiaoShuoZhangJieModel,
|
||||
'isNew' => false, // 已存在
|
||||
];
|
||||
}
|
||||
|
||||
// 新增数据
|
||||
$XiaoShuoZhangJieModel = new self;
|
||||
$XiaoShuoZhangJieModel->save($arrData);
|
||||
|
||||
return [
|
||||
'model' => $XiaoShuoZhangJieModel,
|
||||
'isNew' => true, // 新增
|
||||
];
|
||||
} catch (\Throwable $T) {
|
||||
var_dump($T);
|
||||
throw $T;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// static public function add($arrData): self
|
||||
// {
|
||||
|
||||
// try {
|
||||
// $XiaoShuoZhangJieModel = self::where('vp_md5', $arrData['vp_md5'])->find();
|
||||
// if ($XiaoShuoZhangJieModel) {
|
||||
// return $XiaoShuoZhangJieModel;
|
||||
// }
|
||||
|
||||
// $XiaoShuoZhangJieModel = new self;
|
||||
|
||||
// $XiaoShuoZhangJieModel->save($arrData);
|
||||
// return $XiaoShuoZhangJieModel;
|
||||
|
||||
// } catch (\Throwable $T) {
|
||||
// var_dump($T);
|
||||
// // if ($T->getCode() == 10501) {
|
||||
// // return self::add($arrData);
|
||||
// // }
|
||||
// throw $T;
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 判断章节是否存在
|
||||
*
|
||||
* @param bool $strXszjSourceCode
|
||||
* @return void
|
||||
*/
|
||||
static public function checkZhangJieExists($strXszjSourceCode)
|
||||
{
|
||||
$XiaoShuoZhangJieModel = self::where('vp_md5', $strXszjSourceCode)->find();
|
||||
return !empty($XiaoShuoZhangJieModel);
|
||||
}
|
||||
}
|
||||
90
code/app/admin/model/VideoYearsModel.php
Normal file
90
code/app/admin/model/VideoYearsModel.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class VideoYearsModel extends BaseModel
|
||||
{
|
||||
protected $name = 'video_years';
|
||||
protected $pk = 'vy_id';
|
||||
|
||||
static $arrVideoShuoFenLei = [];
|
||||
|
||||
static public function add($arrData): self
|
||||
{
|
||||
try {
|
||||
if (empty($arrData['vy_name'])) {
|
||||
throw new \Exception("年份信息不全!");
|
||||
}else{
|
||||
$VideoFenLeiModel = self::where('vy_name', $arrData['vy_name'])->where('vc_id', $arrData['vc_id'])->find();
|
||||
if ($VideoFenLeiModel) {
|
||||
return $VideoFenLeiModel;
|
||||
}
|
||||
|
||||
$VideoFenLeiModel = new self;
|
||||
$VideoFenLeiModel->save($arrData);
|
||||
return $VideoFenLeiModel;
|
||||
}
|
||||
|
||||
|
||||
} catch (\Throwable $T) {
|
||||
|
||||
if ($T->getCode() == 10501) {
|
||||
//return self::add($arrData);
|
||||
}
|
||||
throw $T;
|
||||
}
|
||||
}
|
||||
|
||||
static public function getIdByName($strName)
|
||||
{
|
||||
$intId = 0;
|
||||
foreach (self::$arrVideoShuoFenLei as $arrFenLei) {
|
||||
if ($arrFenLei['vy_name'] == $strName) {
|
||||
$intId = $arrFenLei['vy_id'];
|
||||
}
|
||||
}
|
||||
return $intId;
|
||||
}
|
||||
|
||||
static public function getNameById($intId)
|
||||
{
|
||||
static::getDataByCache();
|
||||
$strName = '未知';
|
||||
// var_dump(self::$arrXiaoShuoFenLei);
|
||||
foreach (self::$arrVideoShuoFenLei as $arrFenLei) {
|
||||
if ($arrFenLei['vy_id'] === $intId) {
|
||||
$strName = $arrFenLei['vy_name'];
|
||||
}
|
||||
}
|
||||
return $strName;
|
||||
}
|
||||
|
||||
static public function getDataByCache()
|
||||
{
|
||||
if (self::$arrVideoShuoFenLei == []) {
|
||||
self::$arrVideoShuoFenLei = Cache::get('VIDEO_YEARS');
|
||||
|
||||
if (empty(self::$arrVideoShuoFenLei)) {
|
||||
self::flushCache();
|
||||
self::$arrVideoShuoFenLei = Cache::get('VIDEO_YEARS');
|
||||
}
|
||||
}
|
||||
|
||||
return self::$arrVideoShuoFenLei;
|
||||
}
|
||||
|
||||
static public function flushCache()
|
||||
{
|
||||
$arrVideoShuoFenLei = self::select()->toArray();
|
||||
|
||||
Cache::tag('VIDEO_YEARS')->set('VIDEO_YEARS', $arrVideoShuoFenLei);
|
||||
}
|
||||
}
|
||||
90
code/app/admin/model/VideoYuyanModel.php
Normal file
90
code/app/admin/model/VideoYuyanModel.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class VideoYuyanModel extends BaseModel
|
||||
{
|
||||
protected $name = 'video_language';
|
||||
protected $pk = 'vla_id';
|
||||
|
||||
static $arrVideoShuoFenLei = [];
|
||||
|
||||
static public function add($arrData): self
|
||||
{
|
||||
try {
|
||||
if (empty($arrData['vla_name'])) {
|
||||
throw new \Exception("年份信息不全!");
|
||||
}else{
|
||||
$VideoFenLeiModel = self::where('vla_name', $arrData['vla_name'])->where('vc_id', $arrData['vc_id'])->find();
|
||||
if ($VideoFenLeiModel) {
|
||||
return $VideoFenLeiModel;
|
||||
}
|
||||
|
||||
$VideoFenLeiModel = new self;
|
||||
$VideoFenLeiModel->save($arrData);
|
||||
return $VideoFenLeiModel;
|
||||
}
|
||||
|
||||
|
||||
} catch (\Throwable $T) {
|
||||
|
||||
if ($T->getCode() == 10501) {
|
||||
//return self::add($arrData);
|
||||
}
|
||||
throw $T;
|
||||
}
|
||||
}
|
||||
|
||||
static public function getIdByName($strName)
|
||||
{
|
||||
$intId = 0;
|
||||
foreach (self::$arrVideoShuoFenLei as $arrFenLei) {
|
||||
if ($arrFenLei['vla_name'] == $strName) {
|
||||
$intId = $arrFenLei['vla_id'];
|
||||
}
|
||||
}
|
||||
return $intId;
|
||||
}
|
||||
|
||||
static public function getNameById($intId)
|
||||
{
|
||||
static::getDataByCache();
|
||||
$strName = '未知';
|
||||
// var_dump(self::$arrXiaoShuoFenLei);
|
||||
foreach (self::$arrVideoShuoFenLei as $arrFenLei) {
|
||||
if ($arrFenLei['vla_id'] === $intId) {
|
||||
$strName = $arrFenLei['vla_name'];
|
||||
}
|
||||
}
|
||||
return $strName;
|
||||
}
|
||||
|
||||
static public function getDataByCache()
|
||||
{
|
||||
if (self::$arrVideoShuoFenLei == []) {
|
||||
self::$arrVideoShuoFenLei = Cache::get('VIDEO_YUYAN');
|
||||
|
||||
if (empty(self::$arrVideoShuoFenLei)) {
|
||||
self::flushCache();
|
||||
self::$arrVideoShuoFenLei = Cache::get('VIDEO_YUYAN');
|
||||
}
|
||||
}
|
||||
|
||||
return self::$arrVideoShuoFenLei;
|
||||
}
|
||||
|
||||
static public function flushCache()
|
||||
{
|
||||
$arrVideoShuoFenLei = self::select()->toArray();
|
||||
|
||||
Cache::tag('VIDEO_YUYAN')->set('VIDEO_YUYAN', $arrVideoShuoFenLei);
|
||||
}
|
||||
}
|
||||
63
code/app/admin/model/VisitLogsModel.php
Normal file
63
code/app/admin/model/VisitLogsModel.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class VisitLogsModel extends BaseModel
|
||||
{
|
||||
protected $name = 'visit_logs';
|
||||
protected $pk = 'vil_id';
|
||||
|
||||
static public function add(array $arrData): self
|
||||
{
|
||||
// 处理数据,避免 undefined index 问题
|
||||
$arrData = [
|
||||
'vil_ip' => $arrData['vil_ip'] ?? '',
|
||||
'vil_user_agent' => $arrData['vil_user_agent'] ?? '',
|
||||
'vil_url' => $arrData['vil_url'] ?? '',
|
||||
'vil_method' => $arrData['vil_method'] ?? '',
|
||||
'vil_headers' => $arrData['vil_headers'] ?? '',
|
||||
'vil_timestamp' => date('Y-m-d H:i:s'),
|
||||
'vil_content_type' => $arrData['vil_content_type'] ?? '',
|
||||
'vil_content_id' => $arrData['vil_content_id'] ?? '',
|
||||
'vil_is_spider' => $arrData['vil_is_spider'] ?? '',
|
||||
'vil_location' => $arrData['vil_location'] ?? '',
|
||||
];
|
||||
|
||||
try {
|
||||
// 必填字段校验
|
||||
$requiredFields = ['vil_ip', 'vil_url', 'vil_content_id', 'vil_content_type', 'vil_method'];
|
||||
foreach ($requiredFields as $field) {
|
||||
if (empty($arrData[$field])) {
|
||||
var_dump('字段缺失: {}'.$field);
|
||||
// throw new \InvalidArgumentException("字段缺失: {$field}");
|
||||
}
|
||||
}
|
||||
|
||||
// 创建模型实例
|
||||
$visitLogModel = new self;
|
||||
|
||||
// 保存数据
|
||||
if (!$visitLogModel::create($arrData)) {
|
||||
var_dump('保存失败: ');
|
||||
// throw new \RuntimeException('访问日志保存失败: ' . json_encode($arrData, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
return $visitLogModel;
|
||||
} catch (\Throwable $T) {
|
||||
// 如果错误码是 10501,可以在这里做特殊处理
|
||||
if ($T->getCode() == 10501) {
|
||||
// 记录日志或进行备用操作
|
||||
// logError($T->getMessage());
|
||||
}
|
||||
|
||||
throw $T; // 继续抛出异常
|
||||
}
|
||||
}
|
||||
}
|
||||
92
code/app/admin/model/XiaoShuoFenLeiModel.php
Normal file
92
code/app/admin/model/XiaoShuoFenLeiModel.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class XiaoShuoFenLeiModel extends BaseModel
|
||||
{
|
||||
protected $name = 'xiao_shuo_fen_lei';
|
||||
protected $pk = 'xsfl_id';
|
||||
|
||||
static $arrXiaoShuoFenLei = [];
|
||||
|
||||
static public function addXiaoShuoFenLei($arrData): self
|
||||
{
|
||||
try {
|
||||
if (empty($arrData['xsfl_name']) || empty($arrData['xsfl_source_id'])) {
|
||||
throw new \Exception("小说分类信息不全!");
|
||||
}
|
||||
|
||||
$XiaoShuoFenLeiModel = self::where('xsfl_name', $arrData['xsfl_name'])->find();
|
||||
if ($XiaoShuoFenLeiModel) {
|
||||
return $XiaoShuoFenLeiModel;
|
||||
}
|
||||
|
||||
$XiaoShuoFenLeiModel = new self;
|
||||
$XiaoShuoFenLeiModel->xsfl_source_id = $arrData['xsfl_source_id'];
|
||||
$XiaoShuoFenLeiModel->xsfl_source_code = $arrData['xsfl_source_code'];
|
||||
$XiaoShuoFenLeiModel->xsfl_name = $arrData['xsfl_name'];
|
||||
$XiaoShuoFenLeiModel->save();
|
||||
return $XiaoShuoFenLeiModel;
|
||||
} catch (\Throwable $T) {
|
||||
|
||||
if ($T->getCode() == 10501) {
|
||||
return self::addXiaoShuoFenLei($arrData);
|
||||
}
|
||||
throw $T;
|
||||
}
|
||||
}
|
||||
|
||||
static public function getIdByName($strName)
|
||||
{
|
||||
$intId = 0;
|
||||
foreach (self::$arrXiaoShuoFenLei as $arrFenLei) {
|
||||
if ($arrFenLei['xsfl_name'] == $strName && $arrFenLei['site_id'] == config('app.default_app_id')) {
|
||||
$intId = $arrFenLei['xsfl_id'];
|
||||
}
|
||||
}
|
||||
return $intId;
|
||||
}
|
||||
|
||||
static public function getNameById($intId)
|
||||
{
|
||||
static::getDataByCache();
|
||||
$strName = '全部';
|
||||
foreach (self::$arrXiaoShuoFenLei as $arrFenLei) {
|
||||
if ($arrFenLei['xsfl_source_id'] == $intId && $arrFenLei['site_id'] == config('app.default_app_id')) {
|
||||
$strName = $arrFenLei['xsfl_name'];
|
||||
}
|
||||
}
|
||||
return $strName;
|
||||
}
|
||||
|
||||
static public function getDataByCache()
|
||||
{
|
||||
$strCacheKey = 'XIAO_SHUO_FEN_LEI';
|
||||
if (self::$arrXiaoShuoFenLei == []) {
|
||||
self::$arrXiaoShuoFenLei = Cache::get( $strCacheKey);
|
||||
|
||||
if (empty(self::$arrXiaoShuoFenLei)) {
|
||||
self::flushCache();
|
||||
self::$arrXiaoShuoFenLei = Cache::get( $strCacheKey);
|
||||
}
|
||||
}
|
||||
|
||||
return self::$arrXiaoShuoFenLei;
|
||||
}
|
||||
|
||||
static public function flushCache()
|
||||
{
|
||||
$strCacheKey = 'XIAO_SHUO_FEN_LEI';
|
||||
$arrXiaoShuoFenLei = self::where('site_id',config('app.default_app_id'))->select()->toArray();
|
||||
|
||||
Cache::tag( $strCacheKey)->set( $strCacheKey, $arrXiaoShuoFenLei);
|
||||
}
|
||||
}
|
||||
86
code/app/admin/model/XiaoShuoXiangQingModel.php
Normal file
86
code/app/admin/model/XiaoShuoXiangQingModel.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
use app\admin\model\XiaoShuoFenLeiModel;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class XiaoShuoXiangQingModel extends BaseModel
|
||||
{
|
||||
protected $name = 'xiao_shuo_xiang_qing';
|
||||
protected $pk = 'xsxq_id';
|
||||
|
||||
protected $append = [
|
||||
'xsxq_feng_mian_url',
|
||||
'xsfl_name',
|
||||
];
|
||||
|
||||
public function getXsxqFengMianUrlAttr($value, $data)
|
||||
{
|
||||
if(!empty($data['xsxq_feng_mian'])){
|
||||
$arrUrl = json_decode($data['xsxq_feng_mian'], true);
|
||||
|
||||
$strDomain = ZiYuanDuanDianModel::getDomainByCode($arrUrl['code']);
|
||||
|
||||
return $strDomain . $arrUrl['uri'];
|
||||
}
|
||||
return '';
|
||||
|
||||
}
|
||||
|
||||
public function getXsxqTagAttr($value, $data)
|
||||
{
|
||||
return json_decode($data['xsxq_tag'], true);
|
||||
}
|
||||
|
||||
public function getXsflNameAttr($value, $data)
|
||||
{
|
||||
$strXiaoShuoFenLeiName = '';
|
||||
if(!empty($data['xsfl_id'])){
|
||||
$strXiaoShuoFenLeiName = XiaoShuoFenLeiModel::getNameById($data['xsfl_id']);
|
||||
|
||||
}
|
||||
|
||||
return $strXiaoShuoFenLeiName;
|
||||
}
|
||||
|
||||
static public function addXiaoShuoXiangQing($arrData): self
|
||||
{
|
||||
|
||||
try {
|
||||
$XiaoShuoXiangQingModel = self::where('xsxq_source_code', $arrData['xsxq_source_code'])->find();
|
||||
|
||||
if ($XiaoShuoXiangQingModel) {
|
||||
|
||||
if ($XiaoShuoXiangQingModel->xsxq_geng_xin_shi_jian != $arrData['xsxq_geng_xin_shi_jian']) {
|
||||
$XiaoShuoXiangQingModel->xsxq_geng_xin_shi_jian = $arrData['xsxq_geng_xin_shi_jian'];
|
||||
$XiaoShuoXiangQingModel->xsxq_zuozhe = $arrData['xsxq_zuozhe'];
|
||||
$XiaoShuoXiangQingModel->save();
|
||||
}
|
||||
|
||||
return $XiaoShuoXiangQingModel;
|
||||
}
|
||||
|
||||
$XiaoShuoXiangQingModel = new self;
|
||||
|
||||
$XiaoShuoXiangQingModel->save($arrData);
|
||||
return $XiaoShuoXiangQingModel;
|
||||
} catch (\Throwable $T) {
|
||||
// if ($T->getCode() == 10501 && $retryCount < 3) { // 限制重试次数
|
||||
// $retryCount++;
|
||||
// return self::addXiaoShuoXiangQing($arrData, $retryCount);
|
||||
// }
|
||||
throw $T; // 超过重试次数后抛出异常
|
||||
// if ($T->getCode() == 10501) {
|
||||
// return self::addXiaoShuoXiangQing($arrData);
|
||||
// }
|
||||
// throw $T;
|
||||
}
|
||||
}
|
||||
}
|
||||
49
code/app/admin/model/XiaoShuoZhangJieModel.php
Normal file
49
code/app/admin/model/XiaoShuoZhangJieModel.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class XiaoShuoZhangJieModel extends BaseModel
|
||||
{
|
||||
protected $name = 'xiao_shuo_zhang_jie';
|
||||
protected $pk = 'xszj_id';
|
||||
|
||||
static public function addXiaoShuoZhangJie($arrData): self
|
||||
{
|
||||
try {
|
||||
$XiaoShuoZhangJieModel = self::where('xszj_source_code', $arrData['xszj_source_code'])->find();
|
||||
if ($XiaoShuoZhangJieModel) {
|
||||
return $XiaoShuoZhangJieModel;
|
||||
}
|
||||
|
||||
$XiaoShuoZhangJieModel = new self;
|
||||
|
||||
$XiaoShuoZhangJieModel->save($arrData);
|
||||
return $XiaoShuoZhangJieModel;
|
||||
} catch (\Throwable $T) {
|
||||
if ($T->getCode() == 10501) {
|
||||
return self::addXiaoShuoZhangJie($arrData);
|
||||
}
|
||||
throw $T;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断章节是否存在
|
||||
*
|
||||
* @param bool $strXszjSourceCode
|
||||
* @return void
|
||||
*/
|
||||
static public function checkZhangJieExists($strXszjSourceCode)
|
||||
{
|
||||
$XiaoShuoZhangJieModel = self::where('xszj_source_code', $strXszjSourceCode)->find();
|
||||
return !empty($XiaoShuoZhangJieModel);
|
||||
}
|
||||
}
|
||||
40
code/app/admin/model/ZiYuanDuanDianModel.php
Normal file
40
code/app/admin/model/ZiYuanDuanDianModel.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\facade\Cache;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class ZiYuanDuanDianModel extends BaseModel
|
||||
{
|
||||
protected $name = 'zi_yuan_duan_dian';
|
||||
protected $pk = 'zydd_id';
|
||||
|
||||
static $arrZiYuanDuanDian = [];
|
||||
|
||||
static public function getDomainByCode($strCode)
|
||||
{
|
||||
if (self::$arrZiYuanDuanDian == []) {
|
||||
self::$arrZiYuanDuanDian = Cache::get('Zydd');
|
||||
|
||||
if (empty(self::$arrZiYuanDuanDian)) {
|
||||
self::flushCache();
|
||||
self::$arrZiYuanDuanDian = Cache::get('Zydd');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return self::$arrZiYuanDuanDian[$strCode] ?? "";
|
||||
}
|
||||
|
||||
static public function flushCache()
|
||||
{
|
||||
$arrZiYuanDuanDian = self::column('zydd_domain', 'zydd_code');
|
||||
Cache::tag('Zydd')->set('Zydd', $arrZiYuanDuanDian);
|
||||
}
|
||||
}
|
||||
12
code/app/admin/provider.php
Normal file
12
code/app/admin/provider.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
use app\admin\AdminServiceProvider;
|
||||
use app\admin\middleware\AdminException;
|
||||
use app\ExceptionHandle;
|
||||
use app\Request;
|
||||
|
||||
// 容器Provider定义文件
|
||||
return [
|
||||
'think\Request' => Request::class,
|
||||
'think\exception\Handle' => AdminException::class,
|
||||
];
|
||||
Reference in New Issue
Block a user