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) } // @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 删除一个视频管理 // @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.ErrParamError, nil) return } userId := ctx.GetInt64(auth.AccId) ua, _ := common.GetUA(ctx) serr := srv_videoinfo.UpdateVideoInfo(ctx, req.Id, userId, req.Param, ua) 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.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 } serr := srv_videoinfo.AddVideoCollection(ctx, req) if serr != nil { common.ServerJSON(ctx, serr.Code, serr.Tips) return } common.ServerJSON(ctx, srvdef.Success, "") } // SetVideoFakeWatchTimes 单/批量设置视频假观看次数 // @Tags 视频管理 // @Summary 单/批量设置视频假观看次数 --by 旺鸣 // @Description 根据ids批量随机设置视频假观看次数 // @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) } 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) }