feat-IRONFANS-70 #301

Merged
chenhao merged 2 commits from feat-IRONFANS-70 into test 2024-04-18 06:00:16 +08:00
5 changed files with 69 additions and 16 deletions
Showing only changes of commit 4fc3732b94 - Show all commits

View File

@ -92,8 +92,9 @@ type OpListByMidResp struct {
}
// op 按zids查询
type OpListByZidsReq struct {
type OpListByZidsOrMidReq struct {
base.BaseRequest
Uid *int64 `json:"mid"` // mid
Zids []int64 `json:"zids"` // zids
MType *int64 `json:"m_type"` // 媒体类型
CType *int64 `json:"c_type"` // 付费模式
@ -103,15 +104,15 @@ type OpListByZidsReq struct {
Limit int `json:"limit"`
}
type OpListByZidsData struct {
type OpListByZidsOrMidData struct {
List []*dbstruct.ZoneMoment `json:"list"`
Offset int `json:"offset"`
More int `json:"more"`
}
type OpListByZidsResp struct {
type OpListByZidsOrMidResp struct {
base.BaseResponse
Data *OpListByZidsData `json:"data"`
Data *OpListByZidsOrMidData `json:"data"`
}
// op 列表-zid查询

View File

@ -4057,16 +4057,31 @@ func (m *Mongo) GetZoneMomentById(ctx *gin.Context, id int64) (*dbstruct.ZoneMom
return zonemoment, err
}
func (m *Mongo) GetZoneMomentListByZids(ctx *gin.Context, req *zonemomentproto.OpListByZidsReq) ([]*dbstruct.ZoneMoment, error) {
func (m *Mongo) GetZoneMomentListByZidsOrMid(ctx *gin.Context, req *zonemomentproto.OpListByZidsOrMidReq) ([]*dbstruct.ZoneMoment, error) {
list := make([]*dbstruct.ZoneMoment, 0)
col := m.getColZoneMoment()
query := qmgo.M{
"zid": qmgo.M{
"$in": req.Zids,
},
"status": consts.ZoneMoment_Public,
"del_flag": 0,
}
if req.Uid != nil {
query["$or"] = []qmgo.M{
{
"zid": qmgo.M{
"$in": req.Zids,
},
"status": consts.ZoneMoment_Public,
},
{
"mid": util.DerefInt64(req.Uid),
},
}
} else {
query["zid"] = qmgo.M{
"$in": req.Zids,
}
query["status"] = consts.ZoneMoment_Public
}
if req.MType != nil {
query["m_type"] = util.DerefInt64(req.MType)
}

View File

@ -2269,13 +2269,27 @@ func (s *Service) ApiGetZoneListByVisitorMid(ctx *gin.Context, req *zoneproto.Ap
zids = append(zids, zidZu.GetZid())
}
// 查询已解锁的空间
list, err := _DefaultZone.OpListByZids(ctx, zids)
if err != nil {
logger.Error("OpListGetZoneList fail, req: %v, err: %v", util.ToJson(req), err)
logger.Error("GetZoneListByZids fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeZoneSrvFail
return
}
// 查询自己的空间
ownedList, err := _DefaultZone.OpListByMid(ctx, &zoneproto.OpListByMidReq{
Uid: goproto.Int64(req.BaseRequest.Mid),
})
if err != nil {
logger.Error("GetZoneListByMid fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeZoneSrvFail
return
}
if len(ownedList) > 0 {
list = append(ownedList, list...)
}
// 填充必要信息
volist, err = s.utilFillZonesWithApiVOInfo(ctx, list, req.BaseRequest.Mid, zidZuMap)
if err != nil {
@ -2583,17 +2597,33 @@ func (s *Service) ApiGetZoneMomentListByVisitorMid(ctx *gin.Context, req *zonemo
zids = append(zids, zidZu.GetZid())
}
// 2.根据关注的zids查询得到这一轮的动态基底
list, err := _DefaultZoneMoment.OpListByZids(ctx, &zonemomentproto.OpListByZidsReq{
// 2.查询该用户的角色
account, err := _DefaultAccount.OpListByMid(ctx, &accountproto.OpListByMidReq{
Mid: goproto.Int64(req.BaseRequest.Mid),
})
if err != nil {
logger.Error("_DefaultAccount OpListByMid fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeAccountSrvFail
return
}
// 3.组装查询条件如果是主播则Mid查询生效
queryReq := &zonemomentproto.OpListByZidsOrMidReq{
Zids: zids,
MType: req.MType,
CtUpperBound: req.CtUpperBound,
CtLowerBound: req.CtLowerBound,
Offset: req.Offset,
Limit: req.Limit,
})
}
if account.GetRole() == consts.Streamer {
queryReq.Uid = goproto.Int64(req.BaseRequest.Mid)
}
// 2.根据关注的zids及其mid查询得到这一轮的动态基底
list, err := _DefaultZoneMoment.OpListByZidsOrMid(ctx, queryReq)
if err != nil {
logger.Error("ApiGetZoneMomentList fail, req: %v, err: %v", util.ToJson(req), err)
logger.Error("ApiGetZoneMomentListByZidsOrMid fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeZoneMomentSrvFail
return
}

View File

@ -81,8 +81,8 @@ func (p *ZoneMoment) GetById(ctx *gin.Context, id int64) (*dbstruct.ZoneMoment,
return zonemoment, nil
}
func (p *ZoneMoment) OpListByZids(ctx *gin.Context, req *zonemomentproto.OpListByZidsReq) ([]*dbstruct.ZoneMoment, error) {
list, err := p.store.GetZoneMomentListByZids(ctx, req)
func (p *ZoneMoment) OpListByZidsOrMid(ctx *gin.Context, req *zonemomentproto.OpListByZidsOrMidReq) ([]*dbstruct.ZoneMoment, error) {
list, err := p.store.GetZoneMomentListByZidsOrMid(ctx, req)
if err != nil {
logger.Error("GetZoneMomentListByZids fail, err: %v", err)
return make([]*dbstruct.ZoneMoment, 0), err

View File

@ -31,3 +31,10 @@ type Account struct {
Ut *int64 `json:"ut" bson:"ut"` // 更新时间
DelFlag *int64 `json:"del_flag" bson:"del_flag"` // 删除标记0-否1-是
}
func (p *Account) GetRole() int64 {
if p == nil || p.Role == nil {
return -1
}
return *p.Role
}