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

106 lines
3.1 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端题材列表 -- by 王鸣
// @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, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, resp)
}
// ThemeAdd web端新增题材
// @Tags web短剧相关接口
// @Summary web端新增题材 -- by 王鸣
// @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, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, resp)
}
// ThemeUpdate web端更新题材
// @Tags web短剧相关接口
// @Summary web端更新题材 -- by 王鸣
// @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, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// ThemeDel web端删除题材
// @Tags web短剧相关接口
// @Summary web端删除题材 -- by 王鸣
// @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, err.GetMsg())
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}