diff --git a/api/consts/consts.go b/api/consts/consts.go index 630aedeb..7367855f 100644 --- a/api/consts/consts.go +++ b/api/consts/consts.go @@ -53,6 +53,7 @@ const ( ReferentialZoneMomentKey = "referential_zone_moment" IsMomentImageEncryptEnabledKey = "is_moment_image_encrypt_enabled" RestrictedVisitorMomentKey = "restricted_visitor_moment" + AppConfigReflectKey = "app_config_reflect" ) // del_flag diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 12ab027c..6ed61a12 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -40,6 +40,7 @@ import ( "service/library/contentaudit/textaudit" videomoderation "service/library/contentaudit/video_moderation" "service/library/logger" + "strings" "time" "go.mongodb.org/mongo-driver/mongo" @@ -2110,7 +2111,23 @@ func (s *Service) ApiGetThumbsUpList(ctx *gin.Context, req *thumbsupproto.ApiLis func (s *Service) ApiGetAppConfigListByKey(ctx *gin.Context, req *appconfigproto.ApiListByKeyReq) (appconfig *dbstruct.AppConfig, ec errcode.ErrCode) { ec = errcode.ErrCodeAppConfigSrvOk - appconfig, err := _DefaultAppConfig.OpListByKey(ctx, &appconfigproto.OpListByKeyReq{ + //读取版本下是否有字段需要进行版本映射 + appConfigReflect, err := apollo.GetStringValue(consts.AppConfigReflectKey+"_"+req.BaseRequest.Version, apollo.ApolloOpts().SetNamespace("version")) + if err != nil { + logger.Error("Apollo read failed : %v", err) + ec = errcode.ErrCodeApolloReadFail + return + } + if appConfigReflect != "" { + appConfigReflectColumns := strings.Split(appConfigReflect, ";") + for _, column := range appConfigReflectColumns { + if req.ConfigKey == column { + req.ConfigKey = req.ConfigKey + "_" + req.BaseRequest.Version + } + } + } + + appconfig, err = _DefaultAppConfig.OpListByKey(ctx, &appconfigproto.OpListByKeyReq{ ConfigKey: req.ConfigKey, }) if err != nil { diff --git a/app/mix/service/service.go b/app/mix/service/service.go index 65a4e12d..34cef75d 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -57,6 +57,7 @@ import ( "service/library/payclients/alipaycli" "service/library/payclients/wxpaycli" "service/library/redis" + "strings" "time" accountpunishmentproto "service/api/proto/accountpunishment/proto" @@ -2968,7 +2969,23 @@ func (s *Service) OpGetAppConfigListByKey(ctx *gin.Context, req *appconfigproto. return } - appconfig, err := _DefaultAppConfig.OpListByKey(ctx, req) + //读取版本下是否有字段需要进行版本映射 + appConfigReflect, err := apollo.GetStringValue(consts.AppConfigReflectKey+"_"+req.BaseRequest.Version, apollo.ApolloOpts().SetNamespace("version")) + if err != nil { + logger.Error("Apollo read failed : %v", err) + ec = errcode.ErrCodeApolloReadFail + return + } + if appConfigReflect != "" { + appConfigReflectColumns := strings.Split(appConfigReflect, ";") + for _, column := range appConfigReflectColumns { + if req.ConfigKey == column { + req.ConfigKey = req.ConfigKey + "_" + req.BaseRequest.Version + } + } + } + + appconfig, err = _DefaultAppConfig.OpListByKey(ctx, req) if err != nil { logger.Error("OpGetAppConfigListByKey fail, req: %v, err: %v", util.ToJson(req), err) ec = errcode.ErrCodeAppConfigSrvFail