package web_homebanner import ( "hkdj-web-server/pub/common" "hkdj-web-server/pub/common/srvdef" "hkdj-web-server/web/api/proto" "hkdj-web-server/web/middleware/auth" "hkdj-web-server/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, "") }