diff --git a/api/consts/notif_template.go b/api/consts/notif_template.go index 5d0a3afb..14dfad4f 100644 --- a/api/consts/notif_template.go +++ b/api/consts/notif_template.go @@ -20,7 +20,7 @@ const ( SysNotifTemp_ZoneVasUpdated = 9 // 设置空间付费信息 SysNotifTemp_ZoneThirdPartnerCreated = 10 // 博主自己设置空间代运营 SysNotifTemp_MembershipPurchased = 11 // 开通会员 - SysNotifTemp_PlatformInfoUpdated = 12 // 主播编辑平台并保存 + SysNotifTemp_PlatformInfoUpdated = 12 // 主播编辑平台并保存(todo) AudNotifTemp_AvatarChangeApplied = 100 // 用户修改头像 AudNotifTemp_AvatarPassed = 101 // 用户修改头像成功 @@ -67,7 +67,7 @@ const ( AudNotifTemp_ZoneMomentReeditionRejected = 144 // 运营审核拒绝重新编辑的空间贴 VasNotifTemp_MembershipPurchased = 200 // 开通会员 - VasNotifTemp_WithdrawalFinished = 201 // 提现 + VasNotifTemp_WithdrawalFinished = 201 // 提现成功 VasNotifTemp_ZoneAdmissionPurchased_User = 202 // 用户【付费/免费】加入主播空间-用户侧 VasNotifTemp_ZoneAdmissionPurchased_Streamer = 203 // 用户【付费/免费】加入主播空间-主播侧 VasNotifTemp_ZoneSuperfanshipPurchased_User = 204 // 用户付费成为主播的超粉-用户侧 diff --git a/api/proto/zonemoment/proto/not_null_def_api.go b/api/proto/zonemoment/proto/not_null_def_api.go index 88385610..c857420a 100644 --- a/api/proto/zonemoment/proto/not_null_def_api.go +++ b/api/proto/zonemoment/proto/not_null_def_api.go @@ -81,3 +81,11 @@ func (p *ApiHeadReq) ProvideNotNullValue() (params []*validator.JsonParam) { return } + +func (p *ApiListByIdsReq) ProvideNotNullValue() (params []*validator.JsonParam) { + params = make([]*validator.JsonParam, 0) + + params = append(params, validator.NewInt64SliceParam("请确认动态的ids!", p.Ids)) + + return +} diff --git a/api/proto/zonemoment/proto/zonemoment_api.go b/api/proto/zonemoment/proto/zonemoment_api.go index 7d8006a6..65ff33ff 100644 --- a/api/proto/zonemoment/proto/zonemoment_api.go +++ b/api/proto/zonemoment/proto/zonemoment_api.go @@ -163,3 +163,17 @@ type ApiListStatisticsByCreaterMidResp struct { base.BaseResponse Data *ApiListStatisticsByCreaterMidData `json:"data"` } + +// op ids查询 +type ApiListByIdsReq struct { + base.BaseRequest + Ids []int64 `json:"ids"` +} + +type ApiListByIdsData struct { +} + +type ApiListByIdsResp struct { + base.BaseResponse + Data *ApiListByIdsData `json:"data"` +} diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 30eb7a88..27bad547 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -5139,6 +5139,23 @@ func (m *Mongo) GetZidsByZoneMomentIds(ctx *gin.Context, zonemomentIds []int64) return zids, err } +func (m *Mongo) GetZoneMomentListByIds(ctx *gin.Context, ids []int64) ([]*dbstruct.ZoneMoment, error) { + list := make([]*dbstruct.ZoneMoment, 0) + col := m.getColZoneMoment() + query := qmgo.M{ + "_id": qmgo.M{ + "$in": ids, + }, + "del_flag": 0, + } + err := col.Find(ctx, query).All(&list) + if err == qmgo.ErrNoSuchDocuments { + err = nil + return make([]*dbstruct.ZoneMoment, 0), err + } + return list, err +} + func (m *Mongo) HeadZoneMomentByIds(ctx *gin.Context, ids []int64, opType int64) error { col := m.getColZoneMoment() query := qmgo.M{ diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 73321f50..decd3730 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -3430,6 +3430,63 @@ func (s *Service) ApiGetZoneMomentListByZid(ctx *gin.Context, req *zonemomentpro return } +func (s *Service) ApiGetZoneMomentListByIds(ctx *gin.Context, req *zonemomentproto.ApiListByIdsReq) (volist []*zonemomentproto.ApiZoneMomentVO, ec errcode.ErrCode) { + ec = errcode.ErrCodeZoneMomentSrvOk + + // 1.查询该用户解锁的空间 + zidZuMap, err := _DefaultVas.GetZoneUnlockMapByMid(ctx, req.BaseRequest.Mid) + if err != nil { + logger.Error("GetZoneUnlockMapByMid fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneSrvFail + return + } + + // 2.查询访客创建的空间 + zoneMap, err := _DefaultZone.GetZoneMapByMids(ctx, []int64{req.BaseRequest.Mid}) + if err != nil { + logger.Error("_DefaultZone GetZoneMapByMids fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneSrvFail + return + } + zones := zoneMap[req.BaseRequest.Mid] + zoneZidMap := make(map[int64]*dbstruct.Zone, 0) + for _, zone := range zones { + zoneZidMap[zone.GetId()] = zone + } + + // 3.通过ids查询得到这一轮动态基底 + list, err := _DefaultZoneMoment.GetByIds(ctx, req.Ids) + if err != nil { + logger.Error("ApiGetZoneMomentListByIds fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneMomentSrvFail + return + } + + // 4.依次验证访问人是否有资格访问该条动态 + if !IsZoneVIP(req.BaseRequest.Mid) { // 空间vip放行 + for _, zonemoment := range list { + if zoneZidMap[zonemoment.GetZid()] != nil { // 空间创建人放行 + continue + } + if zidZuMap[zonemoment.GetZid()] == nil { // 未解锁该空间则不允许该轮查询 + logger.Error("Visitor has not unlocked this zone, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeUnlockedZone + return + } + } + } + + // 5.初始化返回的volist,获取mids,并将动态基底填充进去 + volist, err = s.utilFillZoneMomentsWithApiVOInfo(ctx, list, req.BaseRequest.Mid, zidZuMap) + if err != nil { + logger.Error("utilFillZoneMomentsWithApiVOInfo fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneMomentSrvFail + return + } + + return +} + func (s *Service) ApiGetZoneMomentListByCreaterMid(ctx *gin.Context, req *zonemomentproto.ApiListByCreaterMidReq) (volist []*zonemomentproto.ApiZoneMomentVO, ec errcode.ErrCode) { ec = errcode.ErrCodeZoneMomentSrvOk diff --git a/app/mix/service/logic/zonemoment.go b/app/mix/service/logic/zonemoment.go index 9810ef7c..0f4a3d40 100644 --- a/app/mix/service/logic/zonemoment.go +++ b/app/mix/service/logic/zonemoment.go @@ -198,3 +198,12 @@ func (p *ZoneMoment) GetZoneMomentStatInfoList(ctx *gin.Context, st, et int64) ( return list, nil } + +func (p *ZoneMoment) GetByIds(ctx *gin.Context, ids []int64) ([]*dbstruct.ZoneMoment, error) { + list, err := p.store.GetZoneMomentListByIds(ctx, ids) + if err != nil { + logger.Error("GetZoneMomentListByIds fail, err: %v", err) + return nil, err + } + return list, err +}