Merge pull request 'by Robin at 20240411' (#253) from dev-feat-IRONFANS-70-Robin into feat-IRONFANS-70

Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/253
This commit is contained in:
chenhao 2024-04-11 16:08:22 +08:00
commit 9df546d3c5
5 changed files with 10 additions and 35 deletions

View File

@ -4073,11 +4073,11 @@ func (m *Mongo) GetZoneMomentListByZid(ctx *gin.Context, req *zonemomentproto.Op
"is_headed": consts.IsHeaded_Yes, "is_headed": consts.IsHeaded_Yes,
}) })
orClause = append(orClause, qmgo.M{ orClause = append(orClause, qmgo.M{
"priority_in_zone": ctClause, "ct": ctClause,
}) })
query["$or"] = orClause 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 { if err == qmgo.ErrNoSuchDocuments {
err = nil err = nil
return list, err return list, err
@ -4211,7 +4211,7 @@ func (m *Mongo) GetZidsByZoneMomentIds(ctx *gin.Context, zonemomentIds []int64)
return zids, err 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() col := m.getColZoneMoment()
query := qmgo.M{ query := qmgo.M{
"_id": qmgo.M{ "_id": qmgo.M{
@ -4220,19 +4220,10 @@ func (m *Mongo) IncZoneMomentPriorityByIds(ctx *gin.Context, ids []int64, increm
"del_flag": 0, "del_flag": 0,
} }
up := qmgo.M{ up := qmgo.M{
"$inc": qmgo.M{ "$set": qmgo.M{
"priority_in_zone": increment, "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) _, err := col.UpdateAll(ctx, query, up)
return err return err
} }

View File

@ -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) { func (s *Service) ApiHeadZoneMoment(ctx *gin.Context, req *zonemomentproto.ApiHeadReq) (ec errcode.ErrCode) {
ec = errcode.ErrCodeZoneMomentSrvOk 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 { if err != nil {
logger.Error("_DefaultZoneMoment OpIncPriorityByIds fail, req: %v, err: %v", util.ToJson(req), err) logger.Error("_DefaultZoneMoment OpIncPriorityByIds fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeZoneMomentSrvFail ec = errcode.ErrCodeZoneMomentSrvFail

View File

@ -36,7 +36,6 @@ func (p *ZoneMoment) OpCreate(ctx *gin.Context, req *zonemomentproto.OpCreateReq
req.ZoneMoment.Ct = goproto.Int64(time.Now().Unix()) req.ZoneMoment.Ct = goproto.Int64(time.Now().Unix())
req.ZoneMoment.Ut = goproto.Int64(time.Now().Unix()) req.ZoneMoment.Ut = goproto.Int64(time.Now().Unix())
req.ZoneMoment.DelFlag = goproto.Int64(consts.Exist) req.ZoneMoment.DelFlag = goproto.Int64(consts.Exist)
req.ZoneMoment.PriorityInZone = req.ZoneMoment.Ct // 优先级默认按创建时间
req.ZoneMoment.IsHeaded = goproto.Int64(consts.IsHeaded_No) // 未置顶 req.ZoneMoment.IsHeaded = goproto.Int64(consts.IsHeaded_No) // 未置顶
err = p.store.CreateZoneMoment(ctx, req.ZoneMoment) err = p.store.CreateZoneMoment(ctx, req.ZoneMoment)
if err != nil { if err != nil {
@ -156,10 +155,10 @@ func (p *ZoneMoment) GetZidsByZoneMomentIds(ctx *gin.Context, zonemomentIds []in
return zids, err return zids, err
} }
func (p *ZoneMoment) OpIncPriorityByIds(ctx *gin.Context, ids []int64, increment int64) error { func (p *ZoneMoment) OpHeadByIds(ctx *gin.Context, ids []int64, opType int64) error {
err := p.store.IncZoneMomentPriorityByIds(ctx, ids, increment) err := p.store.HeadZoneMomentByIds(ctx, ids, opType)
if err != nil { if err != nil {
logger.Error("IncZoneMomentPriorityByIds fail, err: %v", err) logger.Error("HeadZoneMomentByIds fail, err: %v", err)
return err return err
} }
return nil return nil

View File

@ -3372,15 +3372,8 @@ func (s *Service) OpHeadZoneMoment(ctx *gin.Context, req *zonemomentproto.OpHead
return 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 { if err != nil {
logger.Error("_DefaultZoneMoment OpIncPriorityByIds fail, req: %v, err: %v", util.ToJson(req), err) logger.Error("_DefaultZoneMoment OpIncPriorityByIds fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeZoneMomentSrvFail ec = errcode.ErrCodeZoneMomentSrvFail

View File

@ -27,7 +27,6 @@ type ZoneMoment struct {
TextAuditOpinion *string `json:"text_audit_opinion" bson:"text_audit_opinion"` // 文字审核意见 TextAuditOpinion *string `json:"text_audit_opinion" bson:"text_audit_opinion"` // 文字审核意见
ManuallyReviewOpinion *string `json:"manually_review_opinion" bson:"manually_review_opinion"` // 人工复审意见 ManuallyReviewOpinion *string `json:"manually_review_opinion" bson:"manually_review_opinion"` // 人工复审意见
ManuallyReviewOperator *int64 `json:"manually_review_operator" bson:"manually_review_operator"` // 人工复审操作人 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"` // 是否已置顶 IsHeaded *int64 `json:"is_headed" bson:"is_headed"` // 是否已置顶
Ct *int64 `json:"ct" bson:"ct"` // 创建时间 Ct *int64 `json:"ct" bson:"ct"` // 创建时间
Ut *int64 `json:"ut" bson:"ut"` // 更新时间 Ut *int64 `json:"ut" bson:"ut"` // 更新时间