Files
2026-10-26 16:28:14 +08:00

544 lines
19 KiB
Go

package web_playlet
import (
"videoweb/pub/common"
"videoweb/pub/common/srvdef"
"videoweb/web/api/proto"
"videoweb/web/middleware/auth"
"videoweb/web/service/srv_mediaresource"
"videoweb/web/service/srv_playlet"
"github.com/gin-gonic/gin"
)
// List web端短剧列表
// @Tags web短剧相关接口
// @Summary web端短剧列表 -- by 王鸣
// @Description 分页查询短剧列表
// @Accept json
// @Produce json
// @Param params query proto.PlayletListReq true "短剧列表请求"
// @Success 200 {object} proto.PlayletListPageResp "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/list [get]
func List(ctx *gin.Context) {
var req proto.PlayletListReq
if err := ctx.ShouldBindQuery(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
resp, err := srv_playlet.ListPlaylet(ctx, &req)
if err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, resp)
}
// Add web端新增短剧
// @Tags web短剧相关接口
// @Summary web端新增短剧 -- by 王鸣
// @Description 新增 playlet 集合短剧数据,支持分类、题材、标签、支付方式、推荐和 banner 配置
// @Accept json
// @Produce json
// @Param params body proto.PlayletAddReq true "新增短剧请求"
// @Success 200 {object} proto.PlayletAddResp "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/add [post]
func Add(ctx *gin.Context) {
var req proto.PlayletAddReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
resp, err := srv_playlet.AddPlaylet(ctx, &req, auth.GetAccount(ctx))
if err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, resp)
}
// Update web端编辑短剧
// @Tags web短剧相关接口
// @Summary web端编辑短剧 -- by 王鸣
// @Description 按短剧ID编辑 playlet 集合短剧数据,只更新请求中传入的字段
// @Accept json
// @Produce json
// @Param params body proto.PlayletUpdateReq true "编辑短剧请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/update [post]
func Update(ctx *gin.Context) {
var req proto.PlayletUpdateReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_playlet.UpdatePlaylet(ctx, &req, auth.GetAccount(ctx)); err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// Del 删除短剧及其关联数据
// @Tags web短剧相关接口
// @Summary web端单/批量删除短剧
// @Description 删除短剧、剧集及关联用户数据,上架和下架短剧均可删除
// @Accept json
// @Produce json
// @Param params body proto.PlayletDelReq true "删除短剧请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/del [post]
func Del(ctx *gin.Context) {
var req proto.PlayletDelReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_playlet.DelPlaylet(ctx, &req); err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// SetStatus web端单/批量设置短剧上下架
// @Tags web短剧相关接口
// @Summary web端单/批量设置短剧上下架 -- by 王鸣
// @Description 根据短剧ID集合批量更新 playlet 集合 status 字段,传1个ID表示单条设置,传多个ID表示批量设置
// @Accept json
// @Produce json
// @Param params body proto.PlayletStatusSetReq true "单/批量设置短剧上下架请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/status/set [post]
func SetStatus(ctx *gin.Context) {
var req proto.PlayletStatusSetReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_playlet.SetPlayletStatus(ctx, &req); err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// SetRecommend web端单/批量设置短剧是否推荐
// @Tags web短剧相关接口
// @Summary web端单/批量设置短剧是否推荐 -- by 王鸣
// @Description 根据短剧ID集合批量更新 playlet 集合 isRecommend 字段,传1个ID表示单条设置,传多个ID表示批量设置
// @Accept json
// @Produce json
// @Param params body proto.PlayletRecommendSetReq true "单/批量设置短剧是否推荐请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/recommend/set [post]
func SetRecommend(ctx *gin.Context) {
var req proto.PlayletRecommendSetReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_playlet.SetPlayletRecommend(ctx, &req); err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// SetFeatured web端单/批量设置短剧是否爆剧
// @Tags web短剧相关接口
// @Summary web端单/批量设置短剧是否爆剧 -- by 王鸣
// @Description 根据短剧ID集合批量更新 playlet 集合 isFeatured 字段,传1个ID表示单条设置,传多个ID表示批量设置
// @Accept json
// @Produce json
// @Param params body proto.PlayletFeaturedSetReq true "单/批量设置短剧是否爆剧请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/featured/set [post]
func SetFeatured(ctx *gin.Context) {
var req proto.PlayletFeaturedSetReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_playlet.SetPlayletFeatured(ctx, &req); err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// SetBanner web端单/批量设置短剧是否显示在首页banner
// @Tags web短剧相关接口
// @Summary web端单/批量设置短剧是否显示在首页banner -- by 王鸣
// @Description 根据短剧ID集合批量更新 playlet 集合 showOnBanner 字段,传1个ID表示单条设置,传多个ID表示批量设置
// @Accept json
// @Produce json
// @Param params body proto.PlayletBannerSetReq true "单/批量设置短剧是否显示在首页banner请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/banner/set [post]
func SetBanner(ctx *gin.Context) {
var req proto.PlayletBannerSetReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_playlet.SetPlayletBanner(ctx, &req); err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// SetTheme web端单/批量设置短剧题材
// @Tags web短剧相关接口
// @Summary web端单/批量设置短剧题材 -- by 王鸣
// @Description 根据短剧ID集合批量更新 playlet 集合 themeIds 字段,传1个ID表示单条设置,传多个ID表示批量设置
// @Accept json
// @Produce json
// @Param params body proto.PlayletThemeSetReq true "单/批量设置短剧题材请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/theme/set [post]
func SetTheme(ctx *gin.Context) {
var req proto.PlayletThemeSetReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_playlet.SetPlayletTheme(ctx, &req); err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// SetTag web端单/批量设置短剧标签
// @Tags web短剧相关接口
// @Summary web端单/批量设置短剧标签 -- by 王鸣
// @Description 根据短剧ID集合批量更新 playlet 集合 tagIds 字段,传1个ID表示单条设置,传多个ID表示批量设置
// @Accept json
// @Produce json
// @Param params body proto.PlayletTagSetReq true "单/批量设置短剧标签请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/tag/set [post]
func SetTag(ctx *gin.Context) {
var req proto.PlayletTagSetReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_playlet.SetPlayletTag(ctx, &req); err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// SetCategory web端单/批量设置短剧分类
// @Tags web短剧相关接口
// @Summary web端单/批量设置短剧分类 -- by 王鸣
// @Description 根据短剧ID集合批量更新 playlet 集合 categoryIds 字段,传1个ID表示单条设置,传多个ID表示批量设置
// @Accept json
// @Produce json
// @Param params body proto.PlayletCategorySetReq true "单/批量设置短剧分类请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/category/set [post]
func SetCategory(ctx *gin.Context) {
var req proto.PlayletCategorySetReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_playlet.SetPlayletCategory(ctx, &req); err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// SetVirtualLike web端单/批量设置短剧虚拟点赞数
// @Tags web短剧相关接口
// @Summary web端单/批量设置短剧虚拟点赞数 -- by 王鸣
// @Description 根据短剧ID集合批量更新 playlet 集合 virtualCountLike 字段,每条短剧从最小值和最大值之间随机取不重复数值入库
// @Accept json
// @Produce json
// @Param params body proto.PlayletVirtualLikeSetReq true "单/批量随机设置短剧虚拟点赞数请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/like/virtual/set [post]
func SetVirtualLike(ctx *gin.Context) {
var req proto.PlayletVirtualLikeSetReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_playlet.SetPlayletVirtualLike(ctx, &req); err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// SetVirtualBrowse web端单/批量设置短剧虚拟观看数
// @Tags web短剧相关接口
// @Summary web端单/批量设置短剧虚拟观看数 -- by 王鸣
// @Accept json
// @Produce json
// @Param params body proto.PlayletVirtualBrowseSetReq true "设置短剧虚拟观看数请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/browse/virtual/set [post]
func SetVirtualBrowse(ctx *gin.Context) {
var req proto.PlayletVirtualBrowseSetReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_playlet.SetPlayletVirtualBrowse(ctx, &req); err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// SetVirtualHeat web端单/批量设置短剧虚拟热度
// @Tags web短剧相关接口
// @Summary web端单/批量设置短剧虚拟热度 -- by 王鸣
// @Accept json
// @Produce json
// @Param params body proto.PlayletVirtualHeatSetReq true "设置短剧虚拟热度请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/heat/virtual/set [post]
func SetVirtualHeat(ctx *gin.Context) {
var req proto.PlayletVirtualHeatSetReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_playlet.SetPlayletVirtualHeat(ctx, &req); err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// SetPayType web端单/批量设置短剧默认支付方式
// @Tags web短剧相关接口
// @Summary web端单/批量设置短剧默认支付方式 -- by 王鸣
// @Description 根据短剧ID集合批量更新 playlet 集合 payType/singleCoins 字段
// @Accept json
// @Produce json
// @Param params body proto.PlayletPayTypeSetReq true "单/批量设置短剧默认支付方式请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/pay-type/set [post]
func SetPayType(ctx *gin.Context) {
var req proto.PlayletPayTypeSetReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_playlet.SetPlayletPayType(ctx, &req); err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// ResetWatermark web端按短剧ID批量重置剧集水印
// @Tags web短剧相关接口
// @Summary web端按短剧ID批量重置剧集水印 -- by 王鸣
// @Description 根据短剧ID集合重置剧集水印状态,保留已有水印地址以便换水印期间继续观看
// @Accept json
// @Produce json
// @Param params body proto.PlayletWatermarkResetReq true "批量重置短剧水印请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/watermark/reset [post]
func ResetWatermark(ctx *gin.Context) {
var req proto.PlayletWatermarkResetReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_playlet.ResetPlayletWatermark(ctx, &req); err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// ChapterList web端短剧剧集列表
// @Tags web短剧相关接口
// @Summary web端短剧剧集列表 -- by 王鸣
// @Description 分页查询 playlet_chapter 集合短剧剧集数据,默认按集数升序返回
// @Accept json
// @Produce json
// @Param params query proto.PlayletChapterListReq true "短剧剧集列表请求"
// @Success 200 {object} proto.PlayletChapterListPageResp "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/chapter/list [get]
func ChapterList(ctx *gin.Context) {
var req proto.PlayletChapterListReq
if err := ctx.ShouldBindQuery(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
resp, err := srv_playlet.ListPlayletChapter(ctx, &req)
if err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, resp)
}
// ChapterAdd web端新增短剧剧集
// @Tags web短剧相关接口
// @Summary web端新增短剧剧集 -- by 王鸣
// @Description 新增 playlet_chapter 集合短剧剧集数据
// @Accept json
// @Produce json
// @Param params body proto.PlayletChapterAddReq true "新增短剧剧集请求"
// @Success 200 {object} proto.PlayletChapterAddResp "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/chapter/add [post]
func ChapterAdd(ctx *gin.Context) {
var req proto.PlayletChapterAddReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
resp, err := srv_playlet.AddPlayletChapter(ctx, &req)
if err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, resp)
}
// ChapterDel web端单/批量删除短剧剧集
// @Tags web短剧相关接口
// @Summary web端单/批量删除短剧剧集
// @Description 根据剧集ID集合删除 playlet_chapter 记录,仅原创短剧支持删除
// @Accept json
// @Produce json
// @Param params body proto.PlayletChapterDelReq true "单/批量删除短剧剧集请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/chapter/del [post]
func ChapterDel(ctx *gin.Context) {
var req proto.PlayletChapterDelReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_playlet.DelPlayletChapter(ctx, &req); err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// ChapterSync web端手动同步短剧剧集
// @Tags web短剧相关接口
// @Summary web端手动单/批量同步短剧剧集
// @Description 根据短剧ID集合从媒资中心同步新增剧集,playletIds传1个表示单条同步,传多个表示批量同步,允许已完结短剧补集或修正状态
// @Accept json
// @Produce json
// @Param params body proto.PlayletChapterSyncReq true "手动单/批量同步短剧剧集请求"
// @Success 200 {object} proto.PlayletChapterSyncResp "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/chapter/sync [post]
func ChapterSync(ctx *gin.Context) {
var req proto.PlayletChapterSyncReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
resp, err := srv_mediaresource.SyncPlayletChapters(ctx, &req)
if err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, resp)
}
// ChapterUpdate web端编辑短剧剧集
// @Tags web短剧相关接口
// @Summary web端编辑短剧剧集 -- by 王鸣
// @Description 按剧集ID编辑 playlet_chapter 集合短剧剧集数据,只更新请求中传入的字段
// @Accept json
// @Produce json
// @Param params body proto.PlayletChapterUpdateReq true "编辑短剧剧集请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/chapter/update [post]
func ChapterUpdate(ctx *gin.Context) {
var req proto.PlayletChapterUpdateReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_playlet.UpdatePlayletChapter(ctx, &req); err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// ChapterSetPayType web端单/批量设置短剧剧集支付方式
// @Tags web短剧相关接口
// @Summary web端单/批量设置短剧剧集支付方式 -- by 王鸣
// @Description 根据剧集ID集合批量更新 playlet_chapter 集合 payType 和 singleCoins 字段,传1个ID表示单条设置,传多个ID表示批量设置
// @Accept json
// @Produce json
// @Param params body proto.PlayletChapterPayTypeSetReq true "单/批量设置短剧剧集支付方式请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/chapter/pay-type/set [post]
func ChapterSetPayType(ctx *gin.Context) {
var req proto.PlayletChapterPayTypeSetReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_playlet.SetPlayletChapterPayType(ctx, &req); err != nil {
common.ServerJSON(ctx, err, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}