init: web_hgdjc_server

This commit is contained in:
2026-11-07 10:44:09 +08:00
commit 71a4f4e175
713 changed files with 147749 additions and 0 deletions
+75
View File
@@ -0,0 +1,75 @@
package web_cfg
import (
"videoweb/pub/common"
"videoweb/pub/common/srvdef"
"videoweb/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{})
}
// @Tags 系统配置
// @Summary 设置媒资库 appKey
// @Description 单独设置 sys_cfg.appKey,并刷新内存缓存
// @Accept json
// @Produce json
// @Param param body SetAppKeyReq true "参数列表"
// @Success 200 {object} SetAppKeyResp "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/web/syscfg/appkey [POST]
func SetAppKey(ctx *gin.Context) {
var req SetAppKeyReq
if err := ctx.ShouldBindJSON(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, err.Error())
return
}
if err := srv_cfg.SetAppKey(ctx, req.AppKey); err != nil {
common.ServerJSON(ctx, err.Code, err.Error())
return
}
common.ServerJSON(ctx, srvdef.Success, &SetAppKeyResp{})
}
+24
View File
@@ -0,0 +1,24 @@
package web_cfg
import (
"videoweb/pub/models/cfg"
"videoweb/web/service/srv_cfg"
)
type GetSysConfigReq struct {
}
type GetSysConfigResp struct {
*cfg.SysCfg
}
type SysConfigUpdateReq struct {
srv_cfg.SysCfgUpdate
}
type SysConfigUpdateResp struct{}
type SetAppKeyReq struct {
AppKey string `json:"appKey"` // 媒资库 appKey
}
type SetAppKeyResp struct{}