Merge pull request 'BUG-20241119' (#810) from BUG-20241119 into test

Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/810
This commit is contained in:
chenhao 2024-11-20 16:46:27 +08:00
commit 160c54dfba
7 changed files with 164 additions and 131 deletions

View File

@ -87,7 +87,7 @@ const (
VideoModeration_ServiceFailed = 10 //批次任务失败 VideoModeration_ServiceFailed = 10 //批次任务失败
) )
// 动态审核表状态 // 动态审核表状态(弃用)
const ( const (
MomentAudit_Created = 0 //已创建 MomentAudit_Created = 0 //已创建
MomentAudit_Auditing = 1 //审核中 MomentAudit_Auditing = 1 //审核中
@ -114,12 +114,12 @@ const (
// 动态表status状态 // 动态表status状态
const ( const (
Moment_Private = 0 //仅自己可见 Moment_Private = 0 //仅自己可见
Moment_OpenToCircles = 1 //仅朋友圈可见 Moment_OpenToCircles = 1 //仅朋友圈可见(弃用状态)
Moment_Public = 2 //公开 Moment_Public = 2 //公开
Moment_Auditing = 3 //机审中 Moment_Auditing = 3 //机审中
Moment_ManuallyReviewing = 4 //人工复审中 Moment_ManuallyReviewing = 4 //人工复审中
Moment_AuditRejected = 5 //机审拒绝 Moment_AuditRejected = 5 //机审拒绝 (中间态,实际上不关心)
Moment_ManuallyReviewRejected = 6 //人工复审拒绝 Moment_ManuallyReviewRejected = 6 //人工复审拒绝(折衷方案,等价于空间动态的状态自见+人审拒绝)
) )
// 是否被关注 // 是否被关注

View File

@ -50,14 +50,9 @@ type OpUpdateResp struct {
// op 列表 // op 列表
type OpListReq struct { type OpListReq struct {
base.BaseRequest base.BaseRequest
AssociativeTableId *int64 `json:"associative_table_id"` Status *int64 `json:"status"`
BatchId *string `json:"batch_id"` Offset int `json:"offset"`
ImageAuditTaskId *string `json:"image_audit_task_id"` Limit int `json:"limit"`
TextAuditTaskId *string `json:"text_audit_task_id"`
Status *int64 `json:"status"`
ManuallyReviewStatus *int64 `json:"manually_review_status"`
Offset int `json:"offset"`
Limit int `json:"limit"`
} }
type OpListData struct { type OpListData struct {

View File

@ -1708,6 +1708,21 @@ func (m *Mongo) GetMomentList(ctx *gin.Context, req *momentproto.OpListReq) ([]*
return list, err return list, err
} }
func (m *Mongo) GetMomentListByStatus(ctx *gin.Context, status int64, limit, offset int) ([]*dbstruct.Moment, error) {
list := make([]*dbstruct.Moment, 0)
col := m.getColMoment()
query := qmgo.M{
"status": status,
"del_flag": 0,
}
err := col.Find(ctx, query).Sort("-ct").Skip(int64(offset)).Limit(int64(limit)).All(&list)
if err == qmgo.ErrNoSuchDocuments {
err = nil
return list, err
}
return list, err
}
// 临时接口 // 临时接口
func (m *Mongo) GetDeletedMomentList(ctx *gin.Context, req *momentproto.OpListReq) ([]*dbstruct.Moment, error) { func (m *Mongo) GetDeletedMomentList(ctx *gin.Context, req *momentproto.OpListReq) ([]*dbstruct.Moment, error) {
list := make([]*dbstruct.Moment, 0) list := make([]*dbstruct.Moment, 0)
@ -4095,56 +4110,6 @@ func (m *Mongo) GetMomentAuditTaskList(ctx *gin.Context, req *moment_audit_taskp
query := qmgo.M{ query := qmgo.M{
"del_flag": 0, "del_flag": 0,
} }
if req.AssociativeTableId != nil {
query["associative_table_id"] = util.DerefInt64(req.AssociativeTableId)
}
if req.BatchId != nil {
query["batch_id"] = util.DerefString(req.BatchId)
}
if req.ImageAuditTaskId != nil {
query["image_audit_task_id"] = util.DerefString(req.ImageAuditTaskId)
}
if req.TextAuditTaskId != nil {
query["text_audit_task_id"] = util.DerefString(req.TextAuditTaskId)
}
if req.ManuallyReviewStatus != nil {
query["manually_review_status"] = util.DerefInt64(req.ManuallyReviewStatus)
}
if req.Status != nil {
// 若是审核通过,则图像和文字审核均必须通过
// 若是人工审核通过,则图像和文字审核中至少要有一个人工审核通过,且剩下的均为通过或者人工审核通过
// 其余状态只要图像和文字审核中有一个满足,即满足查询条件
status := util.DerefInt64(req.Status)
switch status {
case consts.MomentAudit_Passed:
query["image_audit_task_status"] = consts.MomentAudit_Passed
query["text_audit_task_status"] = consts.MomentAudit_Passed
case consts.MomentAudit_ManuallyPassed:
orClause := make([]qmgo.M, 0)
orClause = append(orClause, qmgo.M{
"image_audit_task_status": consts.MomentAudit_ManuallyPassed,
})
orClause = append(orClause, qmgo.M{
"text_audit_task_status": consts.MomentAudit_ManuallyPassed,
})
query["$or"] = orClause
query["image_audit_task_status"] = qmgo.M{
"$in": []int64{consts.MomentAudit_Passed, consts.MomentAudit_ManuallyPassed},
}
query["text_audit_task_status"] = qmgo.M{
"$in": []int64{consts.MomentAudit_Passed, consts.MomentAudit_ManuallyPassed},
}
default:
orClause := make([]qmgo.M, 0)
orClause = append(orClause, qmgo.M{
"image_audit_task_status": status,
})
orClause = append(orClause, qmgo.M{
"text_audit_task_status": status,
})
query["$or"] = orClause
}
}
err := col.Find(ctx, query).Sort("-ct").Skip(int64(req.Offset)).Limit(int64(req.Limit)).All(&list) err := col.Find(ctx, query).Sort("-ct").Skip(int64(req.Offset)).Limit(int64(req.Limit)).All(&list)
if err == qmgo.ErrNoSuchDocuments { if err == qmgo.ErrNoSuchDocuments {
err = nil err = nil
@ -4286,6 +4251,38 @@ func (m *Mongo) TryToFinishVideoModerationTaskOfMoment(ctx *gin.Context, task *d
return &instance, nil return &instance, nil
} }
func (m *Mongo) GetMomentAuditTaskListByIds(ctx *gin.Context, ids []int64) ([]*dbstruct.MomentAuditTask, error) {
list := make([]*dbstruct.MomentAuditTask, 0)
col := m.getColMomentAuditTask()
query := qmgo.M{
"_id": qmgo.M{
"$in": ids,
},
}
err := col.Find(ctx, query).All(&list)
if err == qmgo.ErrNoSuchDocuments {
err = nil
return list, err
}
return list, err
}
func (m *Mongo) GetMomentAuditTaskByMomentIds(ctx *gin.Context, momentIds []int64) ([]*dbstruct.MomentAuditTask, error) {
list := make([]*dbstruct.MomentAuditTask, 0)
col := m.getColMomentAuditTask()
query := qmgo.M{
"associative_table_id": qmgo.M{
"$in": momentIds,
},
}
err := col.Find(ctx, query).All(&list)
if err == qmgo.ErrNoSuchDocuments {
err = nil
return make([]*dbstruct.MomentAuditTask, 0), err
}
return list, err
}
// 联系客服对话表相关 // 联系客服对话表相关
func (m *Mongo) CreateContactCustomerServiceSession(ctx *gin.Context, contact_customer_service_session *dbstruct.ContactCustomerServiceSession) error { func (m *Mongo) CreateContactCustomerServiceSession(ctx *gin.Context, contact_customer_service_session *dbstruct.ContactCustomerServiceSession) error {
col := m.getColContactCustomerServiceSession() col := m.getColContactCustomerServiceSession()

View File

@ -2343,14 +2343,13 @@ func (s *Service) ApiCreateMoment(ctx *gin.Context, req *momentproto.ApiCreateRe
// 封装动态审核任务 // 封装动态审核任务
momentAuditTask := &dbstruct.MomentAuditTask{ momentAuditTask := &dbstruct.MomentAuditTask{
AssociativeTableId: goproto.String(fmt.Sprint(util.DerefInt64(req.Moment.Id))), AssociativeTableId: goproto.String(fmt.Sprint(req.Moment.GetId())),
AuditedMedia: req.Moment.MediaComp, AuditedMedia: req.Moment.MediaComp,
AuditedText: req.Moment.Text, AuditedText: req.Moment.Text,
Status: goproto.Int64(consts.MomentAudit_Created),
ManuallyReviewStatus: goproto.Int64(consts.MomentManuallyReview_Waiting), ManuallyReviewStatus: goproto.Int64(consts.MomentManuallyReview_Waiting),
} }
momentAuditTask.ImageAuditTaskStatus = goproto.Int64(consts.MomentAudit_Created) momentAuditTask.ImageAuditTaskStatus = goproto.Int64(consts.ImageAudit_Created)
if len(imageaudittasks) > 0 { if len(imageaudittasks) > 0 {
momentAuditTask.ImageAuditTaskId = imageaudittasks[0].Id momentAuditTask.ImageAuditTaskId = imageaudittasks[0].Id
} else if len(videomoderationtasks) > 0 { } else if len(videomoderationtasks) > 0 {
@ -2361,9 +2360,9 @@ func (s *Service) ApiCreateMoment(ctx *gin.Context, req *momentproto.ApiCreateRe
} }
if len(textaudittasks) > 0 { if len(textaudittasks) > 0 {
momentAuditTask.TextAuditTaskId = textaudittasks[0].Id momentAuditTask.TextAuditTaskId = textaudittasks[0].Id
momentAuditTask.TextAuditTaskStatus = goproto.Int64(consts.MomentAudit_Created) momentAuditTask.TextAuditTaskStatus = goproto.Int64(consts.TextAudit_Created)
} else { } else {
momentAuditTask.TextAuditTaskStatus = goproto.Int64(consts.MomentAudit_Passed) momentAuditTask.TextAuditTaskStatus = goproto.Int64(consts.TextAudit_Passed)
} }
if err := _DefaultMomentAuditTask.OpCreate(ctx, &moment_audit_taskproto.OpCreateReq{ if err := _DefaultMomentAuditTask.OpCreate(ctx, &moment_audit_taskproto.OpCreateReq{
MomentAuditTask: momentAuditTask, MomentAuditTask: momentAuditTask,
@ -2387,23 +2386,6 @@ func (s *Service) ApiUpdateMoment(ctx *gin.Context, req *momentproto.ApiUpdateRe
req.Moment.Mid = goproto.Int64(req.BaseRequest.Mid) req.Moment.Mid = goproto.Int64(req.BaseRequest.Mid)
err := _DefaultMoment.OpUpdate(ctx, &momentproto.OpUpdateReq{
Moment: &dbstruct.Moment{
Id: req.Moment.Id,
Status: goproto.Int64(consts.Moment_Auditing),
},
})
if err == qmgo.ErrNoSuchDocuments {
ec = errcode.ErrCodeMomentNotExist
err = nil
return
}
if err != nil {
logger.Error("ApiUpdate fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeMomentSrvFail
return
}
//读取默认动态文字配置 //读取默认动态文字配置
defaultMomentText, err := apollo.GetStringValue(consts.DefaultMomentTextKey, apollo.ApolloOpts().SetNamespace("application")) defaultMomentText, err := apollo.GetStringValue(consts.DefaultMomentTextKey, apollo.ApolloOpts().SetNamespace("application"))
if err != nil { if err != nil {
@ -2422,40 +2404,74 @@ func (s *Service) ApiUpdateMoment(ctx *gin.Context, req *momentproto.ApiUpdateRe
videomoderationtasks := s.CreateMomentVideoModeration(ctx, req.Moment) videomoderationtasks := s.CreateMomentVideoModeration(ctx, req.Moment)
if len(imageaudittasks) > 0 || len(textaudittasks) > 0 || len(videomoderationtasks) > 0 { if len(imageaudittasks) > 0 || len(textaudittasks) > 0 || len(videomoderationtasks) > 0 {
// 封装动态审核任务
momentAuditTask := &dbstruct.MomentAuditTask{ // 需要重新过机审
AssociativeTableId: goproto.String(fmt.Sprint(req.Moment.GetId())), req.Moment.Status = goproto.Int64(consts.Moment_Auditing)
Status: goproto.Int64(consts.MomentAudit_Created),
ManuallyReviewStatus: goproto.Int64(consts.MomentManuallyReview_Waiting), // 查出该动态的审核任务
tasks, err := _DefaultMomentAuditTask.GetByMomentIds(ctx, []int64{req.Moment.GetId()})
if err == qmgo.ErrNoSuchDocuments {
ec = errcode.ErrCodeMomentAuditTaskNotExist
err = nil
return
}
if err != nil {
logger.Error("ApiUpdate fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeMomentAuditTaskSrvFail
return
}
// 修改该动态的审核任务
updateEntity := &dbstruct.MomentAuditTask{
Id: tasks[0].Id,
ManuallyReviewStatus: goproto.Int64(consts.MomentManuallyReview_Waiting),
ManuallyReviewOperator: goproto.Int64(0),
Remarks: goproto.String(""),
} }
if len(imageaudittasks) > 0 { if len(imageaudittasks) > 0 {
momentAuditTask.ImageAuditTaskId = imageaudittasks[0].Id updateEntity.ImageAuditTaskId = imageaudittasks[0].Id
momentAuditTask.AuditedMedia = imageaudittasks[0].AuditedMedia updateEntity.AuditedMedia = imageaudittasks[0].AuditedMedia
momentAuditTask.ImageAuditTaskStatus = goproto.Int64(consts.MomentAudit_Created) updateEntity.ImageAuditTaskStatus = goproto.Int64(consts.ImageAudit_Created)
updateEntity.ImageAuditOpinion = goproto.String("")
} else if len(videomoderationtasks) > 0 { } else if len(videomoderationtasks) > 0 {
momentAuditTask.ImageAuditTaskId = videomoderationtasks[0].Id updateEntity.ImageAuditTaskId = videomoderationtasks[0].Id
momentAuditTask.AuditedMedia = videomoderationtasks[0].AuditedMedia updateEntity.AuditedMedia = videomoderationtasks[0].AuditedMedia
momentAuditTask.ImageAuditTaskStatus = goproto.Int64(consts.MomentAudit_Created) updateEntity.ImageAuditTaskStatus = goproto.Int64(consts.VideoModeration_Created)
} else { // 媒体内容未更新,默认设置为通过 updateEntity.ImageAuditOpinion = goproto.String("")
momentAuditTask.ImageAuditTaskStatus = goproto.Int64(consts.MomentAudit_Passed)
}
if len(textaudittasks) > 0 {
momentAuditTask.AuditedText = textaudittasks[0].AuditedText
momentAuditTask.TextAuditTaskId = textaudittasks[0].Id
momentAuditTask.TextAuditTaskStatus = goproto.Int64(consts.MomentAudit_Created)
} else {
momentAuditTask.TextAuditTaskStatus = goproto.Int64(consts.MomentAudit_Passed)
} }
if err := _DefaultMomentAuditTask.OpCreate(ctx, &moment_audit_taskproto.OpCreateReq{ if len(textaudittasks) > 0 {
MomentAuditTask: momentAuditTask, updateEntity.AuditedText = textaudittasks[0].AuditedText
updateEntity.TextAuditTaskId = textaudittasks[0].Id
updateEntity.TextAuditTaskStatus = goproto.Int64(consts.TextAudit_Created)
updateEntity.TextAuditOpinion = goproto.String("")
}
// 修改该动态的审核任务
if err := _DefaultMomentAuditTask.OpUpdate(ctx, &moment_audit_taskproto.OpUpdateReq{
MomentAuditTask: updateEntity,
}); err != nil { }); err != nil {
ec = errcode.ErrCodeMomentAuditTaskSrvFail ec = errcode.ErrCodeMomentAuditTaskSrvFail
return return
} }
} }
// 更新动态
err = _DefaultMoment.OpUpdate(ctx, &momentproto.OpUpdateReq{
Moment: req.Moment,
})
if err == qmgo.ErrNoSuchDocuments {
ec = errcode.ErrCodeMomentNotExist
err = nil
return
}
if err != nil {
logger.Error("ApiUpdate fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeMomentSrvFail
return
}
return return
} }

View File

@ -186,3 +186,12 @@ func (p *Moment) GetByIds(ctx *gin.Context, ids []int64) ([]*dbstruct.Moment, er
} }
return list, nil return list, nil
} }
func (p *Moment) GetByStatus(ctx *gin.Context, status int64, limit, offset int) ([]*dbstruct.Moment, error) {
list, err := p.store.GetMomentListByStatus(ctx, status, limit, offset)
if err != nil {
logger.Error("GetMomentListByStatus fail, err: %v", err)
return make([]*dbstruct.Moment, 0), err
}
return list, nil
}

View File

@ -129,3 +129,21 @@ func (p *MomentAuditTask) TryToFinishVideoModerationTask(ctx *gin.Context, task
} }
return instance.GetImageAuditTaskStatus() != consts.ImageAudit_Created && instance.GetTextAuditTaskStatus() != consts.TextAudit_Created, nil return instance.GetImageAuditTaskStatus() != consts.ImageAudit_Created && instance.GetTextAuditTaskStatus() != consts.TextAudit_Created, nil
} }
func (p *MomentAuditTask) GetByIds(ctx *gin.Context, ids []int64) ([]*dbstruct.MomentAuditTask, error) {
list, err := p.store.GetMomentAuditTaskListByIds(ctx, ids)
if err != nil {
logger.Error("GetMomentAuditTaskListByIds fail, err: %v", err)
return make([]*dbstruct.MomentAuditTask, 0), err
}
return list, nil
}
func (p *MomentAuditTask) GetByMomentIds(ctx *gin.Context, momentIds []int64) ([]*dbstruct.MomentAuditTask, error) {
list, err := p.store.GetMomentAuditTaskByMomentIds(ctx, momentIds)
if err != nil {
logger.Error("GetMomentAuditTaskListByIds fail, err: %v", err)
return nil, err
}
return list, nil
}

View File

@ -3592,10 +3592,29 @@ func (s *Service) OpGetMomentAuditTaskList(ctx *gin.Context, req *moment_audit_t
return return
} }
req.ManuallyReviewStatus = goproto.Int64(consts.MomentManuallyReview_Waiting) moments, err := _DefaultMoment.GetByStatus(ctx, util.DerefInt64(req.Status), req.Limit, req.Offset)
list, err := _DefaultMomentAuditTask.OpList(ctx, req)
if err != nil { if err != nil {
logger.Error("OpGetMomentAuditTaskList fail, req: %v, err: %v", util.ToJson(req), err) logger.Error("GetByStatus fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeMomentSrvFail
return
}
momentIds := make([]int64, 0)
momentMp := make(map[string]*dbstruct.Moment)
mids := make([]int64, 0)
midSet := make(map[int64]*dbstruct.Moment)
for _, moment := range moments {
momentIds = append(momentIds, moment.GetId())
momentMp[fmt.Sprint(moment.GetId())] = moment
mid := moment.GetMid()
if midSet[mid] == nil {
midSet[mid] = &dbstruct.Moment{}
mids = append(mids, mid)
}
}
list, err := _DefaultMomentAuditTask.GetByMomentIds(ctx, momentIds)
if err != nil {
logger.Error("OpGetMomentAuditTaskListByIds fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeMomentAuditTaskSrvFail ec = errcode.ErrCodeMomentAuditTaskSrvFail
return return
} }
@ -3604,16 +3623,9 @@ func (s *Service) OpGetMomentAuditTaskList(ctx *gin.Context, req *moment_audit_t
// 收集图像和文字审核的id分别查询出图像和文字审核的任务 // 收集图像和文字审核的id分别查询出图像和文字审核的任务
imageAuditTaskIds := make([]string, 0) imageAuditTaskIds := make([]string, 0)
textAuditTaskIds := make([]string, 0) textAuditTaskIds := make([]string, 0)
momentIdSet := make(map[string]*dbstruct.Moment)
momentIds := make([]string, 0)
for _, task := range list { for _, task := range list {
imageAuditTaskIds = append(imageAuditTaskIds, util.DerefString(task.ImageAuditTaskId)) imageAuditTaskIds = append(imageAuditTaskIds, util.DerefString(task.ImageAuditTaskId))
textAuditTaskIds = append(textAuditTaskIds, util.DerefString(task.TextAuditTaskId)) textAuditTaskIds = append(textAuditTaskIds, util.DerefString(task.TextAuditTaskId))
momentId := task.GetAssociativeTableId()
if momentIdSet[momentId] == nil {
momentIdSet[momentId] = &dbstruct.Moment{}
momentIds = append(momentIds, momentId)
}
} }
imageAuditTaskMap, err := _DefaultImageAuditTask.OpGetImageAuditTaskMapByIds(ctx, imageAuditTaskIds) imageAuditTaskMap, err := _DefaultImageAuditTask.OpGetImageAuditTaskMapByIds(ctx, imageAuditTaskIds)
if err != nil { if err != nil {
@ -3627,21 +3639,7 @@ func (s *Service) OpGetMomentAuditTaskList(ctx *gin.Context, req *moment_audit_t
ec = errcode.ErrCodeTextAuditTaskSrvFail ec = errcode.ErrCodeTextAuditTaskSrvFail
return return
} }
momentMp, err := _DefaultMoment.GetMomentStringIdMapByIds(ctx, momentIds)
if err != nil {
logger.Error("GetMomentStringIdMapByIds fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeMomentSrvFail
return
}
midSet := make(map[int64]*dbstruct.Moment)
mids := make([]int64, 0)
for _, v := range momentMp {
mid := v.GetMid()
if midSet[mid] == nil {
midSet[mid] = &dbstruct.Moment{}
mids = append(mids, mid)
}
}
streamerMp, err := s.utilGetStreamerExtMapByMids(ctx, mids, consts.InterfaceType_Op) streamerMp, err := s.utilGetStreamerExtMapByMids(ctx, mids, consts.InterfaceType_Op)
if err != nil { if err != nil {
logger.Error("utilGetStreamerExtMapByMids fail, req: %v, err: %v", util.ToJson(req), err) logger.Error("utilGetStreamerExtMapByMids fail, req: %v, err: %v", util.ToJson(req), err)