From 12549d2de55241d93b6590b4380e516d5c6aab4e Mon Sep 17 00:00:00 2001 From: Leufolium Date: Fri, 29 Mar 2024 00:16:42 +0800 Subject: [PATCH] by Robin at 20240329; alter moment audit procedure --- api/consts/option.go | 5 ++ api/consts/status.go | 17 +++- api/proto/moment/proto/moment_api.go | 1 + api/proto/moment/proto/moment_op.go | 16 ++++ app/mix/controller/init.go | 1 + app/mix/controller/moment_api.go | 1 + app/mix/controller/moment_op.go | 12 +++ app/mix/dao/mongo.go | 86 +++++++++++++++++++ app/mix/service/apiservice.go | 39 ++++----- .../service/imageaudittask_result_handler.go | 1 + app/mix/service/logic/moment.go | 19 ++++ app/mix/service/logic/moment_audit_task.go | 19 ++++ .../service/opservice_business_validation.go | 16 ++++ app/mix/service/service.go | 83 ++++++++++++++++-- .../service/textaudittask_result_handler.go | 2 +- app/mix/service/utilservice.go | 52 +++++++++++ app/mix/service/xxljob_tasks.go | 4 +- dbstruct/moment_audit_task.go | 2 + 18 files changed, 340 insertions(+), 36 deletions(-) diff --git a/api/consts/option.go b/api/consts/option.go index 4ea98f97..059ab349 100644 --- a/api/consts/option.go +++ b/api/consts/option.go @@ -19,3 +19,8 @@ const ( Recomm_Up = 1 Recomm_Init = 2 ) + +const ( + MomentManuallyReview_Pass = 0 + MomentManuallyReview_Reject = 1 +) diff --git a/api/consts/status.go b/api/consts/status.go index 69f0fa13..65b78c80 100644 --- a/api/consts/status.go +++ b/api/consts/status.go @@ -92,9 +92,13 @@ const ( // 动态表status状态 const ( - Moment_Private = 0 //仅自己可见 - Moment_OpenToCircles = 1 //仅朋友圈可见 - Moment_Public = 2 //公开 + Moment_Private = 0 //仅自己可见 + Moment_OpenToCircles = 1 //仅朋友圈可见 + Moment_Public = 2 //公开 + Moment_Auditing = 3 //机审中 + Moment_ManuallyReviewing = 4 //人工复审中 + Moment_AuditRejected = 5 //机审拒绝 + Moment_ManuallyReviewRejected = 6 //人工复审拒绝 ) // 是否被关注 @@ -140,3 +144,10 @@ const ( AccountCancellationStatus_CancellationExecuting = 3 //注销执行中 AccountCancellationVOStatus_Normal = 2 //账户状态正常(已中止) ) + +// 动态人工复审 +const ( + MomentManuallyReview_Waiting = 0 //等待复审 + MomentManuallyReview_Passed = 1 //已复审通过 + MomentManuallyReview_Rejected = 2 //已复审拒绝 +) diff --git a/api/proto/moment/proto/moment_api.go b/api/proto/moment/proto/moment_api.go index 79fff392..fbe2a3af 100644 --- a/api/proto/moment/proto/moment_api.go +++ b/api/proto/moment/proto/moment_api.go @@ -55,6 +55,7 @@ type ApiListByMidReq struct { CtLowerBound *int64 `json:"ct_lower_bound"` //创建时间下界,开区间,可为0 Offset int `json:"offset"` Limit int `json:"limit"` + Status *int64 } type ApiListByMidData struct { diff --git a/api/proto/moment/proto/moment_op.go b/api/proto/moment/proto/moment_op.go index 1c256f28..b7fe68fa 100644 --- a/api/proto/moment/proto/moment_op.go +++ b/api/proto/moment/proto/moment_op.go @@ -75,6 +75,7 @@ type OpListByMidReq struct { CtLowerBound *int64 `json:"ct_lower_bound"` //创建时间下界,开区间,可为0 Offset int `json:"offset"` Limit int `json:"limit"` + Status *int64 } type OpListByMidData struct { @@ -140,3 +141,18 @@ type OpListByIdsResp struct { base.BaseResponse Data *OpListByIdsData `json:"data"` } + +// op 复审 +type OpReviewReq struct { + base.BaseRequest + MomentIds []int64 `json:"moment_ids"` + OpType int64 `json:"op_type"` +} + +type OpReviewData struct { +} + +type OpReviewResp struct { + base.BaseResponse + Data *OpReviewData `json:"data"` +} diff --git a/app/mix/controller/init.go b/app/mix/controller/init.go index 353cd509..4de835cf 100644 --- a/app/mix/controller/init.go +++ b/app/mix/controller/init.go @@ -282,6 +282,7 @@ func Init(r *gin.Engine) { opMomentGroup.POST("list_by_mid", middleware.JSONParamValidator(momentproto.OpListByMidReq{}), middleware.JwtAuthenticator(), OpGetMomentListByMid) opMomentGroup.POST("thumbs_up", middleware.JSONParamValidator(momentproto.OpThumbsUpReq{}), middleware.JwtAuthenticator(), OpThumbsUpMoment) opMomentGroup.POST("list_by_ids", middleware.JSONParamValidator(momentproto.OpListByIdsReq{}), middleware.JwtAuthenticator(), OpGetMomentListByIds) + opMomentGroup.POST("review", middleware.JSONParamValidator(momentproto.OpReviewReq{}), middleware.JwtAuthenticator(), OpReviewMoment) // 足迹 opFootPrintGroup := r.Group("/op/footprint", PrepareOp()) diff --git a/app/mix/controller/moment_api.go b/app/mix/controller/moment_api.go index 4b2159cb..f914c95a 100644 --- a/app/mix/controller/moment_api.go +++ b/app/mix/controller/moment_api.go @@ -87,6 +87,7 @@ func ApiGetMomentList(ctx *gin.Context) { ReplyOk(ctx, data) } +// 查私有动态接口 func ApiGetMomentListByMid(ctx *gin.Context) { req := ctx.MustGet("client_req").(*momentproto.ApiListByMidReq) diff --git a/app/mix/controller/moment_op.go b/app/mix/controller/moment_op.go index af54a6f8..271e04d3 100644 --- a/app/mix/controller/moment_op.go +++ b/app/mix/controller/moment_op.go @@ -183,3 +183,15 @@ func OpThumbsUpMoment(ctx *gin.Context) { ReplyOk(ctx, nil) } + +func OpReviewMoment(ctx *gin.Context) { + req := ctx.MustGet("client_req").(*momentproto.OpReviewReq) + ec := service.DefaultService.OpReviewMoment(ctx, req) + if ec != errcode.ErrCodeMomentSrvOk { + logger.Error("OpReviewMoment fail, req: %v, ec: %v", util.ToJson(req), ec) + ReplyErrCodeMsg(ctx, ec) + return + } + + ReplyOk(ctx, nil) +} diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 45f85950..59b126f0 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -1375,6 +1375,7 @@ func (m *Mongo) GetMomentList(ctx *gin.Context, req *momentproto.OpListReq) ([]* } query := qmgo.M{ "ct": ctClause, + "status": consts.Moment_Public, "del_flag": 0, } err := col.Find(ctx, query).Sort("-ct").Skip(int64(req.Offset)).Limit(int64(req.Limit)).All(&list) @@ -1417,6 +1418,7 @@ func (m *Mongo) GetMomentListByIds(ctx *gin.Context, req *momentproto.OpListById "_id": qmgo.M{ "$in": req.Ids, }, + "status": consts.Moment_Public, "del_flag": 0, } err := col.Find(ctx, query).Sort("_id").All(&list) @@ -1427,6 +1429,7 @@ func (m *Mongo) GetMomentListByIds(ctx *gin.Context, req *momentproto.OpListById return list, err } +// 查私有动态接口 func (m *Mongo) GetMomentListByMid(ctx *gin.Context, req *momentproto.OpListByMidReq) ([]*dbstruct.Moment, error) { list := make([]*dbstruct.Moment, 0) col := m.getColMoment() @@ -1435,6 +1438,9 @@ func (m *Mongo) GetMomentListByMid(ctx *gin.Context, req *momentproto.OpListByMi "mid": util.DerefInt64(req.Mid), "del_flag": 0, } + if req.Status != nil { + query["status"] = util.DerefInt64(req.Status) + } ctClause := qmgo.M{} if req.CtLowerBound != nil { ctClause["$gt"] = util.DerefInt64(req.CtLowerBound) @@ -1461,6 +1467,7 @@ func (m *Mongo) GetMomentListByMids(ctx *gin.Context, req *momentproto.OpListByM "mid": bson.M{ "$in": req.Mids, }, + "status": consts.Moment_Public, "del_flag": 0, } ctClause := qmgo.M{} @@ -1496,6 +1503,39 @@ func (m *Mongo) ThumbsUpMoment(ctx *gin.Context, req *momentproto.OpThumbsUpReq) return err } +func (m *Mongo) UpdateMomentByIds(ctx *gin.Context, moment *dbstruct.Moment, ids []int64) error { + col := m.getColMoment() + set := util.EntityToM(moment) + set["ut"] = time.Now().Unix() + up := qmgo.M{ + "$set": set, + } + filter := qmgo.M{ + "_id": qmgo.M{ + "$in": ids, + }, + } + _, err := col.UpdateAll(ctx, filter, up) + return err +} + +func (m *Mongo) UpdateMomentByIdsAndStatus(ctx *gin.Context, moment *dbstruct.Moment, ids []int64, status int64) error { + col := m.getColMoment() + set := util.EntityToM(moment) + set["ut"] = time.Now().Unix() + up := qmgo.M{ + "$set": set, + } + filter := qmgo.M{ + "_id": qmgo.M{ + "$in": ids, + }, + "status": status, + } + _, err := col.UpdateAll(ctx, filter, up) + return err +} + // 动态创建频次 func (m *Mongo) GetAndUpdateMomentCreateTimes(ctx *gin.Context, mid int64) (momentCreateTimes *dbstruct.MomentCreateTimes, err error) { col := m.getColMomentCreateTimes() @@ -3224,6 +3264,35 @@ func (m *Mongo) GetMomentAuditTaskList(ctx *gin.Context, req *moment_audit_taskp return list, err } +func (m *Mongo) GetMomentAuditTaskListWaitingForManuallyReview(ctx *gin.Context, batchId string) ([]*dbstruct.MomentAuditTask, error) { + list := make([]*dbstruct.MomentAuditTask, 0) + col := m.getColMomentAuditTask() + query := qmgo.M{ + "batch_id": batchId, + "del_flag": 0, + } + // 组装查询条件,查询状态均为机审通过,或其中有一个为机审失败的审核任务 + passedFilter := qmgo.M{ + "image_audit_task_status": consts.MomentAudit_Passed, + "text_audit_task_status": consts.MomentAudit_Passed, + } + svcFailedFilter := qmgo.M{ + "$or": []qmgo.M{ + {"image_audit_task_status": consts.MomentAudit_ServiceFailed}, + {"text_audit_task_status": consts.MomentAudit_ServiceFailed}, + }, + } + query["$or"] = []qmgo.M{ + passedFilter, svcFailedFilter, + } + err := col.Find(ctx, query).All(&list) + if err == qmgo.ErrNoSuchDocuments { + err = nil + return list, err + } + return list, err +} + func (m *Mongo) UpdateMomentAuditTaskByImageAuditTaskIds(ctx *gin.Context, moment_audit_task *dbstruct.MomentAuditTask, ids []string) error { col := m.getColMomentAuditTask() set := util.EntityToM(moment_audit_task) @@ -3256,6 +3325,23 @@ func (m *Mongo) UpdateMomentAuditTaskByTextAuditTaskIds(ctx *gin.Context, moment return err } +func (m *Mongo) UpdateMomentAuditTaskByMomentIdsAndStatus(ctx *gin.Context, moment_audit_task *dbstruct.MomentAuditTask, momentIds []int64, status int64) error { + col := m.getColMomentAuditTask() + set := util.EntityToM(moment_audit_task) + set["ut"] = time.Now().Unix() + up := qmgo.M{ + "$set": set, + } + filter := qmgo.M{ + "associative_table_id": qmgo.M{ + "$in": momentIds, + }, + "status": status, + } + _, err := col.UpdateAll(ctx, filter, up) + return err +} + // 联系客服对话表相关 func (m *Mongo) CreateContactCustomerServiceSession(ctx *gin.Context, contact_customer_service_session *dbstruct.ContactCustomerServiceSession) error { col := m.getColContactCustomerServiceSession() diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 10bc2edd..38ba4f7d 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -33,7 +33,6 @@ import ( "service/library/contentaudit/imageaudit" "service/library/contentaudit/textaudit" "service/library/logger" - "service/library/redis" "time" "go.mongodb.org/mongo-driver/mongo" @@ -1684,21 +1683,6 @@ func (s *Service) ApiGetContactCustomerServiceSessionListByMid(ctx *gin.Context, func (s *Service) ApiCreateMoment(ctx *gin.Context, req *momentproto.ApiCreateReq) (ec errcode.ErrCode, acctPunEndTime string) { ec = errcode.ErrCodeMomentSrvOk - // 创建完动态,将动态加载到当前redis数组 - defer func() { - if req.Moment.Id == nil { - return - } - go func() { - id := util.DerefInt64(req.Moment.Id) - err := redis.GetRedisClient().RPush(consts.RedisMomentPrefix+"recent_list", id) - if err != nil { - logger.Error("Push newly-created moment to list failed : %v", err) - return - } - }() - }() - req.Moment.Mid = goproto.Int64(req.BaseRequest.Mid) var accountpunishment *dbstruct.AccountPunishment if ec, accountpunishment = s.ApiCreateMomentBusinessValidate(ctx, req); ec != errcode.ErrCodeMomentSrvOk { @@ -1716,6 +1700,7 @@ func (s *Service) ApiCreateMoment(ctx *gin.Context, req *momentproto.ApiCreateRe return } + req.Moment.Status = goproto.Int64(consts.Moment_Auditing) // 创建动态默认机审中 err := _DefaultMoment.OpCreate(ctx, &momentproto.OpCreateReq{ Moment: req.Moment, }) @@ -1745,11 +1730,11 @@ func (s *Service) ApiCreateMoment(ctx *gin.Context, req *momentproto.ApiCreateRe // 封装动态审核任务 momentAuditTask := &dbstruct.MomentAuditTask{ - AssociativeTableId: goproto.String(fmt.Sprint(util.DerefInt64(req.Moment.Id))), - //ImageAuditTaskStatus: goproto.Int64(consts.MomentAudit_Created), - //TextAuditTaskStatus: goproto.Int64(consts.MomentAudit_Created), - AuditedMedia: req.Moment.MediaComp, - AuditedText: req.Moment.Text, + AssociativeTableId: goproto.String(fmt.Sprint(util.DerefInt64(req.Moment.Id))), + AuditedMedia: req.Moment.MediaComp, + AuditedText: req.Moment.Text, + Status: goproto.Int64(consts.MomentAudit_Created), + ManuallyReviewStatus: goproto.Int64(consts.MomentManuallyReview_Waiting), } if len(imageaudittasks) > 0 { momentAuditTask.ImageAuditTaskId = imageaudittasks[0].Id @@ -1816,9 +1801,8 @@ func (s *Service) ApiUpdateMoment(ctx *gin.Context, req *momentproto.ApiUpdateRe // 封装动态审核任务 momentAuditTask := &dbstruct.MomentAuditTask{ - AssociativeTableId: goproto.String(fmt.Sprint(util.DerefInt64(req.Moment.Id))), - //ImageAuditTaskStatus: goproto.Int64(consts.MomentAudit_Created), - //TextAuditTaskStatus: goproto.Int64(consts.MomentAudit_Created), + AssociativeTableId: goproto.String(fmt.Sprint(util.DerefInt64(req.Moment.Id))), + ManuallyReviewStatus: goproto.Int64(consts.MomentManuallyReview_Waiting), } if len(imageaudittasks) > 0 { momentAuditTask.AuditedMedia = imageaudittasks[0].AuditedMedia @@ -1834,6 +1818,7 @@ func (s *Service) ApiUpdateMoment(ctx *gin.Context, req *momentproto.ApiUpdateRe } else { momentAuditTask.TextAuditTaskStatus = goproto.Int64(consts.MomentAudit_Passed) } + if err := _DefaultMomentAuditTask.OpCreate(ctx, &moment_audit_taskproto.OpCreateReq{ MomentAuditTask: momentAuditTask, }); err != nil { @@ -1904,12 +1889,17 @@ func (s *Service) ApiGetMomentList(ctx *gin.Context, req *momentproto.ApiListReq return } +// 查私有动态接口 func (s *Service) ApiGetMomentListByMid(ctx *gin.Context, req *momentproto.ApiListByMidReq) (voList []*momentproto.ApiMomentVO, ec errcode.ErrCode) { ec = errcode.ErrCodeMomentSrvOk if req.Mid == nil { req.Mid = goproto.Int64(req.BaseRequest.Mid) } + // 用户查别人,只查公开 + if util.DerefInt64(req.Mid) == req.BaseRequest.Mid { + req.Status = goproto.Int64(consts.Moment_Public) + } list, err := _DefaultMoment.OpListByMid(ctx, &momentproto.OpListByMidReq{ Mid: req.Mid, @@ -1917,6 +1907,7 @@ func (s *Service) ApiGetMomentListByMid(ctx *gin.Context, req *momentproto.ApiLi CtLowerBound: req.CtLowerBound, Offset: req.Offset, Limit: req.Limit, + Status: req.Status, }) if err != nil { logger.Error("ApiGetMomentListByMid fail, req: %v, err: %v", util.ToJson(req), err) diff --git a/app/mix/service/imageaudittask_result_handler.go b/app/mix/service/imageaudittask_result_handler.go index 405e98e6..f3854b3a 100644 --- a/app/mix/service/imageaudittask_result_handler.go +++ b/app/mix/service/imageaudittask_result_handler.go @@ -168,6 +168,7 @@ func rollbackMomentImageAuditTask(ctx *gin.Context, task *dbstruct.ImageAuditTas Moment: &dbstruct.Moment{ Id: task.AssociativeTableId, MediaComp: mediaComp, + Status: goproto.Int64(consts.Moment_AuditRejected), }, }); err != nil { return err diff --git a/app/mix/service/logic/moment.go b/app/mix/service/logic/moment.go index 09eabf7e..d4c614fb 100644 --- a/app/mix/service/logic/moment.go +++ b/app/mix/service/logic/moment.go @@ -91,6 +91,7 @@ func (p *Moment) OpListByIds(ctx *gin.Context, req *momentproto.OpListByIdsReq) return list, nil } +// 查私有动态接口 func (p *Moment) OpListByMid(ctx *gin.Context, req *momentproto.OpListByMidReq) ([]*dbstruct.Moment, error) { list, err := p.store.GetMomentListByMid(ctx, req) if err != nil { @@ -119,3 +120,21 @@ func (p *Moment) OpThumbsUp(ctx *gin.Context, req *momentproto.OpThumbsUpReq) (e } return } + +func (p *Moment) OpUpdateByIds(ctx *gin.Context, req *momentproto.OpUpdateReq, ids []int64) error { + err := p.store.UpdateMomentByIds(ctx, req.Moment, ids) + if err != nil { + logger.Error("UpdateMoment fail, err: %v", err) + return err + } + return nil +} + +func (p *Moment) OpUpdateByIdsAndStatus(ctx *gin.Context, req *momentproto.OpUpdateReq, ids []int64, status int64) error { + err := p.store.UpdateMomentByIdsAndStatus(ctx, req.Moment, ids, status) + if err != nil { + logger.Error("UpdateMoment fail, err: %v", err) + return err + } + return nil +} diff --git a/app/mix/service/logic/moment_audit_task.go b/app/mix/service/logic/moment_audit_task.go index 50cfa3fd..c8d378bf 100644 --- a/app/mix/service/logic/moment_audit_task.go +++ b/app/mix/service/logic/moment_audit_task.go @@ -64,6 +64,16 @@ func (p *MomentAuditTask) OpList(ctx *gin.Context, req *moment_audit_taskproto.O return list, nil } +// 查询所有应进入人工复审的帖子 +func (p *MomentAuditTask) OpListWaitingForManuallyReview(ctx *gin.Context, batchId string) ([]*dbstruct.MomentAuditTask, error) { + list, err := p.store.GetMomentAuditTaskListWaitingForManuallyReview(ctx, batchId) + if err != nil { + logger.Error("GetMomentAuditTaskList fail, err: %v", err) + return make([]*dbstruct.MomentAuditTask, 0), err + } + return list, nil +} + func (p *MomentAuditTask) OpUpdateByImageAuditTaskIds(ctx *gin.Context, moment_audit_task *dbstruct.MomentAuditTask, ids []string) error { err := p.store.UpdateMomentAuditTaskByImageAuditTaskIds(ctx, moment_audit_task, ids) if err != nil { @@ -81,3 +91,12 @@ func (p *MomentAuditTask) OpUpdateByTextAuditTaskIds(ctx *gin.Context, moment_au } return nil } + +func (p *MomentAuditTask) OpUpdateByMomentIdsAndStatus(ctx *gin.Context, moment_audit_task *dbstruct.MomentAuditTask, momentIds []int64, status int64) error { + err := p.store.UpdateMomentAuditTaskByMomentIdsAndStatus(ctx, moment_audit_task, momentIds, status) + if err != nil { + logger.Error("UpdateMomentAuditTaskByMomentIdAndStatus fail, err: %v", err) + return err + } + return nil +} diff --git a/app/mix/service/opservice_business_validation.go b/app/mix/service/opservice_business_validation.go index 670abb84..9587fa2e 100644 --- a/app/mix/service/opservice_business_validation.go +++ b/app/mix/service/opservice_business_validation.go @@ -1286,6 +1286,22 @@ func (s *Service) OpThumbsUpMomentBusinessValidate(ctx *gin.Context, req *moment return } +func (s *Service) OpReviewMomentBusinessValidate(ctx *gin.Context, req *momentproto.OpReviewReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeMomentSrvOk + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpReviewMoment business validation failed") + return + } + return +} + func (s *Service) OpGetThumbsUpListBusinessValidate(ctx *gin.Context, req *thumbsupproto.OpListReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeContactCustomerServiceSessionSrvOk diff --git a/app/mix/service/service.go b/app/mix/service/service.go index ee520891..27202055 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -51,6 +51,7 @@ import ( "service/library/mycrypto" "service/library/payclients/alipaycli" "service/library/payclients/wxpaycli" + "service/library/redis" accountpunishmentproto "service/api/proto/accountpunishment/proto" @@ -1051,6 +1052,8 @@ func (s *Service) OpCreateMoment(ctx *gin.Context, req *momentproto.OpCreateReq) return } + req.Moment.Status = goproto.Int64(consts.Moment_Auditing) // 创建动态默认机审中 + err := _DefaultMoment.OpCreate(ctx, req) if err != nil { logger.Error("OpCreate fail, req: %v, err: %v", util.ToJson(req), err) @@ -1078,9 +1081,10 @@ func (s *Service) OpCreateMoment(ctx *gin.Context, req *momentproto.OpCreateReq) // 封装动态审核任务 momentAuditTask := &dbstruct.MomentAuditTask{ - AssociativeTableId: goproto.String(fmt.Sprint(util.DerefInt64(req.Moment.Id))), - AuditedMedia: req.Moment.MediaComp, - AuditedText: req.Moment.Text, + AssociativeTableId: goproto.String(fmt.Sprint(util.DerefInt64(req.Moment.Id))), + AuditedMedia: req.Moment.MediaComp, + AuditedText: req.Moment.Text, + ManuallyReviewStatus: goproto.Int64(consts.MomentManuallyReview_Waiting), } if len(imageaudittasks) > 0 { momentAuditTask.ImageAuditTaskId = imageaudittasks[0].Id @@ -1142,9 +1146,8 @@ func (s *Service) OpUpdateMoment(ctx *gin.Context, req *momentproto.OpUpdateReq) // 封装动态审核任务 momentAuditTask := &dbstruct.MomentAuditTask{ - AssociativeTableId: goproto.String(fmt.Sprint(util.DerefInt64(req.Moment.Id))), - //ImageAuditTaskStatus: goproto.Int64(consts.MomentAudit_Created), - //TextAuditTaskStatus: goproto.Int64(consts.MomentAudit_Created), + AssociativeTableId: goproto.String(fmt.Sprint(util.DerefInt64(req.Moment.Id))), + ManuallyReviewStatus: goproto.Int64(consts.MomentManuallyReview_Waiting), } if len(imageaudittasks) > 0 { momentAuditTask.AuditedMedia = imageaudittasks[0].AuditedMedia @@ -1329,6 +1332,72 @@ func (s *Service) OpThumbsUpMoment(ctx *gin.Context, req *momentproto.OpThumbsUp return } +func (s *Service) OpReviewMoment(ctx *gin.Context, req *momentproto.OpReviewReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeMomentSrvOk + + momentIds := make([]int64, 0) + // 复审完动态,将动态加载到当前redis数组 + defer func() { + if len(momentIds) == 0 { + return + } + go func() { + err := redis.GetRedisClient().RPush(consts.RedisMomentPrefix+"recent_list", momentIds) + if err != nil { + logger.Error("Push newly-created moment to list failed : %v", err) + return + } + }() + }() + + if ec = s.OpReviewMomentBusinessValidate(ctx, req); ec != errcode.ErrCodeMomentSrvOk { + return + } + + // 复审通过进队列 + var finalMomentStatus int64 + var finalMomentAuditTaskStatus int64 + if req.OpType == consts.MomentManuallyReview_Pass { + finalMomentStatus = consts.Moment_Public + finalMomentAuditTaskStatus = consts.MomentManuallyReview_Passed + } else if req.OpType == consts.MomentManuallyReview_Reject { + finalMomentStatus = consts.Moment_ManuallyReviewRejected + finalMomentAuditTaskStatus = consts.MomentManuallyReview_Rejected + } else { + logger.Error("wrong op type, req: %v, err: %v", util.ToJson(req)) + ec = errcode.ErrCodeMomentSrvFail + return + } + + // 更新动态的状态 + err := _DefaultMoment.OpUpdateByIdsAndStatus(ctx, &momentproto.OpUpdateReq{ + Moment: &dbstruct.Moment{ + Status: goproto.Int64(finalMomentStatus), + }, + }, req.MomentIds, consts.Moment_ManuallyReviewing) + if err != nil { + logger.Error("_DefaultMoment OpUpdateByIds fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeMomentSrvFail + return + } + + // 更新动态审核表的状态 + err = _DefaultMomentAuditTask.OpUpdateByMomentIdsAndStatus(ctx, &dbstruct.MomentAuditTask{ + Status: goproto.Int64(finalMomentAuditTaskStatus), + }, req.MomentIds, consts.MomentManuallyReview_Waiting) + if err != nil { + logger.Error("_DefaultMomentAuditTask OpUpdateByMomentIdsAndStatus fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeMomentSrvFail + return + } + + if req.OpType == consts.MomentManuallyReview_Pass { + momentIds = req.MomentIds + } + + return +} + // FootPrint func (s *Service) OpCreateFootPrint(ctx *gin.Context, req *footprintproto.OpCreateReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeFootPrintSrvOk @@ -2592,6 +2661,7 @@ func (s *Service) OpPassImageAuditTaskBatch(ctx *gin.Context, req *imageaudittas ids := make([]string, 0) for i, task := range req.ImageAuditTasks { + task.Status = goproto.Int64(consts.ImageAudit_ManuallyPassed) if err := DefaultImageAuditTaskResultHandler.Handle(ctx, task, consts.ImageAuditTaskUpdate_Pass); err != nil { logger.Error("Execution of update function of %dth task fail: %v", i, err) ec = errcode.ErrCodeImageAuditTaskManuallyPassFail @@ -2662,6 +2732,7 @@ func (s *Service) OpPassTextAuditTaskBatch(ctx *gin.Context, req *textaudittaskp ids := make([]string, 0) for i, task := range req.TextAuditTasks { + task.Status = goproto.Int64(consts.TextAudit_ManuallyPassed) if err := DefaultTextAuditTaskResultHandler.Handle(ctx, task, consts.TextAuditTaskUpdate_Pass); err != nil { logger.Error("Execution of update function of %dth task fail: %v", i, err) ec = errcode.ErrCodeTextAuditTaskManuallyPassFail diff --git a/app/mix/service/textaudittask_result_handler.go b/app/mix/service/textaudittask_result_handler.go index ff249a79..d411ee70 100644 --- a/app/mix/service/textaudittask_result_handler.go +++ b/app/mix/service/textaudittask_result_handler.go @@ -121,7 +121,7 @@ func (handler *TextAuditTaskResultHandler) generateMomentTextUpdateFunc() { return func() error { momentId := task.AssociativeTableId var text *string - if option == consts.ImageAuditTaskUpdate_Pass { + if option == consts.TextAuditTaskUpdate_Pass { text = task.AuditedText } else { text = task.OldText diff --git a/app/mix/service/utilservice.go b/app/mix/service/utilservice.go index 5165797d..27a08b69 100644 --- a/app/mix/service/utilservice.go +++ b/app/mix/service/utilservice.go @@ -24,6 +24,7 @@ import ( "service/library/apollo" "service/library/logger" "service/library/redis" + "strconv" "strings" "time" @@ -510,6 +511,7 @@ func (s *Service) utilSyncImageAuditTaskResultByBatchId(ctx *gin.Context, batchI AssociativeTableName: goproto.String(dao.COLMoment), AssociativeTableColumn: goproto.String("media_component"), BatchId: goproto.String(batchId), + Status: goproto.Int64(consts.MomentAudit_Created), }) if err != nil { logger.Error("_DefaultImageAuditTask OpList fail, err: %v", err) @@ -534,6 +536,14 @@ func (s *Service) utilSyncImageAuditTaskResultByBatchId(ctx *gin.Context, batchI return } } + + // 同步本批次所有待人工复审的任务(通过,或机审失败) + err = s.utilSyncWaitingForManuallyReviewMoment(ctx, batchId) + if err != nil { + logger.Error("_DefaultMomentAuditTask OpUpdateByImageAuditTaskIds fail, err: %v", err) + return + } + return } @@ -568,6 +578,48 @@ func (s *Service) utilSyncTextAuditTaskResultByBatchId(ctx *gin.Context, batchId return } } + + // 同步本批次所有待人工复审的任务(通过,或机审失败) + err = s.utilSyncWaitingForManuallyReviewMoment(ctx, batchId) + if err != nil { + logger.Error("_DefaultMomentAuditTask OpUpdateByImageAuditTaskIds fail, err: %v", err) + return + } + return +} + +// 同步待人工审核的帖子 +func (s *Service) utilSyncWaitingForManuallyReviewMoment(ctx *gin.Context, batchId string) (err error) { + // 查询本批次所有待人工复审的任务(通过,或机审失败) + watingForManuallyReviewImageAuditTasks, err := _DefaultMomentAuditTask.OpListWaitingForManuallyReview(ctx, batchId) + if err != nil { + logger.Error("_DefaultMomentAuditTask OpListWaitingForManuallyReview fail, err: %v", err) + return + } + // 统计该部分的动态id + if len(watingForManuallyReviewImageAuditTasks) == 0 { + return + } + momentIds := make([]int64, 0) + for _, task := range watingForManuallyReviewImageAuditTasks { + idInt, err := strconv.Atoi(util.DerefString(task.AssociativeTableId)) + if err != nil { + logger.Error("strconv Atoi fail, err: %v", err) + return err + } + + momentIds = append(momentIds, int64(idInt)) + } + // 将该部分动态的状态置为待人工审核 + err = _DefaultMoment.OpUpdateByIds(ctx, &momentproto.OpUpdateReq{ + Moment: &dbstruct.Moment{ + Status: goproto.Int64(consts.Moment_ManuallyReviewing), + }, + }, momentIds) + if err != nil { + logger.Error("_DefaultMoment OpUpdateByIds fail, err: %v", err) + return + } return } diff --git a/app/mix/service/xxljob_tasks.go b/app/mix/service/xxljob_tasks.go index 8dda8c02..ed4d0295 100644 --- a/app/mix/service/xxljob_tasks.go +++ b/app/mix/service/xxljob_tasks.go @@ -234,13 +234,13 @@ func (s *CronService) TextAuditBatchHis(ctx context.Context, param *xxl.RunReq) successNum, failNum, err := textaudit.Run(batchId) if err != nil { handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, text audit tasks of this batchId have failed, successNum: %v, failNum: %v, err :%v", batchId, successNum, failNum, err)) + } else { + handleMsg.WriteString(fmt.Sprintf("batchId : %v, text audit tasks of this batchId have finished, successNum: %v, failNum: %v", batchId, successNum, failNum)) } // 同步文字审核结果 err = DefaultService.utilSyncTextAuditTaskResultByBatchId(&gin.Context{}, batchId) if err != nil { handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, text audit tasks of this batchId have failed to syncronize, err :%v", batchId, err)) - } else { - handleMsg.WriteString(fmt.Sprintf("batchId : %v, text audit tasks of this batchId have finished, successNum: %v, failNum: %v", batchId, successNum, failNum)) } logger.Info("Text audit batch ends...") diff --git a/dbstruct/moment_audit_task.go b/dbstruct/moment_audit_task.go index 796dde94..88d157d1 100644 --- a/dbstruct/moment_audit_task.go +++ b/dbstruct/moment_audit_task.go @@ -11,6 +11,8 @@ type MomentAuditTask struct { TextAuditTaskId *string `json:"text_audit_task_id" bson:"text_audit_task_id"` // 文字审核任务表id ImageAuditTaskStatus *int64 `json:"image_audit_task_status" bson:"image_audit_task_status"` // 图像审核任务审核状态 TextAuditTaskStatus *int64 `json:"text_audit_task_status" bson:"text_audit_task_status"` // 文字审核任务审核状态 + Status *int64 `json:"status" bson:"status"` // 是否已过期 + ManuallyReviewStatus *int64 `json:"manually_review_status" bson:"manually_review_status"` // 人工复审状态 Remarks *string `json:"remarks" bson:"remarks"` // 备注 Ct *int64 `json:"ct" bson:"ct"` // 创建时间 Ut *int64 `json:"ut" bson:"ut"` // 更新时间