package videoapi import ( "videoweb/app/api/proto" "videoweb/app/service/videoser" "videoweb/pub/common" "videoweb/pub/common/ipaddr" "videoweb/pub/common/srvdef" "github.com/gin-gonic/gin" ) // AllList app端分页查询视频列表 // @Tags 视频相关接口 // @Summary app端分页查询视频列表 --by 王鸣 // @Description 分页查询已上架视频,支持类型、题材和排序筛选 // @Accept json // @Produce json // @Param params query proto.VideoAllListReq true "app端分页查询视频列表请求" // @Success 200 {object} proto.VideoAllListResp{list=[]proto.VideoAllListItemResp} "成功" // @Failure 400 {string} string "失败" // @Router /api/app/video/all/list [get] func AllList(ctx *gin.Context) { var req proto.VideoAllListReq if err := ctx.ShouldBindQuery(&req); err != nil { common.ServerJSON(ctx, srvdef.ErrParamError, nil) return } resp, err := videoser.VideoAllList(ctx, &req) if err != nil { common.ServerJSON(ctx, err.Code, err.Tips) return } common.ServerJSON(ctx, srvdef.Success, resp) } // TopicList app端查询视频题材列表 // @Tags 视频相关接口 // @Summary app端查询视频题材列表 --by 王鸣 // @Description 查询已上架视频题材列表,mediaType=0全部 1影集 2动画 // @Accept json // @Produce json // @Param params query proto.VideoTopicListReq true "app端查询视频题材列表请求" // @Success 200 {object} proto.VideoTopicListResp "成功" // @Failure 400 {string} string "失败" // @Router /api/app/video/topic/list [get] func TopicList(ctx *gin.Context) { var req proto.VideoTopicListReq if err := ctx.ShouldBindQuery(&req); err != nil { common.ServerJSON(ctx, srvdef.ErrParamError, nil) return } resp, err := videoser.VideoTopicList(ctx, &req) if err != nil { common.ServerJSON(ctx, err.Code, err.Tips) return } common.ServerJSON(ctx, srvdef.Success, resp) } // List 普通分页查询视频 // @Tags 视频相关接口 // @Summary 普通分页查询视频 --by 旺鸣 // @Description 按上架时间倒序普通分页查询已上架视频 // @Accept json // @Produce json // @Param params query proto.VideoReq true "普通分页查询视频请求" // @Success 200 {object} proto.VideoResp{list=[]proto.VideoItemResp} "成功" // @Failure 400 {string} string "失败" // @Router /api/app/video/list [get] func List(ctx *gin.Context) { var req proto.VideoReq if err := ctx.ShouldBind(&req); err != nil { common.ServerJSON(ctx, srvdef.ErrParamError, nil) return } resp, err := videoser.VideoList(ctx, &req) if err != nil { common.ServerJSON(ctx, err.Code, err.Tips) return } common.ServerJSON(ctx, srvdef.Success, resp) } // SetLike app端视频点赞/取消点赞 // @Tags 视频相关接口 // @Summary app端视频点赞/取消点赞 --by 王鸣 // @Description 设置当前用户视频点赞状态,点赞数只在状态真实变化时增减 // @Accept json // @Produce json // @Param param body proto.VideoLikeSetReq true "视频点赞设置请求" // @Success 200 {object} proto.VideoLikeSetResp "成功" // @Failure 400 {string} string "失败" // @Router /api/app/video/like/set [post] func SetLike(ctx *gin.Context) { var req proto.VideoLikeSetReq if err := ctx.ShouldBindJSON(&req); err != nil { common.ServerJSON(ctx, srvdef.ErrParamError, nil) return } resp, err := videoser.SetLike(ctx, common.GetUserId(ctx), &req) if err != nil { common.ServerJSON(ctx, err.Code, err.Tips) return } common.ServerJSON(ctx, srvdef.Success, resp) } // SetCollect app端视频收藏/取消收藏 // @Tags 视频相关接口 // @Summary app端视频收藏/取消收藏 --by 王鸣 // @Description 设置当前用户视频收藏状态,收藏数只在状态真实变化时增减 // @Accept json // @Produce json // @Param param body proto.VideoCollectSetReq true "视频收藏设置请求" // @Success 200 {object} proto.VideoCollectSetResp "成功" // @Failure 400 {string} string "失败" // @Router /api/app/video/collect/set [post] func SetCollect(ctx *gin.Context) { var req proto.VideoCollectSetReq if err := ctx.ShouldBindJSON(&req); err != nil { common.ServerJSON(ctx, srvdef.ErrParamError, nil) return } resp, err := videoser.SetCollect(ctx, common.GetUserId(ctx), &req) if err != nil { common.ServerJSON(ctx, err.Code, err.Tips) return } common.ServerJSON(ctx, srvdef.Success, resp) } // HistoryList app端我的视频观看历史列表 // @Tags 视频相关接口 // @Summary app端我的视频观看历史列表 --by 王鸣 // @Description 按当前用户最近观看时间倒序分页返回视频观看历史 // @Accept json // @Produce json // @Param params query proto.VideoHistoryListReq true "视频观看历史列表请求" // @Success 200 {object} proto.VideoHistoryListResp "成功" // @Failure 400 {string} string "失败" // @Router /api/app/video/history/list [get] func HistoryList(ctx *gin.Context) { var req proto.VideoHistoryListReq if err := ctx.ShouldBindQuery(&req); err != nil { common.ServerJSON(ctx, srvdef.ErrParamError, nil) return } resp, err := videoser.HistoryList(ctx, common.GetUserId(ctx), &req) if err != nil { common.ServerJSON(ctx, err.Code, err.Tips) return } common.ServerJSON(ctx, srvdef.Success, resp) } // DeleteHistory app端删除单条视频观看历史 // @Tags 视频相关接口 // @Summary app端删除单条视频观看历史 --by 王鸣 // @Description 删除当前用户指定视频观看历史,不影响收藏和点赞 // @Accept json // @Produce json // @Param param body proto.VideoHistoryDeleteReq true "删除单条视频观看历史请求" // @Success 200 {object} proto.VideoHistoryDeleteResp "成功" // @Failure 400 {string} string "失败" // @Router /api/app/video/history/delete [post] func DeleteHistory(ctx *gin.Context) { var req proto.VideoHistoryDeleteReq if err := ctx.ShouldBindJSON(&req); err != nil { common.ServerJSON(ctx, srvdef.ErrParamError, nil) return } resp, err := videoser.DeleteHistory(ctx, common.GetUserId(ctx), &req) if err != nil { common.ServerJSON(ctx, err.Code, err.Tips) return } common.ServerJSON(ctx, srvdef.Success, resp) } // ClearHistory app端清空我的视频观看历史 // @Tags 视频相关接口 // @Summary app端清空我的视频观看历史 --by 王鸣 // @Description 清空当前用户全部视频观看历史,不影响收藏和点赞 // @Accept json // @Produce json // @Success 200 {object} proto.VideoHistoryClearResp "成功" // @Failure 400 {string} string "失败" // @Router /api/app/video/history/clear [post] func ClearHistory(ctx *gin.Context) { resp, err := videoser.ClearHistory(ctx, common.GetUserId(ctx)) if err != nil { common.ServerJSON(ctx, err.Code, err.Tips) return } common.ServerJSON(ctx, srvdef.Success, resp) } // CollectList app端我的视频收藏列表 // @Tags 视频相关接口 // @Summary app端我的视频收藏列表 --by 王鸣 // @Description 按当前用户收藏时间倒序分页返回视频收藏列表 // @Accept json // @Produce json // @Param params query proto.VideoCollectListReq true "视频收藏列表请求" // @Success 200 {object} proto.VideoCollectListResp "成功" // @Failure 400 {string} string "失败" // @Router /api/app/video/collect/list [get] func CollectList(ctx *gin.Context) { var req proto.VideoCollectListReq if err := ctx.ShouldBindQuery(&req); err != nil { common.ServerJSON(ctx, srvdef.ErrParamError, nil) return } resp, err := videoser.CollectList(ctx, common.GetUserId(ctx), &req) if err != nil { common.ServerJSON(ctx, err.Code, err.Tips) return } common.ServerJSON(ctx, srvdef.Success, resp) } // Detail 查询视频详情 // @Tags 视频相关接口 // @Summary 查询视频详情 --by 旺鸣 // @Description 查询已上架视频详情 // @Accept json // @Produce json // @Param params query proto.VideoInfoReq true "查询视频详情请求" // @Success 200 {object} proto.VideoInfoResp "成功" // @Failure 400 {string} string "失败" // @Router /api/app/video/detail [get] func Detail(ctx *gin.Context) { var req proto.VideoInfoReq if err := ctx.ShouldBindQuery(&req); err != nil { common.ServerJSON(ctx, srvdef.ErrParamError, nil) return } ua, _ := common.GetUA(ctx) resp, err := videoser.VideoInfo(ctx, &req, common.GetUserId(ctx), ipaddr.ResolveClientIP(ctx), ua.UserAgent) if err != nil { common.ServerJSON(ctx, err.Code, err.Tips) return } common.ServerJSON(ctx, srvdef.Success, resp) }