fix vip config

This commit is contained in:
lwl0608 2024-05-06 20:17:52 +08:00
parent e1f6f9f9d7
commit 2a5192c4e1
4 changed files with 28 additions and 0 deletions

View File

@ -54,6 +54,7 @@ const (
IsMomentImageEncryptEnabledKey = "is_moment_image_encrypt_enabled" IsMomentImageEncryptEnabledKey = "is_moment_image_encrypt_enabled"
RestrictedVisitorMomentKey = "restricted_visitor_moment" RestrictedVisitorMomentKey = "restricted_visitor_moment"
AppConfigReflectKey = "app_config_reflect" AppConfigReflectKey = "app_config_reflect"
ZoneVIPConfigKey = "zone_vip_config"
) )
// del_flag // del_flag

5
apollostruct/zone_vip.go Normal file
View File

@ -0,0 +1,5 @@
package apollostruct
type ZoneVIPConfig struct {
WhiteMids []int64 `json:"white_mids"`
}

View File

@ -1462,9 +1462,22 @@ var ZoneVIPMidMap = map[int64]bool{
161: true, 161: true,
1: true, 1: true,
170: true, 170: true,
165: true,
168: true,
167: true,
169: true,
2: true,
} }
func IsZoneVIP(mid int64) bool { func IsZoneVIP(mid int64) bool {
cfg := &apollostruct.ZoneVIPConfig{}
_ = apollo.GetJson(consts.ZoneVIPConfigKey, cfg, apollo.ApolloOpts().SetNamespace("zone"))
if util.Int64Contains(cfg.WhiteMids, mid) {
if mid == 161 {
logger.Info("_ZoneVip Apollo, mids: %v", cfg.WhiteMids)
}
return true
}
return ZoneVIPMidMap[mid] return ZoneVIPMidMap[mid]
} }

View File

@ -58,6 +58,15 @@ func StringsContains(elems []string, v string) bool {
return false return false
} }
func Int64Contains(elems []int64, v int64) bool {
for _, s := range elems {
if s == v {
return true
}
}
return false
}
// 下划线转大写驼峰 // 下划线转大写驼峰
func UderscoreToUpperCamelCase(s string) string { func UderscoreToUpperCamelCase(s string) string {
s = strings.Replace(s, "_", " ", -1) s = strings.Replace(s, "_", " ", -1)