Opt: set setting use assertion judgment

pull/21/head
zijiren233 2 years ago
parent 94823a3d96
commit f8ab5d4da6

@ -27,7 +27,14 @@ func AdminSettings(ctx *gin.Context) {
} }
switch t { switch t {
case dbModel.SettingTypeBool: case dbModel.SettingTypeBool:
op.BoolSettings[k].Set(v == "1") b, ok := v.(bool)
if !ok {
ctx.AbortWithStatusJSON(http.StatusBadRequest, model.NewApiErrorStringResp(fmt.Sprintf("setting %s is not bool", k)))
return
}
op.BoolSettings[k].Set(b)
} }
} }
ctx.Status(http.StatusNoContent)
} }

@ -5,7 +5,7 @@ import (
json "github.com/json-iterator/go" json "github.com/json-iterator/go"
) )
type AdminSettingsReq map[string]string type AdminSettingsReq map[string]any
func (asr *AdminSettingsReq) Validate() error { func (asr *AdminSettingsReq) Validate() error {
return nil return nil

Loading…
Cancel
Save