init: web_hgcg_server 初始化提交
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
package web_homeconfig
|
||||
|
||||
import (
|
||||
"videoweb/pub/common"
|
||||
"videoweb/pub/common/srvdef"
|
||||
"videoweb/web/api/proto"
|
||||
"videoweb/web/service/srv_homeconfig"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List 首页配置列表
|
||||
// @Tags web首页配置相关接口
|
||||
// @Summary 首页配置列表 -- by 王鸣
|
||||
// @Description 分页查询首页配置
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param params query proto.HomeConfigListReq true "首页配置列表请求"
|
||||
// @Success 200 {object} proto.HomeConfigListPageResp "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/home/config/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
var req proto.HomeConfigListReq
|
||||
if err := ctx.ShouldBindQuery(&req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
resp, err := srv_homeconfig.ListHomeConfig(ctx, &req)
|
||||
if err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// Add 新增首页配置
|
||||
// @Tags web首页配置相关接口
|
||||
// @Summary 新增首页配置 -- by 王鸣
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param params body proto.HomeConfigAddReq true "新增首页配置请求"
|
||||
// @Success 200 {object} proto.HomeConfigAddResp "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/home/config/add [post]
|
||||
func Add(ctx *gin.Context) {
|
||||
var req proto.HomeConfigAddReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
resp, err := srv_homeconfig.AddHomeConfig(ctx, &req)
|
||||
if err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// Update 更新首页配置
|
||||
// @Tags web首页配置相关接口
|
||||
// @Summary 更新首页配置 -- by 王鸣
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param params body proto.HomeConfigUpdateReq true "更新首页配置请求"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/home/config/update [post]
|
||||
func Update(ctx *gin.Context) {
|
||||
var req proto.HomeConfigUpdateReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if err := srv_homeconfig.UpdateHomeConfig(ctx, &req); err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
// Del 删除首页配置
|
||||
// @Tags web首页配置相关接口
|
||||
// @Summary 删除首页配置 -- by 王鸣
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param params body proto.HomeConfigDelReq true "删除首页配置请求"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/home/config/del [post]
|
||||
func Del(ctx *gin.Context) {
|
||||
var req proto.HomeConfigDelReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
if err := srv_homeconfig.DelHomeConfig(ctx, &req); err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
Reference in New Issue
Block a user