Files
web_hgdjc_server/web/api/web_homebanner/banner.go
T
2026-11-07 10:44:09 +08:00

107 lines
3.1 KiB
Go

package web_homebanner
import (
"videoweb/pub/common"
"videoweb/pub/common/srvdef"
"videoweb/web/api/proto"
"videoweb/web/middleware/auth"
"videoweb/web/service/srv_homebanner"
"github.com/gin-gonic/gin"
)
// List 首页banner列表
// @Tags web首页banner相关接口
// @Summary 首页banner列表 -- by 王鸣
// @Description 分页查询首页banner配置
// @Accept json
// @Produce json
// @Param params query proto.HomeBannerListReq true "首页banner列表请求"
// @Success 200 {object} proto.HomeBannerListPageResp "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/home/banner/list [get]
func List(ctx *gin.Context) {
var req proto.HomeBannerListReq
if err := ctx.ShouldBindQuery(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
resp, err := srv_homebanner.ListHomeBanner(ctx, &req)
if err != nil {
common.ServerJSON(ctx, err.Code, err.Tips)
return
}
common.ServerJSON(ctx, srvdef.Success, resp)
}
// Add 新增首页banner
// @Tags web首页banner相关接口
// @Summary 新增首页banner -- by 王鸣
// @Accept json
// @Produce json
// @Param params body proto.HomeBannerAddReq true "新增首页banner请求"
// @Success 200 {object} proto.HomeBannerAddResp "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/home/banner/add [post]
func Add(ctx *gin.Context) {
var req proto.HomeBannerAddReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
resp, err := srv_homebanner.AddHomeBanner(ctx, &req, auth.GetAccount(ctx))
if err != nil {
common.ServerJSON(ctx, err.Code, err.Tips)
return
}
common.ServerJSON(ctx, srvdef.Success, resp)
}
// Update 更新首页banner
// @Tags web首页banner相关接口
// @Summary 更新首页banner -- by 王鸣
// @Accept json
// @Produce json
// @Param params body proto.HomeBannerUpdateReq true "更新首页banner请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/home/banner/update [post]
func Update(ctx *gin.Context) {
var req proto.HomeBannerUpdateReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_homebanner.UpdateHomeBanner(ctx, &req, auth.GetAccount(ctx)); err != nil {
common.ServerJSON(ctx, err.Code, err.Tips)
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// Del 删除首页banner
// @Tags web首页banner相关接口
// @Summary 删除首页banner -- by 王鸣
// @Accept json
// @Produce json
// @Param params body proto.HomeBannerDelReq true "删除首页banner请求"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/home/banner/del [post]
func Del(ctx *gin.Context) {
var req proto.HomeBannerDelReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if err := srv_homebanner.DelHomeBanner(ctx, &req); err != nil {
common.ServerJSON(ctx, err.Code, err.Tips)
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}