feat: 添加视频分页/详情接口
This commit is contained in:
15
app/admin/model/v1/VideoCategoryModel.php
Normal file
15
app/admin/model/v1/VideoCategoryModel.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\admin\model\v1;
|
||||
|
||||
use app\common\model\VideoCategoryBaseModel;
|
||||
|
||||
/**
|
||||
* 视频分类模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class VideoCategoryModel extends VideoCategoryBaseModel
|
||||
{
|
||||
//
|
||||
}
|
||||
52
app/admin/model/v1/VideoModel.php
Normal file
52
app/admin/model/v1/VideoModel.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\admin\model\v1;
|
||||
|
||||
use app\common\model\VideoBaseModel;
|
||||
|
||||
/**
|
||||
* 视频信息模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class VideoModel extends VideoBaseModel
|
||||
{
|
||||
// 关联分类
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(VideoCategoryModel::class, 'category_id', 'id');
|
||||
}
|
||||
|
||||
// 名称搜索器
|
||||
public function searchNameAttr($query, $value, $data)
|
||||
{
|
||||
if (empty($value)) {
|
||||
return;
|
||||
}
|
||||
$query->where('name', 'like', '%' . $value . '%');
|
||||
}
|
||||
|
||||
// 搜索发布时间
|
||||
public function searchCreatedAtAttr($query, $value, $data)
|
||||
{
|
||||
if (empty($value)) {
|
||||
return;
|
||||
}
|
||||
if (is_array($value)) {
|
||||
if (count($value) == 2) {
|
||||
$query->whereBetweenTime('created_at', $value[0], $value[1]);
|
||||
} else {
|
||||
$query->whereTime('created_at', '>=', $value[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 分类查询
|
||||
public function scopeCategoryId($query, $value)
|
||||
{
|
||||
if (empty($value)) {
|
||||
return;
|
||||
}
|
||||
$query->where('category_id', '=', $value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user