feat: 从黄果 NET hgdjnet-server 9bfbafe 导入 HKDJ 官网后端
来源: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>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package web_cfg
|
||||
|
||||
import (
|
||||
"hkdj-web-server/pub/common"
|
||||
"hkdj-web-server/pub/common/srvdef"
|
||||
"hkdj-web-server/web/service/srv_cfg"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 系统配置
|
||||
// @Summary 获取系统配置
|
||||
// @Description 获取系统配置
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body GetSysConfigReq true "参数列表"
|
||||
// @Success 200 {object} GetSysConfigResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/syscfg/get [GET]
|
||||
func GetCfg(ctx *gin.Context) {
|
||||
config, err := srv_cfg.GetSystemConfig(ctx)
|
||||
if err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Error())
|
||||
return
|
||||
}
|
||||
resp := &GetSysConfigResp{config}
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 系统配置
|
||||
// @Summary 修改系统配置
|
||||
// @Description 修改系统配置
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body SysConfigUpdateReq true "参数列表"
|
||||
// @Success 200 {object} SysConfigUpdateResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/web/syscfg/update [POST]
|
||||
func UpdateCfg(ctx *gin.Context) {
|
||||
var req SysConfigUpdateReq
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err := srv_cfg.UpdateSystemConfig(ctx, &req.SysCfgUpdate); err != nil {
|
||||
common.ServerJSON(ctx, err.Code, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, &SysConfigUpdateResp{})
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package web_cfg
|
||||
|
||||
import (
|
||||
"hkdj-web-server/pub/models/cfg"
|
||||
"hkdj-web-server/web/service/srv_cfg"
|
||||
)
|
||||
|
||||
type GetSysConfigReq struct {
|
||||
}
|
||||
|
||||
type GetSysConfigResp struct {
|
||||
*cfg.SysCfg
|
||||
}
|
||||
|
||||
type SysConfigUpdateReq struct {
|
||||
srv_cfg.SysCfgUpdate
|
||||
}
|
||||
type SysConfigUpdateResp struct{}
|
||||
Reference in New Issue
Block a user