来源:hgdjnet-server 9bfbafe10d417deea959bd53117bc88a10e60a83 项目身份 HKDJ / JHA-216,独立官网仓库,Jenkins 守卫键 hkdjnet 测试目录 /server/hkdj_net,App/Web API 30331/30332 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
106 lines
3.1 KiB
Go
106 lines
3.1 KiB
Go
package web_homeconfig
|
|
|
|
import (
|
|
"hkdj-web-server/pub/common"
|
|
"hkdj-web-server/pub/common/srvdef"
|
|
"hkdj-web-server/web/api/proto"
|
|
"hkdj-web-server/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, "")
|
|
}
|