package v2 import ( "github.com/1Panel-dev/1Panel/agent/app/api/v2/helper" "github.com/1Panel-dev/1Panel/agent/app/dto" "github.com/1Panel-dev/1Panel/agent/constant" "github.com/1Panel-dev/1Panel/agent/global" "github.com/gin-gonic/gin" ) // @Tags System Setting // @Summary Load system setting info // @Description 加载系统配置信息 // @Success 200 {object} dto.SettingInfo // @Security ApiKeyAuth // @Router /settings/search [post] func (b *BaseApi) GetSettingInfo(c *gin.Context) { setting, err := settingService.GetSettingInfo() if err != nil { helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) return } helper.SuccessWithData(c, setting) } // @Tags System Setting // @Summary Load system available status // @Description 获取系统可用状态 // @Success 200 // @Security ApiKeyAuth // @Router /settings/search/available [get] func (b *BaseApi) GetSystemAvailable(c *gin.Context) { helper.SuccessWithData(c, nil) } // @Tags System Setting // @Summary Update system setting // @Description 更新系统配置 // @Accept json // @Param request body dto.SettingUpdate true "request" // @Success 200 // @Security ApiKeyAuth // @Router /settings/update [post] // @x-panel-log {"bodyKeys":["key","value"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改系统配置 [key] => [value]","formatEN":"update system setting [key] => [value]"} func (b *BaseApi) UpdateSetting(c *gin.Context) { var req dto.SettingUpdate if err := helper.CheckBindAndValidate(&req, c); err != nil { return } if err := settingService.Update(req.Key, req.Value); err != nil { helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) return } helper.SuccessWithData(c, nil) } // @Tags System Setting // @Summary Load local backup dir // @Description 获取安装根目录 // @Success 200 {string} path // @Security ApiKeyAuth // @Router /settings/basedir [get] func (b *BaseApi) LoadBaseDir(c *gin.Context) { helper.SuccessWithData(c, global.CONF.System.DataDir) }