获取云存储配置
(configCate helper.ConfigCate)
| 164 | |
| 165 | // 获取云存储配置 |
| 166 | func (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 | |
| 210 | func (this *Config) ParseForm(configCate helper.ConfigCate, form url.Values) (cfg interface{}, err error) { |
| 211 | switch configCate { |
no test coverage detected