Merge pull request 'feat-IRONFANS-70' (#301) from feat-IRONFANS-70 into test
Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/301
This commit is contained in:
commit
78e5e6a33a
|
@ -92,8 +92,9 @@ type OpListByMidResp struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// op 按zids查询
|
// op 按zids查询
|
||||||
type OpListByZidsReq struct {
|
type OpListByZidsOrMidReq struct {
|
||||||
base.BaseRequest
|
base.BaseRequest
|
||||||
|
Uid *int64 `json:"mid"` // mid
|
||||||
Zids []int64 `json:"zids"` // zids
|
Zids []int64 `json:"zids"` // zids
|
||||||
MType *int64 `json:"m_type"` // 媒体类型
|
MType *int64 `json:"m_type"` // 媒体类型
|
||||||
CType *int64 `json:"c_type"` // 付费模式
|
CType *int64 `json:"c_type"` // 付费模式
|
||||||
|
@ -103,15 +104,15 @@ type OpListByZidsReq struct {
|
||||||
Limit int `json:"limit"`
|
Limit int `json:"limit"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type OpListByZidsData struct {
|
type OpListByZidsOrMidData struct {
|
||||||
List []*dbstruct.ZoneMoment `json:"list"`
|
List []*dbstruct.ZoneMoment `json:"list"`
|
||||||
Offset int `json:"offset"`
|
Offset int `json:"offset"`
|
||||||
More int `json:"more"`
|
More int `json:"more"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type OpListByZidsResp struct {
|
type OpListByZidsOrMidResp struct {
|
||||||
base.BaseResponse
|
base.BaseResponse
|
||||||
Data *OpListByZidsData `json:"data"`
|
Data *OpListByZidsOrMidData `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// op 列表-zid查询
|
// op 列表-zid查询
|
||||||
|
|
|
@ -3945,16 +3945,31 @@ func (m *Mongo) GetZoneMomentById(ctx *gin.Context, id int64) (*dbstruct.ZoneMom
|
||||||
return zonemoment, err
|
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)
|
list := make([]*dbstruct.ZoneMoment, 0)
|
||||||
col := m.getColZoneMoment()
|
col := m.getColZoneMoment()
|
||||||
|
|
||||||
query := qmgo.M{
|
query := qmgo.M{
|
||||||
"zid": qmgo.M{
|
|
||||||
"$in": req.Zids,
|
|
||||||
},
|
|
||||||
"status": consts.ZoneMoment_Public,
|
|
||||||
"del_flag": 0,
|
"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 {
|
if req.MType != nil {
|
||||||
query["m_type"] = util.DerefInt64(req.MType)
|
query["m_type"] = util.DerefInt64(req.MType)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2269,13 +2269,27 @@ func (s *Service) ApiGetZoneListByVisitorMid(ctx *gin.Context, req *zoneproto.Ap
|
||||||
zids = append(zids, zidZu.GetZid())
|
zids = append(zids, zidZu.GetZid())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询已解锁的空间
|
||||||
list, err := _DefaultZone.OpListByZids(ctx, zids)
|
list, err := _DefaultZone.OpListByZids(ctx, zids)
|
||||||
if err != nil {
|
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
|
ec = errcode.ErrCodeZoneSrvFail
|
||||||
return
|
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)
|
volist, err = s.utilFillZonesWithApiVOInfo(ctx, list, req.BaseRequest.Mid, zidZuMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -2593,17 +2607,33 @@ func (s *Service) ApiGetZoneMomentListByVisitorMid(ctx *gin.Context, req *zonemo
|
||||||
zids = append(zids, zidZu.GetZid())
|
zids = append(zids, zidZu.GetZid())
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.根据关注的zids查询得到这一轮的动态基底
|
// 2.查询该用户的角色
|
||||||
list, err := _DefaultZoneMoment.OpListByZids(ctx, &zonemomentproto.OpListByZidsReq{
|
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,
|
Zids: zids,
|
||||||
MType: req.MType,
|
MType: req.MType,
|
||||||
CtUpperBound: req.CtUpperBound,
|
CtUpperBound: req.CtUpperBound,
|
||||||
CtLowerBound: req.CtLowerBound,
|
CtLowerBound: req.CtLowerBound,
|
||||||
Offset: req.Offset,
|
Offset: req.Offset,
|
||||||
Limit: req.Limit,
|
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 {
|
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
|
ec = errcode.ErrCodeZoneMomentSrvFail
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,8 +81,8 @@ func (p *ZoneMoment) GetById(ctx *gin.Context, id int64) (*dbstruct.ZoneMoment,
|
||||||
return zonemoment, nil
|
return zonemoment, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ZoneMoment) OpListByZids(ctx *gin.Context, req *zonemomentproto.OpListByZidsReq) ([]*dbstruct.ZoneMoment, error) {
|
func (p *ZoneMoment) OpListByZidsOrMid(ctx *gin.Context, req *zonemomentproto.OpListByZidsOrMidReq) ([]*dbstruct.ZoneMoment, error) {
|
||||||
list, err := p.store.GetZoneMomentListByZids(ctx, req)
|
list, err := p.store.GetZoneMomentListByZidsOrMid(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("GetZoneMomentListByZids fail, err: %v", err)
|
logger.Error("GetZoneMomentListByZids fail, err: %v", err)
|
||||||
return make([]*dbstruct.ZoneMoment, 0), err
|
return make([]*dbstruct.ZoneMoment, 0), err
|
||||||
|
|
|
@ -31,3 +31,10 @@ type Account struct {
|
||||||
Ut *int64 `json:"ut" bson:"ut"` // 更新时间
|
Ut *int64 `json:"ut" bson:"ut"` // 更新时间
|
||||||
DelFlag *int64 `json:"del_flag" bson:"del_flag"` // 删除标记,0-否,1-是
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue