by Robin at 20240222; fix

This commit is contained in:
Leufolium 2024-02-22 14:36:28 +08:00
parent 59f206a612
commit 967d383b46
1 changed files with 14 additions and 10 deletions

View File

@ -1186,6 +1186,10 @@ func (m *Mongo) GetMomentListByMid(ctx *gin.Context, req *momentproto.OpListByMi
list := make([]*dbstruct.Moment, 0)
col := m.getColMoment()
//ct_lower_bound < ct <= ct_upper_bound
query := qmgo.M{
"mid": util.DerefInt64(req.Mid),
"del_flag": 0,
}
ctClause := qmgo.M{}
if req.CtLowerBound != nil {
ctClause["$gt"] = util.DerefInt64(req.CtLowerBound)
@ -1193,10 +1197,8 @@ func (m *Mongo) GetMomentListByMid(ctx *gin.Context, req *momentproto.OpListByMi
if req.CtUpperBound != nil {
ctClause["$lte"] = util.DerefInt64(req.CtUpperBound)
}
query := qmgo.M{
"mid": util.DerefInt64(req.Mid),
"ct": ctClause,
"del_flag": 0,
if len(ctClause) != 0 {
query["ct"] = ctClause
}
err := col.Find(ctx, query).Sort("-ct").Skip(int64(req.Offset)).Limit(int64(req.Limit)).All(&list)
if err == qmgo.ErrNoSuchDocuments {
@ -1210,6 +1212,12 @@ func (m *Mongo) GetMomentListByMids(ctx *gin.Context, req *momentproto.OpListByM
list := make([]*dbstruct.Moment, 0)
col := m.getColMoment()
//ct_lower_bound < ct <= ct_upper_bound
query := qmgo.M{
"mid": bson.M{
"$in": req.Mids,
},
"del_flag": 0,
}
ctClause := qmgo.M{}
if req.CtLowerBound != nil {
ctClause["$gt"] = util.DerefInt64(req.CtLowerBound)
@ -1217,12 +1225,8 @@ func (m *Mongo) GetMomentListByMids(ctx *gin.Context, req *momentproto.OpListByM
if req.CtUpperBound != nil {
ctClause["$lte"] = util.DerefInt64(req.CtUpperBound)
}
query := qmgo.M{
"mid": bson.M{
"$in": req.Mids,
},
"ct": ctClause,
"del_flag": 0,
if len(ctClause) != 0 {
query["ct"] = ctClause
}
err := col.Find(ctx, query).Sort("-ct").Skip(int64(req.Offset)).Limit(int64(req.Limit)).All(&list)
if err == qmgo.ErrNoSuchDocuments {