package config import ( logger "eta/eta_mini_ht_api/common/component/log" "eta/eta_mini_ht_api/common/exception" "eta/eta_mini_ht_api/models/sys" ) func GetConfigValue(configId int, configType string) (value interface{}, err error) { config, err := sys.GetConfig(configId) if err != nil { logger.Error("获取配置失败:%v,配置项[%d]", err, configId) err = exception.NewWithException(exception.GetConfigValueFailed, err.Error()) return } if config.ConfigType != configType { logger.Error("配置项类型不符 配置类型:%v,获取类型:%v", err, configId) err = exception.NewWithException(exception.IllegalConfigType, "配置项类型不符") } switch configType { case "int": value = config.IntValue case "string": value = config.StrValue case "byte": value = config.ByteValue default: logger.Error("不支持的配置类型:%v", configType) err = exception.New(exception.IllegalConfigType) } return }