From acfe24623fe0b03471074e5dd3db169e7ae44932 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Thu, 11 Apr 2024 18:33:38 +0800 Subject: [PATCH] by Robin at 20240411 --- api/consts/option.go | 1 + app/mix/dao/mongo.go | 10 ++++++---- app/mix/service/apiservice_business_validation.go | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/api/consts/option.go b/api/consts/option.go index 3fa176bc..89eee587 100644 --- a/api/consts/option.go +++ b/api/consts/option.go @@ -16,6 +16,7 @@ const ( AccountPunishment_BlockFromCreatingMoment = 0 // 禁止发贴 AccountPunishment_BlockFromCreatingFreeZoneMoment = 1 // 禁止发免费空间贴 AccountPunishment_BlockFromCreatingPaidZoneMoment = 2 // 禁止发付费空间贴 + AccountPunishment_BlockFromCreatingZoneMoment = 3 // 禁止发空间贴 ) const ( diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index d5d7a85b..d25b63ae 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -4082,16 +4082,18 @@ func (m *Mongo) GetZoneMomentListByZid(ctx *gin.Context, req *zonemomentproto.Op } orClause := make([]qmgo.M, 0) - orClause = append(orClause, qmgo.M{ - "is_headed": consts.IsHeaded_Yes, - }) if len(ctClause) != 0 { + orClause = append(orClause, qmgo.M{ + "is_headed": consts.IsHeaded_Yes, + }) orClause = append(orClause, qmgo.M{ "ct": ctClause, }) } + if len(orClause) != 0 { + query["$or"] = orClause + } - query["$or"] = orClause err := col.Find(ctx, query).Sort("-is_headed", "-ct").Skip(int64(req.Offset)).Limit(int64(req.Limit)).All(&list) if err == qmgo.ErrNoSuchDocuments { err = nil diff --git a/app/mix/service/apiservice_business_validation.go b/app/mix/service/apiservice_business_validation.go index 25e21d54..006e588d 100644 --- a/app/mix/service/apiservice_business_validation.go +++ b/app/mix/service/apiservice_business_validation.go @@ -560,6 +560,7 @@ func (s *Service) ApiCreateZoneMomentBusinessValidate(ctx *gin.Context, req *zon QueryAccount(_DefaultAccount.OpListByMid). EnsureAccountExist(). EnsureIsThisRole(consts.Streamer). + EnsureSuchAccountPunishmentNotExist(req.GetBaseRequest().Mid, consts.AccountPunishment_BlockFromCreatingZoneMoment, _DefaultAccountPunishment.OpListByMidAndType). EnsureSuchAccountPunishmentNotExist(req.GetBaseRequest().Mid, pType, _DefaultAccountPunishment.OpListByMidAndType). EnsureAmongZoneMomentsPaidItemsLessThanFreeItems(_DefaultZoneMoment.OpCountByMidAndCType, req.GetBaseRequest().Mid, util.DerefInt64(req.CType)). Validate().