dev-feat-IRONFANS-70-Robin #350

Merged
chenhao merged 2 commits from dev-feat-IRONFANS-70-Robin into feat-IRONFANS-70 2024-04-26 11:22:33 +08:00
4 changed files with 27 additions and 11 deletions
Showing only changes of commit 3076813dfb - Show all commits

View File

@ -4714,16 +4714,13 @@ func (m *Mongo) GetZoneMomentCreateTimes(ctx *gin.Context, mid int64) (momentCre
return momentCreateTimes, err
}
func (m *Mongo) GetAndUpdateZoneMomentCreateTimes(ctx *gin.Context, mid int64, cType int64) (momentCreateTimes *dbstruct.ZoneMomentCreateTimes, err error) {
func (m *Mongo) GetAndUpdateZoneMomentCreateTimes(ctx *gin.Context, mid, totalIncr, freeIncr, paidIncr int64) (momentCreateTimes *dbstruct.ZoneMomentCreateTimes, err error) {
col := m.getColZoneMomentCreateTimes()
incClause := qmgo.M{
"create_times": 1,
}
if cType == consts.ZoneMomentCType_Free {
incClause["free_create_times"] = 1
} else if cType == consts.ZoneMomentCType_Paid {
incClause["paid_create_times"] = 1
"create_times": totalIncr,
"free_create_times": freeIncr,
"paid_create_times": paidIncr,
}
change := qmgo.Change{

View File

@ -2618,6 +2618,18 @@ func (s *Service) ApiDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.Api
}
}
// 回退每日发帖次数
totalIncr, freeIncr, paidIncr := int64(-1), int64(0), int64(0)
if zonemoment.GetCType() == consts.ZoneMomentCType_Free {
freeIncr = -1
} else if zonemoment.GetCType() == consts.ZoneMomentCType_Paid {
paidIncr = -1
}
_, err = _DefaultZoneMomentCreateTimes.OpGetAndUpdate(ctx, zone.GetMid(), totalIncr, freeIncr, paidIncr)
logger.Error("OpGetAndUpdate fail, err: %v", err)
ec = errcode.ErrCodeZoneMomentSrvFail
return
return
}

View File

@ -460,7 +460,7 @@ func (l *AuthBusinessValidator) EnsureSuchAccountPunishmentNotExist(uid int64, t
return l
}
func (l *AuthBusinessValidator) EnsureZoneMomentCreateTimesNotReachedDailyUpperbound(fun func(*gin.Context, int64, int64) (*dbstruct.ZoneMomentCreateTimes, error), mid int64, cType int64) *AuthBusinessValidator {
func (l *AuthBusinessValidator) EnsureZoneMomentCreateTimesNotReachedDailyUpperbound(fun func(*gin.Context, int64, int64, int64, int64) (*dbstruct.ZoneMomentCreateTimes, error), mid int64, cType int64) *AuthBusinessValidator {
l.oplist = append(l.oplist, func() {
// 读取每日发送上限
@ -471,7 +471,14 @@ func (l *AuthBusinessValidator) EnsureZoneMomentCreateTimesNotReachedDailyUpperb
return
}
zoneMomentCreateTimes, err := fun(l.ctx, mid, cType)
totalIncr, freeIncr, paidIncr := int64(1), int64(0), int64(0)
if cType == consts.ZoneMomentCType_Free {
freeIncr = 1
} else if cType == consts.ZoneMomentCType_Paid {
paidIncr = 1
}
zoneMomentCreateTimes, err := fun(l.ctx, mid, totalIncr, freeIncr, paidIncr)
if err != nil {
l.ec = errcode.ErrCodeZoneMomentCreateTimesSrvFail
return

View File

@ -30,9 +30,9 @@ func (p *ZoneMomentCreateTimes) OpGetOne(ctx *gin.Context, mid int64) (*dbstruct
return zoneMomentCreateTimes, nil
}
func (p *ZoneMomentCreateTimes) OpGetAndUpdate(ctx *gin.Context, mid int64, cType int64) (*dbstruct.ZoneMomentCreateTimes, error) {
func (p *ZoneMomentCreateTimes) OpGetAndUpdate(ctx *gin.Context, mid, totalIncr, freeIncr, paidIncr int64) (*dbstruct.ZoneMomentCreateTimes, error) {
zoneMomentCreateTimes, err := p.store.GetAndUpdateZoneMomentCreateTimes(ctx, mid, cType)
zoneMomentCreateTimes, err := p.store.GetAndUpdateZoneMomentCreateTimes(ctx, mid, totalIncr, freeIncr, paidIncr)
if err != nil {
logger.Error("GetAndUpdateZoneMomentCreateTimes fail, err: %v", err)
return nil, err