Initial commit: web_hghl_server
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -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