by Robin at 20240427
This commit is contained in:
parent
edb5caf001
commit
7dd5e042ca
|
@ -51,6 +51,7 @@ const (
|
|||
DefaultMomentTextKey = "default_moment_text"
|
||||
MaxDailyZoneMomentCreateTimesKey = "max_daily_zone_moment_create_times"
|
||||
ReferentialZoneMomentKey = "referential_zone_moment"
|
||||
RestrictedVisitorMomentKey = "restricted_visitor_moment"
|
||||
)
|
||||
|
||||
// del_flag
|
||||
|
|
|
@ -5,3 +5,8 @@ type RestrictedVisitorCfg struct {
|
|||
RestrictedVisitorMids []int64 `json:"restricted_visitor_mids"` // 限制可见范围的访客mids
|
||||
RestrictedVisitorVisibleMids []int64 `json:"restricted_visitor_visible_mids"` // 限制访客可见的mids
|
||||
}
|
||||
|
||||
type RestrictedVisitorMomentCfg struct {
|
||||
RestrictedVisitorMids []int64 `json:"restricted_visitor_mids"` // 限制可见范围的访客mids
|
||||
RestrictedVisitorVisibleMomentIds []int64 `json:"restricted_visitor_visible_moment_ids"` // 限制访客可见的动态ids
|
||||
}
|
||||
|
|
|
@ -2053,6 +2053,33 @@ func (s *Service) ApiGetMomentRecommList(ctx *gin.Context, req *momentproto.ApiR
|
|||
ids = append(ids, recommIds...)
|
||||
}
|
||||
|
||||
// 取apollo配置
|
||||
cfg := &apollostruct.RestrictedVisitorMomentCfg{}
|
||||
err = apollo.GetJson(consts.RestrictedVisitorMomentKey, &cfg, apollo.ApolloOpts().SetNamespace("application"))
|
||||
if err != nil {
|
||||
logger.Error("Apollo read failed : %v", err)
|
||||
return nil, errcode.ErrCodeApolloReadFail
|
||||
}
|
||||
|
||||
// 查询是否限制访客
|
||||
visitorMid := req.BaseRequest.Mid
|
||||
for _, restricted_visitor_mid := range cfg.RestrictedVisitorMids {
|
||||
if restricted_visitor_mid == visitorMid { // 是限制访问的访客
|
||||
recommMap := make(map[int64]int64)
|
||||
for _, momentId := range ids {
|
||||
recommMap[momentId] = 1
|
||||
}
|
||||
restrictedRecommList := make([]int64, 0)
|
||||
for _, restrictedVisitorVisibleMomentId := range cfg.RestrictedVisitorVisibleMomentIds {
|
||||
if recommMap[restrictedVisitorVisibleMomentId] == 1 {
|
||||
restrictedRecommList = append(restrictedRecommList, restrictedVisitorVisibleMomentId)
|
||||
}
|
||||
}
|
||||
ids = restrictedRecommList
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// 4.查询动态内容
|
||||
recommMomentList, err = s.utilGetApiMomentVOListByIds(ctx, req.Mid, ids)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue