diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index f619e40d..1e7750dc 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -4073,11 +4073,11 @@ func (m *Mongo) GetZoneMomentListByZid(ctx *gin.Context, req *zonemomentproto.Op "is_headed": consts.IsHeaded_Yes, }) orClause = append(orClause, qmgo.M{ - "priority_in_zone": ctClause, + "ct": ctClause, }) query["$or"] = orClause - err := col.Find(ctx, query).Sort("-priority_in_zone").Skip(int64(req.Offset)).Limit(int64(req.Limit)).All(&list) + 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 return list, err @@ -4211,7 +4211,7 @@ func (m *Mongo) GetZidsByZoneMomentIds(ctx *gin.Context, zonemomentIds []int64) return zids, err } -func (m *Mongo) IncZoneMomentPriorityByIds(ctx *gin.Context, ids []int64, increment int64) error { +func (m *Mongo) HeadZoneMomentByIds(ctx *gin.Context, ids []int64, opType int64) error { col := m.getColZoneMoment() query := qmgo.M{ "_id": qmgo.M{ @@ -4220,19 +4220,10 @@ func (m *Mongo) IncZoneMomentPriorityByIds(ctx *gin.Context, ids []int64, increm "del_flag": 0, } up := qmgo.M{ - "$inc": qmgo.M{ - "priority_in_zone": increment, + "$set": qmgo.M{ + "is_headed": opType, }, } - if increment == consts.ZoneMomentPriorityInZone_Increment { - up["$set"] = qmgo.M{ - "is_headed": int64(consts.IsHeaded_Yes), - } - } else { - up["$set"] = qmgo.M{ - "is_headed": int64(consts.IsHeaded_No), - } - } _, err := col.UpdateAll(ctx, query, up) return err } diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 16d48b3f..aae29fae 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -2637,15 +2637,8 @@ func (s *Service) ApiGetZoneMomentListByCreaterMid(ctx *gin.Context, req *zonemo func (s *Service) ApiHeadZoneMoment(ctx *gin.Context, req *zonemomentproto.ApiHeadReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeZoneMomentSrvOk - incr := int64(0) - if req.OpType == consts.ZoneMomentHead_Head { - incr = consts.ZoneMomentPriorityInZone_Increment - } else { - incr = consts.ZoneMomentPriorityInZone_Decrement - } - // 更新动态的状态 - err := _DefaultZoneMoment.OpIncPriorityByIds(ctx, req.ZoneMomentIds, incr) + err := _DefaultZoneMoment.OpHeadByIds(ctx, req.ZoneMomentIds, req.OpType) if err != nil { logger.Error("_DefaultZoneMoment OpIncPriorityByIds fail, req: %v, err: %v", util.ToJson(req), err) ec = errcode.ErrCodeZoneMomentSrvFail diff --git a/app/mix/service/logic/zonemoment.go b/app/mix/service/logic/zonemoment.go index b9d01cf6..d934def4 100644 --- a/app/mix/service/logic/zonemoment.go +++ b/app/mix/service/logic/zonemoment.go @@ -36,7 +36,6 @@ func (p *ZoneMoment) OpCreate(ctx *gin.Context, req *zonemomentproto.OpCreateReq req.ZoneMoment.Ct = goproto.Int64(time.Now().Unix()) req.ZoneMoment.Ut = goproto.Int64(time.Now().Unix()) req.ZoneMoment.DelFlag = goproto.Int64(consts.Exist) - req.ZoneMoment.PriorityInZone = req.ZoneMoment.Ct // 优先级默认按创建时间 req.ZoneMoment.IsHeaded = goproto.Int64(consts.IsHeaded_No) // 未置顶 err = p.store.CreateZoneMoment(ctx, req.ZoneMoment) if err != nil { @@ -156,10 +155,10 @@ func (p *ZoneMoment) GetZidsByZoneMomentIds(ctx *gin.Context, zonemomentIds []in return zids, err } -func (p *ZoneMoment) OpIncPriorityByIds(ctx *gin.Context, ids []int64, increment int64) error { - err := p.store.IncZoneMomentPriorityByIds(ctx, ids, increment) +func (p *ZoneMoment) OpHeadByIds(ctx *gin.Context, ids []int64, opType int64) error { + err := p.store.HeadZoneMomentByIds(ctx, ids, opType) if err != nil { - logger.Error("IncZoneMomentPriorityByIds fail, err: %v", err) + logger.Error("HeadZoneMomentByIds fail, err: %v", err) return err } return nil diff --git a/app/mix/service/service.go b/app/mix/service/service.go index 100082b0..f90ea171 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -3372,15 +3372,8 @@ func (s *Service) OpHeadZoneMoment(ctx *gin.Context, req *zonemomentproto.OpHead return } - incr := int64(0) - if req.OpType == consts.ZoneMomentHead_Head { - incr = consts.ZoneMomentPriorityInZone_Increment - } else { - incr = consts.ZoneMomentPriorityInZone_Decrement - } - // 更新动态的状态 - err := _DefaultZoneMoment.OpIncPriorityByIds(ctx, req.ZoneMomentIds, incr) + err := _DefaultZoneMoment.OpHeadByIds(ctx, req.ZoneMomentIds, req.OpType) if err != nil { logger.Error("_DefaultZoneMoment OpIncPriorityByIds fail, req: %v, err: %v", util.ToJson(req), err) ec = errcode.ErrCodeZoneMomentSrvFail diff --git a/dbstruct/zonemoment.go b/dbstruct/zonemoment.go index 867e3a50..f74dac2b 100644 --- a/dbstruct/zonemoment.go +++ b/dbstruct/zonemoment.go @@ -27,7 +27,6 @@ type ZoneMoment struct { TextAuditOpinion *string `json:"text_audit_opinion" bson:"text_audit_opinion"` // 文字审核意见 ManuallyReviewOpinion *string `json:"manually_review_opinion" bson:"manually_review_opinion"` // 人工复审意见 ManuallyReviewOperator *int64 `json:"manually_review_operator" bson:"manually_review_operator"` // 人工复审操作人 - PriorityInZone *int64 `json:"priority_in_zone" bson:"priority_in_zone"` // 优先级 IsHeaded *int64 `json:"is_headed" bson:"is_headed"` // 是否已置顶 Ct *int64 `json:"ct" bson:"ct"` // 创建时间 Ut *int64 `json:"ut" bson:"ut"` // 更新时间