video tag
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace app\services;
|
||||
|
||||
use app\model\CategoryModel;
|
||||
use app\model\VideoCategoryModel;
|
||||
use app\model\VideoModel;
|
||||
|
||||
class StaticConfig
|
||||
{
|
||||
@@ -50,12 +52,19 @@ class StaticConfig
|
||||
'update' => '最新更新',
|
||||
];
|
||||
|
||||
static $arrVideoRankSortType = [
|
||||
'daily' => '天',
|
||||
'weekly' => '周',
|
||||
'monthly' => '月',
|
||||
'total' => '总',
|
||||
];
|
||||
|
||||
/**
|
||||
* GetCategoryFilter
|
||||
* getNovelCategoryFilter
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function getCategoryFilter(string $strNSex = ''): array
|
||||
static function getNovelCategoryFilter(string $strNSex = ''): array
|
||||
{
|
||||
if ($strNSex == 'man') {
|
||||
return CategoryModel::$arrCategoryAll['man'];
|
||||
@@ -65,4 +74,14 @@ class StaticConfig
|
||||
return array_combine(CategoryModel::$arrCategoryPinYin, CategoryModel::$arrCategory);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getNovelCategoryFilter
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function getVideoCategoryFilter(): array
|
||||
{
|
||||
return VideoCategoryModel::$arrCategory;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class VideoService
|
||||
|
||||
|
||||
/**
|
||||
* 获取小说分类URl
|
||||
* 获取视频分类URl
|
||||
*
|
||||
* @param string $strGender
|
||||
* @param string $strCategory
|
||||
@@ -114,7 +114,7 @@ class VideoService
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* 小说目录
|
||||
* 视频目录
|
||||
* @param int $intVId
|
||||
* @param string $intPinYin
|
||||
* @return string
|
||||
@@ -151,7 +151,7 @@ class VideoService
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取排行榜小说
|
||||
* 获取排行榜视频
|
||||
*
|
||||
* @param array $arrParams
|
||||
* @return array
|
||||
@@ -160,7 +160,7 @@ class VideoService
|
||||
{
|
||||
$intCount = (int)$arrParams['count'] ?? 10;
|
||||
$strSortType = (string)$arrParams['sort_type'] ?? '';
|
||||
$strNStatus = (string) $arrParams['v_isend'] ?? '';
|
||||
$strVStatus = (string) $arrParams['v_status'] ?? '';
|
||||
|
||||
$strDiffKey = (string) $arrParams['diff_key'] ?? '';
|
||||
$intCacheLifeTime = (int)$arrParams['cache_life'] ?? 0;
|
||||
@@ -168,8 +168,8 @@ class VideoService
|
||||
$arrFilter = [];
|
||||
|
||||
# v_isend filter
|
||||
if (!empty($strNStatus)) {
|
||||
switch ($strNStatus) {
|
||||
if (!empty($strVStatus)) {
|
||||
switch ($strVStatus) {
|
||||
case 'lianzai':
|
||||
$arrFilter['v_isend'] = 0;
|
||||
break;
|
||||
@@ -220,10 +220,8 @@ class VideoService
|
||||
$arrVideo = $this->VideoModel->getRankVideoOnCache(
|
||||
$strCacheKey,
|
||||
$intCount,
|
||||
$arrFilter['v_category_sex_zh'] ?? 0,
|
||||
$arrSort['v_sort_type'] ?? 'daily',
|
||||
$arrFilter['v_isend'] ?? NULL,
|
||||
$intLifeTime,
|
||||
$arrFilter['v_status'] ?? NULL,
|
||||
);
|
||||
|
||||
return $arrVideo;
|
||||
@@ -231,7 +229,7 @@ class VideoService
|
||||
|
||||
|
||||
/**
|
||||
* 获取小说数据
|
||||
* 获取视频数据
|
||||
*
|
||||
* @param array $arrParams
|
||||
* @return array
|
||||
@@ -241,7 +239,7 @@ class VideoService
|
||||
$intCount = (int)$arrParams['count'] ?? 10;
|
||||
$strNCategory = $arrParams['v_category'] ?? '';
|
||||
$strSortType = (string)$arrParams['sort_type'] ?? '';
|
||||
$strNStatus = (string) $arrParams['v_isend'] ?? '';
|
||||
$strVStatus = (string) $arrParams['v_status'] ?? '';
|
||||
|
||||
$strDiffKey = (string) $arrParams['diff_key'] ?? '';
|
||||
$intCacheLifeTime = (int)$arrParams['cache_life'] ?? 0;
|
||||
@@ -257,18 +255,17 @@ class VideoService
|
||||
}
|
||||
|
||||
# v_isend filter
|
||||
if (!empty($strNStatus)) {
|
||||
switch ($strNStatus) {
|
||||
if (!empty($strVStatus)) {
|
||||
switch ($strVStatus) {
|
||||
case 'lianzai':
|
||||
$arrFilter['v_isend'] = StaticConfig::$arrVideoStatus[$strNStatus];
|
||||
$arrFilter['v_isend'] = 0;
|
||||
break;
|
||||
case 'wanjie':
|
||||
$arrFilter['v_isend'] = StaticConfig::$arrVideoStatus[$strNStatus];
|
||||
$arrFilter['v_isend'] = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$arrSort = [];
|
||||
|
||||
# sort filter
|
||||
@@ -281,7 +278,7 @@ class VideoService
|
||||
$arrSort['v_level'] = -1;
|
||||
break;
|
||||
case 'update':
|
||||
$arrSort['v_update_time'] = -1;
|
||||
$arrSort['v_publish_date'] = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -316,7 +313,7 @@ class VideoService
|
||||
|
||||
|
||||
/**
|
||||
* 获取小说分页数据
|
||||
* 获取视频分页数据
|
||||
*
|
||||
* @param array $arrParams
|
||||
* @return array
|
||||
@@ -330,7 +327,6 @@ class VideoService
|
||||
'v_category' => (string)($arrParams['v_category'] ?? ''),
|
||||
'sort_type' => (string)($arrParams['sort_type'] ?? ''),
|
||||
'v_isend' => (string)($arrParams['v_isend'] ?? ''),
|
||||
'v_sex' => (string)($arrParams['v_sex'] ?? ''),
|
||||
'diff_key' => (string)($arrParams['diff_key'] ?? ''),
|
||||
'key' => (string)($arrParams['key'] ?? ''),
|
||||
'cache_life' => (int)($arrParams['cache_life'] ?? 0),
|
||||
@@ -341,7 +337,7 @@ class VideoService
|
||||
$intLimit = $arrParams['limit'];
|
||||
$strNCategory = $arrParams['v_category'];
|
||||
$strSortType = $arrParams['sort_type'];
|
||||
$strNStatus = $arrParams['v_isend'];
|
||||
$strVStatus = $arrParams['v_isend'];
|
||||
|
||||
$strDiffKey = $arrParams['diff_key'];
|
||||
$strKey = $arrParams['key'];
|
||||
@@ -367,13 +363,13 @@ class VideoService
|
||||
}
|
||||
|
||||
# v_isend filter
|
||||
if (!empty($strNStatus)) {
|
||||
switch ($strNStatus) {
|
||||
if (!empty($strVStatus)) {
|
||||
switch ($strVStatus) {
|
||||
case 'lianzai':
|
||||
$arrFilter['$and'][] = ['v_isend' => StaticConfig::$arrVideoStatus[$strNStatus]];
|
||||
$arrFilter['$and'][] = ['v_isend' => 0];
|
||||
break;
|
||||
case 'wanjie':
|
||||
$arrFilter['$and'][] = ['v_isend' => StaticConfig::$arrVideoStatus[$strNStatus]];
|
||||
$arrFilter['$and'][] = ['v_isend' => 1];
|
||||
break;
|
||||
default:
|
||||
$arrParams['v_isend'] = 'all';
|
||||
@@ -409,7 +405,7 @@ class VideoService
|
||||
$arrSort['v_level'] = -1;
|
||||
break;
|
||||
case 'update':
|
||||
$arrSort['v_update_time'] = -1;
|
||||
$arrSort['v_publish_date'] = -1;
|
||||
break;
|
||||
default:
|
||||
$arrParams['sort_type'] = 'all';
|
||||
@@ -436,18 +432,11 @@ class VideoService
|
||||
}
|
||||
|
||||
// 更新值
|
||||
$strGender = $this->SiteContext->Request->param('strGender');
|
||||
$strNanUrlTemp = $this->SiteContext->DomainModel->getFomartSubject('NAN_SHENG_URL', '', false);
|
||||
$strNanUrl = str_replace("/", "", $strNanUrlTemp);
|
||||
$strCNSex = '全部';
|
||||
if ($strGender) {
|
||||
$strCNSex = $strGender == $strNanUrl ? '男生' : '女生';
|
||||
}
|
||||
|
||||
ConverterMovel::setVal([
|
||||
'intPage' => $intPage,
|
||||
'strVideoSex' => $strCNSex,
|
||||
'strVideoCategoryName' => empty($strNCategory) ? '' : str_replace("小说", "", $strNCategory),
|
||||
'strVideoStatus' => empty($strNStatus) ? '' : StaticConfig::$arrVideoStatus[$strNStatus],
|
||||
'strVideoCategoryName' => empty($strNCategory) ? '' : str_replace("视频", "", $strNCategory),
|
||||
'strVideoStatus' => empty($strVStatus) ? '' : StaticConfig::$arrVideoStatus[$strVStatus],
|
||||
'strVideoOrder' => empty($strSortType) ? '' : StaticConfig::$arrVideoSortType[$strSortType],
|
||||
'strSearchKeywords' => $strKey,
|
||||
]);
|
||||
@@ -497,82 +486,54 @@ class VideoService
|
||||
return $arrPaginator;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 书库/分类定制分页
|
||||
*
|
||||
* @param array $arrFilter 查询条件字段
|
||||
* @param array $arrSort 查询排序字段
|
||||
* @param array $arrVideo 查询出来的数据
|
||||
* @param array $arrNovel 查询出来的数据
|
||||
* @return array
|
||||
*/
|
||||
public function generateCategoryPager(array $arrParams, array $arrSort, array $arrVideo): array
|
||||
public function generateVideoPager(array $arrParams, array $arrSort, array $arrVideo): array
|
||||
{
|
||||
$strGender = $arrParams['v_sex'];
|
||||
$strCategory = $arrParams['v_category'];
|
||||
$strStatus = $arrParams['v_isend'];
|
||||
$strOrder = $arrParams['sort_type'];
|
||||
$intPage = $arrVideo['page'] ?? 1;
|
||||
$intLimit = $arrVideo['limit'] ?? 10;
|
||||
$intTotal = $arrVideo['total'] ?? 0;
|
||||
$strKey = $arrParams['key'];
|
||||
$intPage = $arrVideo['page'];
|
||||
$intLimit = $arrVideo['limit'];
|
||||
$intButtomNum = $arrParams['buttov_num'];
|
||||
$strBaseUrl = $this->getVideoCategoryUrl($strGender, $strCategory, $strStatus, $strOrder, '{page}');
|
||||
|
||||
$arrPaginator = CusteomPage02::generate($intPage, $intTotal, $intLimit, $strBaseUrl, $intButtomNum);
|
||||
$strBaseUrl = app(VideoService::class)->getVideoSearchUrl($strKey, '{page}');
|
||||
$arrPaginator = CusteomPage02::generate($intPage, $arrVideo['total'], $intLimit, $strBaseUrl, $intButtomNum);
|
||||
|
||||
return $arrPaginator;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据VId获取小说详情
|
||||
* 根据VId获取视频详情
|
||||
*
|
||||
* @param integer $intVId
|
||||
* @return void
|
||||
*/
|
||||
public function getVideoByVId(int $intVId, int|null $intNForgeId = 0)
|
||||
public function getVideoByVId(int $intVId)
|
||||
{
|
||||
|
||||
// 小说详情
|
||||
// 视频详情
|
||||
$arrVideo = $this->VideoModel->getVideoByVId($intVId);
|
||||
|
||||
if ($intNForgeId > 0) {
|
||||
foreach ($arrVideo['v_forge_novel'] as $arrForgeVideo) {
|
||||
if ($arrForgeVideo['v_forge_id'] == $intNForgeId) {
|
||||
$arrVideo['v_name'] = $arrForgeVideo['v_forge_title'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 分类拼音
|
||||
$arrVideo['v_category_pinyin'] = CategoryModel::getPinYin($arrVideo['v_category']);
|
||||
$arrVideo['v_category_sex_en'] = $arrVideo['v_category_sex_en'] ?? 'man';
|
||||
|
||||
// 点击数
|
||||
$arrVideoClicks = $this->VideoClicksModel->getStats($intVId);
|
||||
|
||||
// 推荐小说
|
||||
$arrRelateveVId = array_column($arrVideo['v_related_novel'], 'v_id');
|
||||
|
||||
$arrRelateveVideo = $this->VideoModel->findMany(['v_id' => [
|
||||
'$in' => $arrRelateveVId,
|
||||
]], 10);
|
||||
|
||||
|
||||
// 更新值
|
||||
ConverterMovel::setVal([
|
||||
'intPage' => 1,
|
||||
'strVideoName' => $arrVideo['v_name'],
|
||||
'strVideoAuthor' => $arrVideo['v_author'],
|
||||
'strVideoCategoryName' => $arrVideo['v_category'],
|
||||
'strVideoSex' => $arrVideo['v_category_sex_en'] == 'man' ? '男生' : '女生',
|
||||
'strVideoStatus' => $arrVideo['v_isend'],
|
||||
'strVideoDescription' => $arrVideo['v_description'],
|
||||
]);
|
||||
|
||||
$arrVideo['arrVideoClicks'] = $arrVideoClicks;
|
||||
$arrVideo['arrRelateveVideo'] = $arrRelateveVideo;
|
||||
|
||||
|
||||
return $arrVideo;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user