MCPcopy Create free account
hub / github.com/TruthHun/DocHub / UpdateCloudStore

Method UpdateCloudStore

models/ConfigModel.go:280–304  ·  view source on GitHub ↗

注意:这里的 cfg 参数是值传递

(storeType helper.ConfigCate, cfg interface{})

Source from the content-addressed store, hash-verified

278
279// 注意:这里的 cfg 参数是值传递
280func (this *Config) UpdateCloudStore(storeType helper.ConfigCate, cfg interface{}) (err error) {
281 t := reflect.TypeOf(cfg)
282 v := reflect.ValueOf(cfg)
283 numFields := t.Elem().NumField()
284 o := orm.NewOrm()
285 o.Begin()
286 defer func() {
287 if err == nil {
288 o.Commit()
289 this.UpdateGlobalConfig()
290 } else {
291 o.Rollback()
292 }
293 }()
294 for i := 0; i < numFields; i++ {
295 key := t.Elem().Field(i).Tag.Get("dochub")
296 params := orm.Params{"Value": v.Elem().Field(i).Interface()}
297 _, err = o.QueryTable(this).Filter("Key", key).Filter("Category", storeType).Update(params)
298 if err != nil {
299 return
300 }
301 }
302 go this.UpdateGlobalConfig()
303 return
304}
305
306//更新全局config配置
307func (this *Config) UpdateGlobalConfig() {

Callers 1

SetCloudStoreMethod · 0.95

Calls 3

UpdateGlobalConfigMethod · 0.95
UpdateMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected