by Robin at 20240501

This commit is contained in:
Leufolium 2024-05-01 04:32:09 +08:00
parent cf4068ddca
commit 7317ea2a65
3 changed files with 37 additions and 2 deletions

View File

@ -53,6 +53,7 @@ const (
ReferentialZoneMomentKey = "referential_zone_moment" ReferentialZoneMomentKey = "referential_zone_moment"
IsMomentImageEncryptEnabledKey = "is_moment_image_encrypt_enabled" IsMomentImageEncryptEnabledKey = "is_moment_image_encrypt_enabled"
RestrictedVisitorMomentKey = "restricted_visitor_moment" RestrictedVisitorMomentKey = "restricted_visitor_moment"
AppConfigReflectKey = "app_config_reflect"
) )
// del_flag // del_flag

View File

@ -40,6 +40,7 @@ import (
"service/library/contentaudit/textaudit" "service/library/contentaudit/textaudit"
videomoderation "service/library/contentaudit/video_moderation" videomoderation "service/library/contentaudit/video_moderation"
"service/library/logger" "service/library/logger"
"strings"
"time" "time"
"go.mongodb.org/mongo-driver/mongo" "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) { func (s *Service) ApiGetAppConfigListByKey(ctx *gin.Context, req *appconfigproto.ApiListByKeyReq) (appconfig *dbstruct.AppConfig, ec errcode.ErrCode) {
ec = errcode.ErrCodeAppConfigSrvOk 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, ConfigKey: req.ConfigKey,
}) })
if err != nil { if err != nil {

View File

@ -57,6 +57,7 @@ import (
"service/library/payclients/alipaycli" "service/library/payclients/alipaycli"
"service/library/payclients/wxpaycli" "service/library/payclients/wxpaycli"
"service/library/redis" "service/library/redis"
"strings"
"time" "time"
accountpunishmentproto "service/api/proto/accountpunishment/proto" accountpunishmentproto "service/api/proto/accountpunishment/proto"
@ -2968,7 +2969,23 @@ func (s *Service) OpGetAppConfigListByKey(ctx *gin.Context, req *appconfigproto.
return 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 { if err != nil {
logger.Error("OpGetAppConfigListByKey fail, req: %v, err: %v", util.ToJson(req), err) logger.Error("OpGetAppConfigListByKey fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeAppConfigSrvFail ec = errcode.ErrCodeAppConfigSrvFail