diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 316418e5..de3203e5 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -2517,6 +2517,8 @@ func (s *Service) ApiUpdateZoneMoment(ctx *gin.Context, req *zonemomentproto.Api return } + zmStatus := zonemoment.GetStatus() + // 抹消审核信息,回退到初始 isReauditRequired := false if req.ZoneMoment.MediaComp != nil && req.ZoneMoment.GetMType() == consts.MediaTypeImg { @@ -2556,8 +2558,8 @@ func (s *Service) ApiUpdateZoneMoment(ctx *gin.Context, req *zonemomentproto.Api return } - // 回退空间内统计总数 - if isReauditRequired { + // 回退空间内统计总数,只回退公开的情况 + if zmStatus == consts.ZoneMoment_Public && isReauditRequired { mediaCountInc := len(zonemoment.MediaComp.GetImageIds()) videoCountInc := len(zonemoment.MediaComp.GetVideoIds()) err := _DefaultZone.RecordStatisticsById(ctx, zonemoment.GetZid(), -1, -int64(mediaCountInc), -int64(videoCountInc)) @@ -2645,14 +2647,16 @@ func (s *Service) ApiDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.Api } } - // 回退空间内统计总数 - 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 { + 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 + } } // 回退每日发帖次数 diff --git a/dbstruct/zonemoment.go b/dbstruct/zonemoment.go index b2983de2..10f23bd5 100644 --- a/dbstruct/zonemoment.go +++ b/dbstruct/zonemoment.go @@ -87,3 +87,10 @@ func (p *ZoneMoment) GetUt() int64 { } return 0 } + +func (p *ZoneMoment) GetStatus() int64 { + if p != nil && p.Status != nil { + return *p.Status + } + return 0 +}