76 lines
2.2 KiB
Go
76 lines
2.2 KiB
Go
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{})
|
|
}
|