by RObin at

This commit is contained in:
Leufolium 2024-05-01 04:01:58 +08:00
parent 74e6f9a9f5
commit 138a8da41d
2 changed files with 32 additions and 32 deletions

View File

@ -2653,6 +2653,26 @@ func (s *Service) ApiDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.Api
return return
} }
// 回退空间内统计总数,只回退公开的情况
if zonemoment.GetStatus() == consts.ZoneMoment_Public {
mediaCountInc := len(zonemoment.MediaComp.GetImageIds())
videoCountInc := len(zonemoment.MediaComp.GetVideoIds())
err = _DefaultZone.RecordStatisticsById(ctx, zonemoment.GetZid(), -1, -int64(mediaCountInc), -int64(videoCountInc))
if err != nil {
logger.Error("RecordStatisticsById fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeZoneSrvFail
return
}
}
// 回退每日发帖次数
totalIncr := int64(-1)
_, err = _DefaultZoneMomentCreateTimes.OpGetAndUpdate(ctx, zone.GetMid(), totalIncr)
if err != nil {
logger.Error("OpGetAndUpdate fail, err: %v", err)
ec = errcode.ErrCodeZoneMomentSrvFail
}
// 查看空间最后更新时间是否需要回退 // 查看空间最后更新时间是否需要回退
if zonemoment.GetStatus() == consts.ZoneMoment_Public { if zonemoment.GetStatus() == consts.ZoneMoment_Public {
list, err := _DefaultZoneMoment.OpListByMid(ctx, &zonemomentproto.OpListByMidReq{ list, err := _DefaultZoneMoment.OpListByMid(ctx, &zonemomentproto.OpListByMidReq{
@ -2699,26 +2719,6 @@ func (s *Service) ApiDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.Api
} }
} }
// 回退空间内统计总数,只回退公开的情况
if zonemoment.GetStatus() == consts.ZoneMoment_Public {
mediaCountInc := len(zonemoment.MediaComp.GetImageIds())
videoCountInc := len(zonemoment.MediaComp.GetVideoIds())
err = _DefaultZone.RecordStatisticsById(ctx, zonemoment.GetZid(), -1, -int64(mediaCountInc), -int64(videoCountInc))
if err != nil {
logger.Error("RecordStatisticsById fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeZoneSrvFail
return
}
}
// 回退每日发帖次数
totalIncr := int64(-1)
_, err = _DefaultZoneMomentCreateTimes.OpGetAndUpdate(ctx, zone.GetMid(), totalIncr)
if err != nil {
logger.Error("OpGetAndUpdate fail, err: %v", err)
ec = errcode.ErrCodeZoneMomentSrvFail
}
return return
} }

View File

@ -3416,6 +3416,18 @@ func (s *Service) OpDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.OpDe
return return
} }
// 回退空间内统计总数,只回退公开的情况
if zonemoment.GetStatus() == consts.ZoneMoment_Public {
mediaCountInc := len(zonemoment.MediaComp.GetImageIds())
videoCountInc := len(zonemoment.MediaComp.GetVideoIds())
err = _DefaultZone.RecordStatisticsById(ctx, zonemoment.GetZid(), -1, -int64(mediaCountInc), -int64(videoCountInc))
if err != nil {
logger.Error("RecordStatisticsById fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeZoneSrvFail
return
}
}
// 查看空间最后更新时间是否需要回退 // 查看空间最后更新时间是否需要回退
if zonemoment.GetStatus() == consts.ZoneMoment_Public { if zonemoment.GetStatus() == consts.ZoneMoment_Public {
list, err := _DefaultZoneMoment.OpListByMid(ctx, &zonemomentproto.OpListByMidReq{ list, err := _DefaultZoneMoment.OpListByMid(ctx, &zonemomentproto.OpListByMidReq{
@ -3462,18 +3474,6 @@ func (s *Service) OpDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.OpDe
} }
} }
// 回退空间内统计总数,只回退公开的情况
if zonemoment.GetStatus() == consts.ZoneMoment_Public {
mediaCountInc := len(zonemoment.MediaComp.GetImageIds())
videoCountInc := len(zonemoment.MediaComp.GetVideoIds())
err = _DefaultZone.RecordStatisticsById(ctx, zonemoment.GetZid(), -1, -int64(mediaCountInc), -int64(videoCountInc))
if err != nil {
logger.Error("RecordStatisticsById fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeZoneSrvFail
return
}
}
return return
} }