This commit is contained in:
Default
2025-03-18 22:51:45 +08:00
parent eb9035a7ae
commit 526d3f47f4
103 changed files with 542 additions and 4025 deletions

View File

@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace app\admin;
use app\admin\model\AdminUserModel;
use app\model\AdminUserModel;
use app\admin\service\AdminUserAuth;
use app\Request;
use think\Container;

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace app\admin\controller;
use app\admin\BaseController;
use app\admin\model\AdminUserModel;
use app\model\AdminUserModel;
use app\admin\service\AdminUserAuth;
use app\Request;
use think\facade\Cache;

View File

@@ -5,13 +5,13 @@ 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\model\AdminUserModel;
use app\model\FenLeiModel;
use app\model\GuangGaoFenZuModel;
use app\model\GuangGaoModel;
use app\model\GuangGaoPeiZhiModel;
use app\model\NvYouModel;
use app\model\ShiPinModel;
use app\Request;
use think\Response;

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace app\admin\controller;
use app\admin\BaseController;
use app\admin\model\AdminUserModel;
use app\model\AdminUserModel;
use app\admin\service\AdminUserAuth;
use app\Request;
use think\facade\Cache;

View File

@@ -1,154 +0,0 @@
<?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();
}
}

View File

@@ -5,16 +5,16 @@ 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\model\AdminUserModel;
use app\model\BaoYangRuZhuModel;
use app\model\CaiJiPeiZhiModel;
use app\model\DaLiWanFanKuiModel;
use app\model\DaLiWanModel;
use app\model\GuanFangZiYingModel;
use app\model\LouFengModel;
use app\model\PlanTaskModel;
use app\model\SystemConfigModel;
use app\model\ZiYuanDuanDianModel;
use app\Request;
use think\Response;

View File

@@ -1,179 +0,0 @@
<?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);
}
}

View File

@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace app\admin\middleware;
use app\admin\model\AdminUserModel;
use app\model\AdminUserModel;
use app\admin\service\AdminUserAuth;
use app\Request;
use think\Response;

View File

@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace app\admin\middleware;
use app\admin\model\AdminUserModel;
use app\model\AdminUserModel;
use app\admin\service\AdminUserAuth;
use app\Request;
use think\Response;

View File

@@ -1,15 +0,0 @@
<?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';
}

View File

@@ -1,47 +0,0 @@
<?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;
}
}

View File

@@ -1,15 +0,0 @@
<?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';
}

View File

@@ -1,92 +0,0 @@
<?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;
}
}

View File

@@ -1,21 +0,0 @@
<?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;
}
}
}

View File

@@ -1,39 +0,0 @@
<?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);
}
}

View File

@@ -1,70 +0,0 @@
<?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;
}
}
}

View File

@@ -1,133 +0,0 @@
<?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;
}
}

View File

@@ -1,76 +0,0 @@
<?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");
}
}
}
}

View File

@@ -1,17 +0,0 @@
<?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';
}

View File

@@ -1,59 +0,0 @@
<?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);
}
}

View File

@@ -1,40 +0,0 @@
<?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);
}
}

View File

@@ -1,41 +0,0 @@
<?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; // 超过重试次数后抛出异常
}
}
}

View File

@@ -1,17 +0,0 @@
<?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';
}

View File

@@ -1,42 +0,0 @@
<?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;
}
}
}

View File

@@ -1,101 +0,0 @@
<?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());
}
}

View File

@@ -1,63 +0,0 @@
<?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.");
}
}
}
}

View File

@@ -1,63 +0,0 @@
<?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.");
}
}
}
}

View File

@@ -1,63 +0,0 @@
<?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);
}
}

View File

@@ -1,82 +0,0 @@
<?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);
}
}

View File

@@ -1,39 +0,0 @@
<?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);
}
}

View File

@@ -1,112 +0,0 @@
<?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);
}
}

View File

@@ -1,90 +0,0 @@
<?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);
}
}

View File

@@ -1,119 +0,0 @@
<?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; // 超过重试次数后抛出异常
}
}
}

View File

@@ -1,41 +0,0 @@
<?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; // 超过重试次数后抛出异常
}
}
}

View File

@@ -1,90 +0,0 @@
<?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);
}
}

View File

@@ -1,90 +0,0 @@
<?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);
}
}

View File

@@ -1,96 +0,0 @@
<?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);
}
}

View File

@@ -1,90 +0,0 @@
<?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);
}
}

View File

@@ -1,90 +0,0 @@
<?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);
}
}

View File

@@ -1,63 +0,0 @@
<?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; // 继续抛出异常
}
}
}

View File

@@ -1,92 +0,0 @@
<?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);
}
}

View File

@@ -1,86 +0,0 @@
<?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;
}
}
}

View File

@@ -1,49 +0,0 @@
<?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);
}
}

View File

@@ -1,40 +0,0 @@
<?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);
}
}