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

88 lines
2.8 KiB
Go

package web_mediaresource
import (
"videoweb/pub/common"
"videoweb/pub/common/log"
"videoweb/pub/common/srvdef"
"videoweb/web/api/proto"
"videoweb/web/service/srv_mediaresource"
"github.com/gin-gonic/gin"
)
// ResourceList web端短剧媒资列表
// @Tags web媒资库相关接口
// @Summary web端短剧媒资列表 -- by 王鸣
// @Description 分页查询短剧媒资列表
// @Accept json
// @Produce json
// @Param params query proto.PlayletResourceListReq true "短剧媒资列表请求"
// @Success 200 {object} proto.PlayletResourceListResp "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/resource/list [get]
func ResourceList(ctx *gin.Context) {
var req proto.PlayletResourceListReq
if err := ctx.ShouldBindQuery(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
resp, err := srv_mediaresource.ListPlayletResource(ctx, &req)
if err != nil {
common.ServerJSON(ctx, err.Code, err.Tips)
return
}
common.ServerJSON(ctx, srvdef.Success, resp)
}
// ResourceImport web端短剧媒资入库
// @Tags web媒资库相关接口
// @Summary web端短剧媒资入库 -- by 王鸣
// @Description 提交媒资入库任务,后台从媒资中心同步短剧详情并写入短剧和章节集合
// @Accept json
// @Produce json
// @Param params body proto.PlayletResourceUseReq true "短剧媒资入库请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/resource/import [post]
func ResourceImport(ctx *gin.Context) {
var req proto.PlayletResourceUseReq
if err := ctx.ShouldBindJSON(&req); err != nil {
log.Error("短剧媒资入库参数绑定失败", log.E(err))
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
resp, err := srv_mediaresource.ImportPlayletResource(ctx, &req)
if err != nil {
common.ServerJSON(ctx, err.Code, err.Tips)
return
}
common.ServerJSON(ctx, srvdef.Success, resp)
}
// ResourceChapters web端短剧媒资剧集列表
// @Tags web媒资库相关接口
// @Summary web端短剧媒资剧集列表 -- by 王鸣
// @Description 按媒资ID查询剧集信息,复用入库时的 mediaSync 接口
// @Accept json
// @Produce json
// @Param id query int true "媒资中心资源ID"
// @Success 200 {object} proto.PlayletResourceChapterListResp "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/resource/chapters [get]
func ResourceChapters(ctx *gin.Context) {
var req proto.PlayletResourceChapterListReq
if err := ctx.ShouldBindQuery(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
resp, err := srv_mediaresource.ListPlayletResourceChapters(ctx, &req)
if err != nil {
common.ServerJSON(ctx, err.Code, err.Tips)
return
}
common.ServerJSON(ctx, srvdef.Success, resp)
}