by Robin at 20240119; fix
This commit is contained in:
parent
7fff48036d
commit
b14fd35846
|
@ -34,6 +34,7 @@ const (
|
|||
MaxDailyVeriCodeSendTimesKey = "max_daily_veri_code_send_times"
|
||||
ImageIdForUploadFail = "image_id_for_upload_fail"
|
||||
VideoIdForUploadFail = "video_id_for_upload_fail"
|
||||
RestrictedVisitorKey = "restricted_visitor"
|
||||
)
|
||||
|
||||
// del_flag
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package apollostruct
|
||||
|
||||
// 账户初始化数据
|
||||
type RestrictedVisitorCfg struct {
|
||||
RestrictedVisitorMids []int64 `json:"restricted_visitor_mids"` // 限制可见范围的访客mids
|
||||
RestrictedVisitorVisibleMids []int64 `json:"restricted_visitor_visible_mids"` // 限制访客可见的mids
|
||||
}
|
|
@ -1213,8 +1213,16 @@ func (s *Service) ApiGetStreamerRecommList(ctx *gin.Context, req *streamerproto.
|
|||
|
||||
ec = errcode.ErrCodeStreamerSrvOk
|
||||
|
||||
// 取apollo配置
|
||||
cfg := &apollostruct.RestrictedVisitorCfg{}
|
||||
err := apollo.GetJson(consts.RestrictedVisitorKey, &cfg, apollo.ApolloOpts().SetNamespace("application"))
|
||||
if err != nil {
|
||||
logger.Error("Apollo read failed : %v", err)
|
||||
return nil, errcode.ErrCodeApolloReadFail
|
||||
}
|
||||
|
||||
//1.从redis中获取数据
|
||||
err := redis.GetRedisClient().GetObject(consts.RedisStreamerPrefix+"recomm_list", &recommlist)
|
||||
err = redis.GetRedisClient().GetObject(consts.RedisStreamerPrefix+"recomm_list", &recommlist)
|
||||
if err != nil {
|
||||
logger.Error("Redis read failed : %v", err)
|
||||
ec = errcode.ErrCodeStreamerRecommListRedisCacheInvalid
|
||||
|
@ -1255,6 +1263,24 @@ func (s *Service) ApiGetStreamerRecommList(ctx *gin.Context, req *streamerproto.
|
|||
}
|
||||
}
|
||||
|
||||
visitorMid := req.BaseRequest.Mid
|
||||
for _, restricted_visitor_mid := range cfg.RestrictedVisitorMids {
|
||||
if restricted_visitor_mid == visitorMid { // 是限制访问的访客
|
||||
recommMap := make(map[int64]int64)
|
||||
for _, recommMid := range recommlist {
|
||||
recommMap[recommMid] = 1
|
||||
}
|
||||
restrictedRecommList := make([]int64, 0)
|
||||
for _, restrictedVisitorVisibleMid := range cfg.RestrictedVisitorVisibleMids {
|
||||
if recommMap[restrictedVisitorVisibleMid] == 1 {
|
||||
restrictedRecommList = append(restrictedRecommList, restrictedVisitorVisibleMid)
|
||||
}
|
||||
}
|
||||
recommlist = restrictedRecommList
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue