Initial commit: web_hghl_server
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
package web_video
|
||||
|
||||
import (
|
||||
"videoweb/pub/common"
|
||||
"videoweb/pub/common/srvdef"
|
||||
"videoweb/pub/models/videocategorymod"
|
||||
"videoweb/web/service/srv_videocategory"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// GetVideoCategory
|
||||
// @Tags 视频分类
|
||||
// @Summary 分组分页获取视频分类
|
||||
// @Description 分组分页获取视频分类
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videocategory.VideoCategoryReq true "参数列表"
|
||||
// @Success 200 {object} srv_videocategory.VideoCategoryResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videocategory/list [POST]
|
||||
func GetVideoCategory(ctx *gin.Context) {
|
||||
var req = &srv_videocategory.VideoCategoryReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
resp, err := srv_videocategory.GetVideoCategorys(ctx, req)
|
||||
if err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// AddOneVideoCategory
|
||||
// @Tags 视频分类
|
||||
// @Summary 添加一个视频分类
|
||||
// @Description 添加一个视频分类
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body videocategorymod.VideoCategory true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videocategory/add [POST]
|
||||
func AddOneVideoCategory(ctx *gin.Context) {
|
||||
var req = &videocategorymod.VideoCategory{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
err := srv_videocategory.AddVideoCategory(ctx, req)
|
||||
if err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// DelOneVideoCategory
|
||||
// @Tags 视频分类
|
||||
// @Summary 删除一个视频分类
|
||||
// @Description 删除一个视频分类
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videocategory.VideoCategoryDelReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videocategory/del [POST]
|
||||
func DelOneVideoCategory(ctx *gin.Context) {
|
||||
var req = &srv_videocategory.VideoCategoryDelReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
err := srv_videocategory.DelVideoCategory(ctx, req.Id)
|
||||
if err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// UpdateOneVideoCategory
|
||||
// @Tags 视频分类
|
||||
// @Summary 更新一个视频分类
|
||||
// @Description 更新一个视频分类
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videocategory.VideoCategoryUpdate true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videocategory/update [POST]
|
||||
func UpdateOneVideoCategory(ctx *gin.Context) {
|
||||
var req = &srv_videocategory.VideoCategoryUpdateReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
err := srv_videocategory.UpdateVideoCategory(ctx, req.Id, req.Param)
|
||||
if err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package web_video
|
||||
|
||||
import (
|
||||
"videoweb/pub/common"
|
||||
"videoweb/pub/common/srvdef"
|
||||
"videoweb/pub/models/videocreatermod"
|
||||
"videoweb/web/service/srv_videocreater"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 视频作者
|
||||
// @Summary 分组分页获取视频作者
|
||||
// @Description 分组分页获取视频作者
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videocreater.VideoCreaterReq true "参数列表"
|
||||
// @Success 200 {object} srv_videocreater.VideoCreaterResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videocreater/list [POST]
|
||||
func GetVideoCreater(ctx *gin.Context) {
|
||||
var req = &srv_videocreater.VideoCreaterReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
resp, serr := srv_videocreater.GetVideoCreaters(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 视频作者
|
||||
// @Summary 添加一个视频作者
|
||||
// @Description 添加一个视频作者
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body videocreatermod.VideoCreaterInfo true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videocreater/add [POST]
|
||||
func AddOneVideoCreater(ctx *gin.Context) {
|
||||
var req = &videocreatermod.VideoCreaterInfo{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
serr := srv_videocreater.AddVideoCreater(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 视频作者
|
||||
// @Summary 删除一个视频作者
|
||||
// @Description 删除一个视频作者
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videocreater.VideoCreaterDelReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videocreater/del [POST]
|
||||
func DelOneVideoCreater(ctx *gin.Context) {
|
||||
var req = &srv_videocreater.VideoCreaterDelReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
serr := srv_videocreater.DelVideoCreater(ctx, req.Id)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 视频作者
|
||||
// @Summary 更新一个视频作者
|
||||
// @Description 更新一个视频作者
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videocreater.VideoCreaterUpdate true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videocreater/update [POST]
|
||||
func UpdateOneVideoCreater(ctx *gin.Context) {
|
||||
var req = &srv_videocreater.VideoCreaterUpdateReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
serr := srv_videocreater.UpdateVideoCreater(ctx, req.Id, req.Param)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package web_video
|
||||
|
||||
import (
|
||||
"videoweb/pub/common"
|
||||
"videoweb/pub/common/srvdef"
|
||||
"videoweb/web/service/srv_videoinfo"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// VideoList 按日期查询已上架视频。
|
||||
func VideoList(ctx *gin.Context) {
|
||||
param := srv_videoinfo.ExternalVideoListReq{}
|
||||
if err := ctx.ShouldBindQuery(¶m); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
data, serr := srv_videoinfo.SearchExternalVideoList(ctx, ¶m)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, data)
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package web_video
|
||||
|
||||
import (
|
||||
"videoweb/pub/common"
|
||||
"videoweb/pub/common/srvdef"
|
||||
"videoweb/web/service/srv_videotag"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 标签管理
|
||||
// @Summary 查询播放量最多的标签
|
||||
// @Description 根据视频累计播放量聚合返回热门标签列表
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param limit query int false "返回条数,默认10,最大1000"
|
||||
// @Success 200 {object} srv_videotag.HotTagResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Router /wbapi/hjsq/hottag [GET]
|
||||
func GetVideoPlayData(ctx *gin.Context) {
|
||||
var req = &srv_videotag.HotTagReq{}
|
||||
if err := ctx.ShouldBindQuery(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
resp, serr := srv_videotag.GetHotTagsByPlayData(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags IP统计
|
||||
// @Summary 查询今日和昨日去重访客IP数
|
||||
// @Produce json
|
||||
// @Success 200 {object} srv_videotag.IpStatReq "成功"
|
||||
// @Router /wbapi/hjsq/ipstat [GET]
|
||||
func GetIpStatData(ctx *gin.Context) {
|
||||
fetchIpStat := srv_videotag.FetchIpStat(ctx)
|
||||
common.ServerJSON(ctx, srvdef.Success, fetchIpStat)
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package web_video
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"io"
|
||||
"net/http"
|
||||
"videoweb/pub/common"
|
||||
"videoweb/pub/common/m3u8"
|
||||
"videoweb/pub/common/srvdef"
|
||||
"videoweb/pub/models/cfg"
|
||||
"videoweb/web/webg"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type fileHandler func(ctx *gin.Context) (contentLength int64, contentType string, reader io.Reader, extraHeaders map[string]string, err error)
|
||||
|
||||
func Play(ctx *gin.Context) {
|
||||
fn := func(c *gin.Context) (contentLength int64, contentType string, reader io.Reader, extraHeaders map[string]string, err error) {
|
||||
m3u8Name := ctx.Param("key")
|
||||
|
||||
var req m3u8.Req
|
||||
if err = ctx.BindQuery(&req); err != nil {
|
||||
return
|
||||
}
|
||||
req.Name = m3u8Name
|
||||
cfgSys, _ := cfg.FindOneSysCfg(ctx, bson.M{})
|
||||
cdnDomain := webg.Conf.CdnDomain
|
||||
if cfgSys != nil {
|
||||
cdnDomain = cfgSys.MediaWebCdn
|
||||
}
|
||||
origDomain := webg.Conf.OrigDomain
|
||||
_, buff, err := m3u8.TransFormWithSafely(&req, cdnDomain, origDomain, true, webg.Conf.TsAuthKey, webg.Conf.LsjMediaConf.M3u8Yuan, "")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
contentType = "application/vnd.apple.mpegurl"
|
||||
reader = bytes.NewReader(buff.Bytes())
|
||||
contentLength = int64(buff.Len())
|
||||
extraHeaders = map[string]string{}
|
||||
return
|
||||
}
|
||||
|
||||
handlerFile(ctx, fn)
|
||||
}
|
||||
|
||||
func Enkey(ctx *gin.Context) {
|
||||
fn := func(c *gin.Context) (contentLength int64, contentType string, reader io.Reader, extraHeaders map[string]string, err error) {
|
||||
buffer, err := m3u8.Enkey(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
contentLength = int64(buffer.Len())
|
||||
contentType = "application/octet-stream"
|
||||
reader = buffer
|
||||
extraHeaders = map[string]string{}
|
||||
return
|
||||
}
|
||||
handlerFile(ctx, fn)
|
||||
}
|
||||
|
||||
// TranscodeM3u8 转码专用 m3u8 接口(不鉴权)。
|
||||
func TranscodeM3u8(ctx *gin.Context) {
|
||||
fn := func(c *gin.Context) (contentLength int64, contentType string, reader io.Reader, extraHeaders map[string]string, err error) {
|
||||
name := ctx.Param("key")
|
||||
_, buff, err := m3u8.TransformForTranscode(name, webg.Conf.OrigDomain, webg.Conf.CdnDomain, webg.Conf.WebM3u8Host, webg.Conf.LsjMediaConf.M3u8Yuan, webg.Conf.LsjMediaConf.TsYuan)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
contentType = "application/vnd.apple.mpegurl"
|
||||
reader = bytes.NewReader(buff.Bytes())
|
||||
contentLength = int64(buff.Len())
|
||||
extraHeaders = map[string]string{}
|
||||
return
|
||||
}
|
||||
handlerFile(ctx, fn)
|
||||
}
|
||||
|
||||
func LsjEnkey(ctx *gin.Context) {
|
||||
fn := func(c *gin.Context) (contentLength int64, contentType string, reader io.Reader, extraHeaders map[string]string, err error) {
|
||||
buffer, err := m3u8.LsjEnkey(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
contentLength = int64(buffer.Len())
|
||||
contentType = "application/octet-stream"
|
||||
reader = buffer
|
||||
extraHeaders = map[string]string{}
|
||||
return
|
||||
}
|
||||
handlerFile(ctx, fn)
|
||||
}
|
||||
|
||||
func handlerFile(ctx *gin.Context, h fileHandler) {
|
||||
contentLength, contentType, reader, extraHeaders, err := h(ctx)
|
||||
if err != nil {
|
||||
common.ServerJSON(ctx, srvdef.DownloadM3u8File, err)
|
||||
return
|
||||
}
|
||||
ctx.DataFromReader(http.StatusOK, contentLength, contentType, reader, extraHeaders)
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package web_video
|
||||
|
||||
import (
|
||||
"videoweb/pub/common"
|
||||
"videoweb/pub/common/srvdef"
|
||||
"videoweb/pub/models/videotagmod"
|
||||
"videoweb/web/service/srv_videotag"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 标签管理
|
||||
// @Summary 分组分页获取标签管理
|
||||
// @Description 分组分页获取标签管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videotag.VideoTagInfoReq true "参数列表"
|
||||
// @Success 200 {object} srv_videotag.VideoTagInfoResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videotag/list [POST]
|
||||
func GetVideoTagInfo(ctx *gin.Context) {
|
||||
var req = &srv_videotag.VideoTagInfoReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
resp, serr := srv_videotag.GetVideoTagInfos(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 标签管理
|
||||
// @Summary 添加一个标签管理
|
||||
// @Description 添加一个标签管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body videotagmod.VideoTagInfo true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videotag/add [POST]
|
||||
func AddOneVideoTagInfo(ctx *gin.Context) {
|
||||
var req = &videotagmod.VideoTagInfo{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
serr := srv_videotag.AddVideoTagInfo(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 标签管理
|
||||
// @Summary 删除一个标签管理
|
||||
// @Description 删除一个标签管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videotag.VideoTagInfoDelReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videotag/del [POST]
|
||||
func DelOneVideoTagInfo(ctx *gin.Context) {
|
||||
var req = &srv_videotag.VideoTagInfoDelReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
serr := srv_videotag.DelVideoTagInfo(ctx, req.Id)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 标签管理
|
||||
// @Summary 更新一个标签管理
|
||||
// @Description 更新一个标签管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videotag.VideoTagInfoUpdate true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videotag/update [POST]
|
||||
func UpdateOneVideoTagInfo(ctx *gin.Context) {
|
||||
var req = &srv_videotag.VideoTagInfoUpdateReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
serr := srv_videotag.UpdateVideoTagInfo(ctx, req.Id, req.Param)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,344 @@
|
||||
package web_video
|
||||
|
||||
import (
|
||||
"videoweb/pub/common"
|
||||
"videoweb/pub/common/srvdef"
|
||||
"videoweb/web/middleware/auth"
|
||||
"videoweb/web/service/srv_videoinfo"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 视频管理
|
||||
// @Summary 分组分页获取视频管理
|
||||
// @Description 分组分页获取视频管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videoinfo.VideoInfoReq true "参数列表"
|
||||
// @Success 200 {object} srv_videoinfo.VideoInfoResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videoinfo/list [POST]
|
||||
func GetVideoInfo(ctx *gin.Context) {
|
||||
var req = &srv_videoinfo.VideoInfoReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
resp, serr := srv_videoinfo.GetVideoInfos(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// SetVideoRecommend 单/批量设置视频是否推荐
|
||||
// @Tags 视频管理
|
||||
// @Summary 单/批量设置视频是否推荐 -- by 王鸣
|
||||
// @Description 根据视频ID集合批量更新 video_information 集合 isRecommend 字段,传1个ID表示单条设置,传多个ID表示批量设置
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videoinfo.SetRecommendReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videoinfo/recommend/set [post]
|
||||
func SetVideoRecommend(ctx *gin.Context) {
|
||||
req := &srv_videoinfo.SetRecommendReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err := srv_videoinfo.SetVideoRecommend(ctx, req); err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// SetVideoFakeLikes 单/批量设置视频假点赞数
|
||||
// @Tags 视频管理
|
||||
// @Summary 单/批量设置视频假点赞数 --by 旺鸣
|
||||
// @Description 根据ids批量随机设置视频fake.likes,随机范围包含最小值和最大值
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videoinfo.SetFakeLikesReq true "参数列表"
|
||||
// @Success 200 {object} srv_videoinfo.SetFakeCountResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videoinfo/setFakeLikes [post]
|
||||
func SetVideoFakeLikes(ctx *gin.Context) {
|
||||
req := &srv_videoinfo.SetFakeLikesReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := srv_videoinfo.SetVideoFakeLikes(ctx, req)
|
||||
if err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// SetVideoFakeWatchTimes 单/批量设置视频假观看次数
|
||||
// @Tags 视频管理
|
||||
// @Summary 单/批量设置视频假观看次数 --by 旺鸣
|
||||
// @Description 根据ids批量随机设置视频fake.watchTimes,随机范围包含最小值和最大值
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videoinfo.SetFakeWatchTimesReq true "参数列表"
|
||||
// @Success 200 {object} srv_videoinfo.SetFakeCountResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videoinfo/setFakeWatchTimes [post]
|
||||
func SetVideoFakeWatchTimes(ctx *gin.Context) {
|
||||
req := &srv_videoinfo.SetFakeWatchTimesReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := srv_videoinfo.SetVideoFakeWatchTimes(ctx, req)
|
||||
if err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// SetVideoHeat 单/批量设置视频热度
|
||||
// @Tags 视频管理
|
||||
// @Summary 单/批量设置视频热度 -- by 王鸣
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videoinfo.SetVideoHeatReq true "视频热度设置请求"
|
||||
// @Success 200 {object} srv_videoinfo.SetFakeCountResp "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videoinfo/heat/set [post]
|
||||
func SetVideoHeat(ctx *gin.Context) {
|
||||
req := &srv_videoinfo.SetVideoHeatReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := srv_videoinfo.SetVideoHeat(ctx, req)
|
||||
if err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// /api/web/videoinfo/fillZeroFakeFlow [post]
|
||||
func FillZeroVideoFakeFlow(ctx *gin.Context) {
|
||||
//临时注释,有需要再放开
|
||||
//resp, err := srv_videoinfo.FillZeroVideoFakeFlow(ctx)
|
||||
//if err != nil {
|
||||
// common.ServerJSON(ctx, err.Code, err.Tips)
|
||||
// return
|
||||
//}
|
||||
//common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 视频管理
|
||||
// @Summary 从切片列表同步多个视频
|
||||
// @Description 从切片列表同步多个视频
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videoinfo.AddVideoReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videoinfo/sync [POST]
|
||||
func SyncVideoInfo(ctx *gin.Context) {
|
||||
var req = &srv_videoinfo.AddVideoReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
serr := srv_videoinfo.SyncVideoInfo(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 视频管理
|
||||
// @Summary 从媒资库直同步到视频列表
|
||||
// @Description 从媒资库直同步到视频列表,后续切片同步时按 mediaSourceId 覆盖
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videoinfo.SyncMediaFileReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videoinfo/syncMediaFile [POST]
|
||||
func SyncVideoFromMediaFile(ctx *gin.Context) {
|
||||
var req = &srv_videoinfo.SyncMediaFileReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
result, serr := srv_videoinfo.SyncVideoFromMediaFile(ctx, req)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, result)
|
||||
}
|
||||
|
||||
// @Tags 视频管理
|
||||
// @Summary 删除一个视频管理
|
||||
// @Description 删除一个视频管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videoinfo.VideoInfoDelReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videoinfo/del [POST]
|
||||
func DelOneVideoInfo(ctx *gin.Context) {
|
||||
var req = &srv_videoinfo.VideoInfoDelReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
serr := srv_videoinfo.DelVideoInfo(ctx, req.Id)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 视频管理
|
||||
// @Summary 更新一个视频管理
|
||||
// @Description 更新一个视频管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videoinfo.VideoInfoUpdateReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videoinfo/update [POST]
|
||||
func UpdateOneVideoInfo(ctx *gin.Context) {
|
||||
var req = &srv_videoinfo.VideoInfoUpdateReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.New(srvdef.ErrParamError, err.Error(), err.Error()), nil)
|
||||
return
|
||||
}
|
||||
userId := ctx.GetInt64(auth.AccId)
|
||||
serr := srv_videoinfo.UpdateVideoInfo(ctx, req.Id, userId, req.Param)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, videoUpdateErr(serr), nil)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// videoUpdateErr 把业务错误里的具体原因带到接口提示里。
|
||||
func videoUpdateErr(err *srvdef.SrvErr) *srvdef.SrvErr {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
if err.Tips == "" && err.Msg != "" && err.Msg != err.Code.Msg() {
|
||||
return srvdef.New(err.Code, err.Msg, err.Msg)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// @Tags 视频管理
|
||||
// @Summary 新增一个视频合集
|
||||
// @Description 新增一个视频合集
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videoinfo.AddVideoCollectionReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videoinfo/addcoll [POST]
|
||||
func AddOneVideoCollection(ctx *gin.Context) {
|
||||
var req = &srv_videoinfo.AddVideoCollectionReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// AddVideoTags 批量追加视频标签
|
||||
// @Tags 视频管理
|
||||
// @Summary 批量追加视频标签 -- by 王鸣
|
||||
// @Description 根据视频ID集合批量追加统一标签,已存在的标签不会重复追加
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videoinfo.VideoAddTagsReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videoinfo/addTags [post]
|
||||
func AddVideoTags(ctx *gin.Context) {
|
||||
req := &srv_videoinfo.VideoAddTagsReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err := srv_videoinfo.AddVideoTags(ctx, req); err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// SetVideoTags 单/批量设置视频标签
|
||||
// @Tags 视频管理
|
||||
// @Summary 单/批量设置视频标签 -- by 王鸣
|
||||
// @Description 根据视频ID集合批量覆盖 video_information 集合 tags 字段,传1个ID表示单条设置,传多个ID表示批量设置,tagIds传空数组表示清空标签
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body srv_videoinfo.VideoSetTagsReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/videoinfo/tag/set [post]
|
||||
func SetVideoTags(ctx *gin.Context) {
|
||||
req := &srv_videoinfo.VideoSetTagsReq{}
|
||||
if err := ctx.ShouldBindJSON(req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err := srv_videoinfo.SetVideoTags(ctx, req); err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
type TranscodeVideoReq struct {
|
||||
Id int64 `json:"id" binding:"required"`
|
||||
}
|
||||
|
||||
// @Tags 视频管理
|
||||
// @Summary 提交视频 H265 转码
|
||||
// @Router /api/web/videoinfo/transcode [POST]
|
||||
func TranscodeVideo(ctx *gin.Context) {
|
||||
var req TranscodeVideoReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if serr := srv_videoinfo.TranscodeVideo(ctx, req.Id); serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, nil)
|
||||
}
|
||||
Reference in New Issue
Block a user