注意:这里的 cfg 参数是值传递
(storeType helper.ConfigCate, cfg interface{})
| 278 | |
| 279 | // 注意:这里的 cfg 参数是值传递 |
| 280 | func (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配置 |
| 307 | func (this *Config) UpdateGlobalConfig() { |
no test coverage detected