MCPcopy Index your code
hub / github.com/TruthHun/DocHub / GetGlobalConfigWithStruct

Method GetGlobalConfigWithStruct

models/ConfigModel.go:166–208  ·  view source on GitHub ↗

获取云存储配置

(configCate helper.ConfigCate)

Source from the content-addressed store, hash-verified

164
165// 获取云存储配置
166func (this *Config) GetGlobalConfigWithStruct(configCate helper.ConfigCate) (cfg interface{}) {
167 switch configCate {
168 case StoreCos:
169 cfg = &ConfigCos{}
170 case StoreBos:
171 cfg = &ConfigBos{}
172 case StoreOss:
173 cfg = &ConfigOss{}
174 case StoreMinio:
175 cfg = &ConfigMinio{}
176 case StoreUpyun:
177 cfg = &ConfigUpYun{}
178 case StoreQiniu:
179 cfg = &ConfigQiniu{}
180 case StoreObs:
181 cfg = &ConfigObs{}
182 case ConfigCateEmail:
183 cfg = &ConfigEmail{}
184 }
185 t := reflect.TypeOf(cfg)
186 v := reflect.ValueOf(cfg)
187 numFields := t.Elem().NumField()
188 for i := 0; i < numFields; i++ {
189 key := t.Elem().Field(i).Tag.Get("dochub")
190 if v.Elem().Field(i).CanSet() && key != "" {
191 switch t.Elem().Field(i).Type.Kind() {
192 case reflect.String:
193 v.Elem().Field(i).Set(reflect.ValueOf(helper.GetConfig(configCate, key)))
194 case reflect.Int64:
195 v.Elem().Field(i).Set(reflect.ValueOf(helper.GetConfigInt64(configCate, key)))
196 case reflect.Int:
197 v.Elem().Field(i).Set(reflect.ValueOf(int(helper.GetConfigInt64(configCate, key))))
198 case reflect.Float64:
199 v.Elem().Field(i).Set(reflect.ValueOf(helper.GetConfigFloat64(configCate, key)))
200 case reflect.Float32:
201 v.Elem().Field(i).Set(reflect.ValueOf(float32(helper.GetConfigFloat64(configCate, key))))
202 case reflect.Bool:
203 v.Elem().Field(i).Set(reflect.ValueOf(helper.GetConfigBool(configCate, key)))
204 }
205 }
206 }
207 return
208}
209
210func (this *Config) ParseForm(configCate helper.ConfigCate, form url.Values) (cfg interface{}, err error) {
211 switch configCate {

Callers 2

NewCloudStoreFunction · 0.95
NewEmailFunction · 0.80

Calls 1

GetMethod · 0.45

Tested by

no test coverage detected