Files
web_hgtv_server/web/api/web_playlet/theme.go
T
rootandClaude Opus 5.5 7974a42301 Initial commit
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-23 11:07:42 +08:00

130 lines
3.9 KiB
Go

package web_playlet
import (
"videoweb/pub/common"
"videoweb/pub/common/srvdef"
"videoweb/web/api/proto"
"videoweb/web/service/srv_playlet"
"github.com/gin-gonic/gin"
)
// ThemeList web端题材列表
// @Tags web短剧相关接口
// @Summary web端题材列表
// @Description 分页查询短剧题材
// @Accept json
// @Produce json
// @Param params query proto.PlayletThemeListReq true "题材列表请求"
// @Success 200 {object} proto.PlayletThemeListPageResp "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/theme/list [get]
func ThemeList(ctx *gin.Context) {
var req proto.PlayletThemeListReq
if err := ctx.ShouldBindQuery(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
resp, err := srv_playlet.ListPlayletTheme(ctx, &req)
if err != nil {
common.ServerJSON(ctx, err.Code, err.Tips)
return
}
common.ServerJSON(ctx, srvdef.Success, resp)
}
// ThemeAdd web端新增题材
// @Tags web短剧相关接口
// @Summary web端新增题材
// @Accept json
// @Produce json
// @Param params body proto.PlayletThemeAddReq true "新增题材请求"
// @Success 200 {object} proto.PlayletThemeAddResp "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/theme/add [post]
func ThemeAdd(ctx *gin.Context) {
var req proto.PlayletThemeAddReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
resp, err := srv_playlet.AddPlayletTheme(ctx, &req)
if err != nil {
common.ServerJSON(ctx, err.Code, err.Tips)
return
}
common.ServerJSON(ctx, srvdef.Success, resp)
}
// ThemeUpdate web端更新题材
// @Tags web短剧相关接口
// @Summary web端更新题材
// @Accept json
// @Produce json
// @Param params body proto.PlayletThemeUpdateReq true "更新题材请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/theme/update [post]
func ThemeUpdate(ctx *gin.Context) {
var req proto.PlayletThemeUpdateReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_playlet.UpdatePlayletTheme(ctx, &req); err != nil {
common.ServerJSON(ctx, err.Code, err.Tips)
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// SetThemeRecommend web端单/批量设置题材是否推荐
// @Tags web短剧相关接口
// @Summary web端单/批量设置题材是否推荐
// @Description 根据题材ID集合批量更新 playlet_theme 集合 isRecommend 字段
// @Accept json
// @Produce json
// @Param params body proto.PlayletThemeRecommendSetReq true "单/批量设置题材是否推荐请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/theme/recommend/set [post]
func SetThemeRecommend(ctx *gin.Context) {
var req proto.PlayletThemeRecommendSetReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_playlet.SetPlayletThemeRecommend(ctx, &req); err != nil {
common.ServerJSON(ctx, err.Code, err.Tips)
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// ThemeDel web端删除题材
// @Tags web短剧相关接口
// @Summary web端删除题材
// @Accept json
// @Produce json
// @Param params body proto.PlayletThemeDelReq true "删除题材请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/playlet/theme/del [post]
func ThemeDel(ctx *gin.Context) {
var req proto.PlayletThemeDelReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_playlet.DelPlayletTheme(ctx, req.Id); err != nil {
common.ServerJSON(ctx, err.Code, err.Tips)
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}