diff --git a/api/proto/zone_collaborator/proto/not_null_def_api.go b/api/proto/zone_collaborator/proto/not_null_def_api.go index 95e5248a..862709af 100644 --- a/api/proto/zone_collaborator/proto/not_null_def_api.go +++ b/api/proto/zone_collaborator/proto/not_null_def_api.go @@ -5,7 +5,7 @@ import ( ) func (p *ApiCreateReq) ProvideNotNullValue() (params []*validator.JsonParam) { - params = make([]*validator.JsonParam, 3) + params = make([]*validator.JsonParam, 0) params = append(params, validator.NewInt64PtrParam("请填写空间id!", p.ZoneCollaborator.Zid)) params = append(params, validator.NewInt64PtrParam("请填写协作者用户id!", p.ZoneCollaborator.CollaboratorMid)) @@ -14,21 +14,21 @@ func (p *ApiCreateReq) ProvideNotNullValue() (params []*validator.JsonParam) { } func (p *ApiUpdateReq) ProvideNotNullValue() (params []*validator.JsonParam) { - params = make([]*validator.JsonParam, 3) + params = make([]*validator.JsonParam, 0) params = append(params, validator.NewInt64PtrParam("请填写协作者表id!", p.ZoneCollaborator.Id)) return } func (p *ApiDeleteReq) ProvideNotNullValue() (params []*validator.JsonParam) { - params = make([]*validator.JsonParam, 3) + params = make([]*validator.JsonParam, 0) params = append(params, validator.NewInt64PtrParam("请填写协作者表id!", p.Id)) return } func (p *ApiListReq) ProvideNotNullValue() (params []*validator.JsonParam) { - params = make([]*validator.JsonParam, 3) + params = make([]*validator.JsonParam, 0) params = append(params, validator.NewInt64PtrParam("请填写空间id!", p.Zid)) return diff --git a/api/proto/zone_third_partner/proto/not_null_def_api.go b/api/proto/zone_third_partner/proto/not_null_def_api.go index 4722ff48..41aab21a 100644 --- a/api/proto/zone_third_partner/proto/not_null_def_api.go +++ b/api/proto/zone_third_partner/proto/not_null_def_api.go @@ -5,7 +5,7 @@ import ( ) func (p *ApiCreateReq) ProvideNotNullValue() (params []*validator.JsonParam) { - params = make([]*validator.JsonParam, 3) + params = make([]*validator.JsonParam, 0) params = append(params, validator.NewStringParam("请填写您的手机号!", p.MobilePhone)) params = append(params, validator.NewStringParam("请确认用户的国家区号!", p.RegionCode)) @@ -17,7 +17,7 @@ func (p *ApiCreateReq) ProvideNotNullValue() (params []*validator.JsonParam) { } func (p *ApiListReq) ProvideNotNullValue() (params []*validator.JsonParam) { - params = make([]*validator.JsonParam, 3) + params = make([]*validator.JsonParam, 0) params = append(params, validator.NewInt64PtrParam("请填写空间id!", p.Zid)) return diff --git a/api/proto/zonemoment/proto/not_null_def_api.go b/api/proto/zonemoment/proto/not_null_def_api.go index b6ab489a..8e395a4d 100644 --- a/api/proto/zonemoment/proto/not_null_def_api.go +++ b/api/proto/zonemoment/proto/not_null_def_api.go @@ -30,6 +30,29 @@ func (p *ApiCreateReq) ProvideNotNullValue() (params []*validator.JsonParam) { return } +func (p *ApiUpdateReq) ProvideNotNullValue() (params []*validator.JsonParam) { + params = make([]*validator.JsonParam, 0) + + params = append(params, validator.NewInt64PtrParam("请确认创建动态的可见范围!", p.ZoneMoment.CType)) + params = append(params, validator.NewInt64PtrParam("请确认创建动态的媒体类型!", p.ZoneMoment.MType)) + params = append(params, validator.NewStringPtrParam("请确认创建动态的文案!", p.Text)) + params = append(params, validator.NewStructPtrParam("请确认创建动态的媒体!", p.MediaComp)) + + switch util.DerefInt64(p.ZoneMoment.CType) { + case consts.ZoneMomentCType_Paid: + params = append(params, validator.NewInt64PtrParam("请确认创建动态的文字可见范围!", p.ZoneMoment.TextVisibleRange)) + params = append(params, validator.NewInt64PtrParam("请确认创建动态的价格!", p.ZoneMoment.Price)) + switch util.DerefInt64(p.ZoneMoment.MType) { + case consts.MediaTypeImg: + params = append(params, validator.NewInt64PtrParam("请确认创建动态的媒体可见范围!", p.ZoneMoment.MediaVisibleRange)) + case consts.MediaTypeVideo: + params = append(params, validator.NewInt64PtrParam("请确认创建动态是否要模糊封面!", p.ZoneMoment.IsBlurringCover)) + } + + } + return +} + func (p *ApiDeleteReq) ProvideNotNullValue() (params []*validator.JsonParam) { params = make([]*validator.JsonParam, 0) @@ -53,9 +76,5 @@ func (p *ApiListByZidReq) ProvideNotNullValue() (params []*validator.JsonParam) params = append(params, validator.NewInt64PtrParam("请确认创建动态的所属空间id!", p.Zid)) //params = append(params, validator.NewInt64PtrParam("请确认创建动态的媒体类型!", p.MType)) - switch util.DerefInt64(p.CType) { - case consts.ZoneMomentCType_Paid: - params = append(params, validator.NewInt64PtrParam("请确认是否铁粉可见!", p.IsIronfanVisible)) - } return } diff --git a/api/proto/zonemoment/proto/zonemoment_api.go b/api/proto/zonemoment/proto/zonemoment_api.go index 86f2222b..7708341d 100644 --- a/api/proto/zonemoment/proto/zonemoment_api.go +++ b/api/proto/zonemoment/proto/zonemoment_api.go @@ -101,6 +101,7 @@ type ApiListByZidReq struct { CtLowerBound *int64 `json:"ct_lower_bound"` // 创建时间下界,开区间,可为0 Offset int `json:"offset"` Limit int `json:"limit"` + Status *int64 } type ApiListByZidData struct { diff --git a/api/proto/zonemoment/proto/zonemoment_op.go b/api/proto/zonemoment/proto/zonemoment_op.go index d219a470..c4f30bfb 100644 --- a/api/proto/zonemoment/proto/zonemoment_op.go +++ b/api/proto/zonemoment/proto/zonemoment_op.go @@ -125,6 +125,7 @@ type OpListByZidReq struct { CtLowerBound *int64 `json:"ct_lower_bound"` // 创建时间下界,开区间,可为0 Offset int `json:"offset"` Limit int `json:"limit"` + Status *int64 } type OpListByZidData struct { diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index cdc51b5c..00524196 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -3933,7 +3933,6 @@ func (m *Mongo) GetZoneMomentListByZid(ctx *gin.Context, req *zonemomentproto.Op col := m.getColZoneMoment() query := qmgo.M{ "zid": util.DerefInt64(req.Zid), - "status": consts.ZoneMoment_Public, "del_flag": 0, } if req.MType != nil { @@ -3945,6 +3944,9 @@ func (m *Mongo) GetZoneMomentListByZid(ctx *gin.Context, req *zonemomentproto.Op if req.IsIronfanVisible != nil { query["is_ironfan_visible"] = util.DerefInt64(req.IsIronfanVisible) } + if req.Status != nil { + query["status"] = util.DerefInt64(req.Status) + } ctClause := qmgo.M{} if req.CtLowerBound != nil { ctClause["$gt"] = util.DerefInt64(req.CtLowerBound) @@ -4495,7 +4497,7 @@ func (m *Mongo) GetZoneThirdPartnerList(ctx *gin.Context, req *zone_third_partne err := col.Find(ctx, query).One(&zoneThirdPartner) if err == qmgo.ErrNoSuchDocuments { err = nil - return zoneThirdPartner, err + return nil, err } return zoneThirdPartner, err } diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index dd37772e..18e074b3 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -2466,7 +2466,23 @@ func (s *Service) ApiGetZoneMomentListByVisitorMid(ctx *gin.Context, req *zonemo func (s *Service) ApiGetZoneMomentListByZid(ctx *gin.Context, req *zonemomentproto.ApiListByZidReq) (volist []*zonemomentproto.ApiZoneMomentVO, ec errcode.ErrCode) { ec = errcode.ErrCodeZoneMomentSrvOk - // 1.根据关注的zids查询得到这一轮的动态基底 + // 1.查询访客是否是空间创建者,不是创建者,则只查询公开动态 + 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[util.DerefInt64(zone.Id)] = zone + } + if zoneZidMap[util.DerefInt64(req.Zid)] == nil { + req.Status = goproto.Int64(consts.ZoneMoment_Public) + } + + // 2.根据关注的zids查询得到这一轮的动态基底 list, err := _DefaultZoneMoment.OpListByZid(ctx, &zonemomentproto.OpListByZidReq{ Zid: req.Zid, MType: req.MType, @@ -2476,6 +2492,7 @@ func (s *Service) ApiGetZoneMomentListByZid(ctx *gin.Context, req *zonemomentpro CtLowerBound: req.CtLowerBound, Offset: req.Offset, Limit: req.Limit, + Status: req.Status, }) if err != nil { logger.Error("ApiGetZoneMomentListByZid fail, req: %v, err: %v", util.ToJson(req), err) @@ -2576,6 +2593,7 @@ func (s *Service) ApiGetZoneMomentListByCreaterMid(ctx *gin.Context, req *zonemo } streamerExt := streamerExtMap[req.GetBaseRequest().Mid] + volist = make([]*zonemomentproto.ApiZoneMomentVO, 0) // 3.填充所有信息 for _, zonemoment := range list { vo := &zonemomentproto.ApiZoneMomentVO{ @@ -2719,6 +2737,9 @@ func (s *Service) ApiGetZoneThirdPartnerList(ctx *gin.Context, req *zone_third_p ec = errcode.ErrCodeZoneThirdPartnerSrvFail return } + if zoneThirdPartner == nil { + return &zone_third_partner_proto.ZoneThirdPartnerApiVO{}, errcode.ErrCodeZoneThirdPartnerNotExist + } account, err := _DefaultAccount.OpListByMid(ctx, &accountproto.OpListByMidReq{ Mid: zoneThirdPartner.ThirdPartnerMid, @@ -2799,6 +2820,9 @@ func (s *Service) ApiGetZoneCollaboratorList(ctx *gin.Context, req *zone_collabo ec = errcode.ErrCodeZoneCollaboratorSrvFail return } + if len(list) == 0 { + return make([]*zone_collaborator_proto.ZoneCollaboratorApiVO, 0), errcode.ErrCodeZoneCollaboratorNotExist + } midSet := make(map[int64]*dbstruct.Moment) mids := make([]int64, 0) diff --git a/app/mix/service/logic/account.go b/app/mix/service/logic/account.go index 37d98adf..57227006 100644 --- a/app/mix/service/logic/account.go +++ b/app/mix/service/logic/account.go @@ -115,7 +115,9 @@ func (p *Account) GetAccountMapByMids(ctx *gin.Context, mids []int64) (map[int64 logger.Error("GetAccountListByMid fail, err: %v", err) return make(map[int64]*dbstruct.Account), err } - list = append(list, account) + if account != nil { + list = append(list, account) + } } else { accounts, err := p.store.GetAccountListByMids(ctx, &accountproto.OpListByMidsReq{ Mids: mids, diff --git a/app/mix/service/logic/streamer.go b/app/mix/service/logic/streamer.go index 1b8d4fe9..b58107c4 100644 --- a/app/mix/service/logic/streamer.go +++ b/app/mix/service/logic/streamer.go @@ -93,7 +93,9 @@ func (p *Streamer) GetStreamerMapByMids(ctx *gin.Context, mids []int64) (map[int logger.Error("GetStreamerListByMids fail, err: %v", err) return make(map[int64]*dbstruct.Streamer), err } - list = append(list, streamer) + if streamer != nil { + list = append(list, streamer) + } } else { streamers, err := p.store.GetStreamerListByMids(ctx, &streamerproto.OpListByMidsReq{ Mids: mids, diff --git a/app/mix/service/logic/zone.go b/app/mix/service/logic/zone.go index 2d334b9b..bd81d63f 100644 --- a/app/mix/service/logic/zone.go +++ b/app/mix/service/logic/zone.go @@ -120,7 +120,7 @@ func (p *Zone) GetById(ctx *gin.Context, id int64) (*dbstruct.Zone, error) { func (p *Zone) GetZoneMapByMids(ctx *gin.Context, mids []int64) (map[int64][]*dbstruct.Zone, error) { _map := make(map[int64][]*dbstruct.Zone) list := make([]*dbstruct.Zone, 0) - if len(mids) == 0 { + if len(mids) == 1 { zones, err := p.store.GetZoneListByMid(ctx, &zoneproto.OpListByMidReq{ Uid: goproto.Int64(mids[0]), }) diff --git a/app/mix/service/utilservice.go b/app/mix/service/utilservice.go index d59b166f..c6cc6746 100644 --- a/app/mix/service/utilservice.go +++ b/app/mix/service/utilservice.go @@ -1493,7 +1493,7 @@ func (s *Service) utilFillZonesWithApiVOInfo(ctx *gin.Context, list []*dbstruct. // 填充访客身份 vo.VisitorRole = consts.Zone_Visitor - if zoneZidMap[visitorMid] != nil { + if zoneZidMap[util.DerefInt64(vo.Zone.Id)] != nil { vo.VisitorRole = consts.Zone_Creater } else if tpZoneMap[visitorMid] != nil { vo.VisitorRole = consts.Zone_ThridPartner