From 0dd9eb13606ca655491fc36178b277caa610011e Mon Sep 17 00:00:00 2001 From: Leufolium Date: Thu, 11 Apr 2024 16:52:30 +0800 Subject: [PATCH] by Robin at 20240411 --- api/proto/zonemoment/proto/zonemoment_op.go | 20 +++++++++++ app/mix/dao/mongo.go | 39 +++++++++++++++++++-- 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/api/proto/zonemoment/proto/zonemoment_op.go b/api/proto/zonemoment/proto/zonemoment_op.go index 835de296..a9f062b8 100644 --- a/api/proto/zonemoment/proto/zonemoment_op.go +++ b/api/proto/zonemoment/proto/zonemoment_op.go @@ -186,3 +186,23 @@ type OpHeadResp struct { base.BaseResponse Data *OpHeadData `json:"data"` } + +// op 列表 +type OpCountByZidReq struct { + base.BaseRequest + Zid *int64 `json:"zid"` // 空间id + MType *int64 `json:"m_type"` // 媒体类型 + CType *int64 `json:"c_type"` // 付费模式 + IsIronfanVisible *int64 `json:"is_ironfan_visible"` // 是否铁粉可见 + CtUpperBound *int64 `json:"ct_upper_bound"` // 创建时间上界,闭区间 + CtLowerBound *int64 `json:"ct_lower_bound"` // 创建时间下界,开区间,可为0 + Status *int64 `json:"status"` // 状态 +} + +type OpCountByZidData struct { +} + +type OpLCountByZidResp struct { + base.BaseResponse + Data *OpListByMidData `json:"data"` +} diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 1e7750dc..2cfc6d86 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -4072,9 +4072,11 @@ func (m *Mongo) GetZoneMomentListByZid(ctx *gin.Context, req *zonemomentproto.Op orClause = append(orClause, qmgo.M{ "is_headed": consts.IsHeaded_Yes, }) - orClause = append(orClause, qmgo.M{ - "ct": ctClause, - }) + if len(ctClause) != 0 { + orClause = append(orClause, qmgo.M{ + "ct": ctClause, + }) + } query["$or"] = orClause err := col.Find(ctx, query).Sort("-is_headed", "-ct").Skip(int64(req.Offset)).Limit(int64(req.Limit)).All(&list) @@ -4119,6 +4121,37 @@ func (m *Mongo) GetZoneMomentListByMid(ctx *gin.Context, req *zonemomentproto.Op return list, err } +func (m *Mongo) GetZoneMomentCountByZid(ctx *gin.Context, req *zonemomentproto.OpCountByZidReq) (int64, error) { + col := m.getColZoneMoment() + query := qmgo.M{ + "zid": util.DerefInt64(req.Zid), + "del_flag": 0, + } + if req.MType != nil { + query["m_type"] = util.DerefInt64(req.MType) + } + if req.CType != nil { + query["c_type"] = util.DerefInt64(req.CType) + } + 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) + } + if req.CtUpperBound != nil { + ctClause["$lte"] = util.DerefInt64(req.CtUpperBound) + } + if len(ctClause) != 0 { + query["ct"] = ctClause + } + return col.Find(ctx, query).Count() +} + func (m *Mongo) ThumbsUpZoneMoment(ctx *gin.Context, req *zonemomentproto.OpZoneMomentThumbsUpReq) (err error) { col := m.getColMoment() change := qmgo.Change{