Merge pull request 'conflict-test-feat-20240117-001-Robin' (#110) from conflict-test-feat-20240117-001-Robin into test
Reviewed-on: #110
This commit is contained in:
commit
e95d2311cc
|
@ -49,6 +49,7 @@ const (
|
|||
ImageAudit_Expired = 8 //已失效
|
||||
ImageAudit_Failed = 9 //已回退失败
|
||||
ImageAudit_ServiceFailed = 10 //批次任务失败
|
||||
ImageAudit_ForAlignment = 11 //对齐使用
|
||||
)
|
||||
|
||||
// 文字审核表状态
|
||||
|
@ -64,6 +65,7 @@ const (
|
|||
TextAudit_Expired = 8 //已失效
|
||||
TextAudit_Failed = 9 //回退失败
|
||||
TextAudit_ServiceFailed = 10 //批次任务失败
|
||||
TextAudit_ForAlignment = 11 //对齐使用
|
||||
)
|
||||
|
||||
// 意见反馈表的status审批状态
|
||||
|
@ -93,3 +95,14 @@ const (
|
|||
IsThumbedUp_No = 0 //否
|
||||
IsThumbedUp_Yes = 1 //是
|
||||
)
|
||||
|
||||
// 是否已经对齐
|
||||
// 对齐是指同一张表中,某一些审核字段必须在审核表中同时存在,以便查询
|
||||
// ex:动态表Moment,需要将文字和图像的审核任务对齐,二者不能单独存在,就算某个创建动态的请求只有图片,没有文字,
|
||||
// 也应在文字审核表中插入一条status为11的空任务,这样便于查询该类对齐任务时做分页查询
|
||||
const (
|
||||
ImageAuditIsAligned_No = 0 //否
|
||||
ImageAuditIsAligned_Yes = 1 //是
|
||||
TextAuditIsAligned_No = 0 //否
|
||||
TextAuditIsAligned_Yes = 1 //是
|
||||
)
|
||||
|
|
|
@ -147,6 +147,10 @@ var ErrCodeMsgMap = map[ErrCode]string{
|
|||
ErrCodeMomentCreateTimesSrvFail: "动态创建频次表服务错误",
|
||||
ErrCodeMomentCreateTimesNotExist: "动态创建频次表不存在",
|
||||
ErrCodeMomentCreateTimesReachedDailyUpperbound: "每天仅可发布三条动态",
|
||||
|
||||
ErrCodeAlignedAuditTaskSrvFail: "已对齐审核任务服务错误",
|
||||
ErrCodeAlignedAuditTaskNotExist: "已对齐审核任务不存在",
|
||||
ErrCodeAlignedAuditTaskNotAligned: "数据库该类审核作业不对齐",
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -350,6 +354,12 @@ const (
|
|||
ErrCodeMomentCreateTimesNotExist ErrCode = -28002 // 动态创建频次表不存在
|
||||
ErrCodeMomentCreateTimesReachedDailyUpperbound ErrCode = -28003 // 动态创建次数已达每日上限
|
||||
|
||||
// AlignedAuditTask: 29xxx
|
||||
ErrCodeAlignedAuditTaskSrvOk ErrCode = ErrCodeOk
|
||||
ErrCodeAlignedAuditTaskSrvFail ErrCode = -29001 // 已对齐审核任务服务错误
|
||||
ErrCodeAlignedAuditTaskNotExist ErrCode = -29002 // 已对齐审核任务不存在
|
||||
ErrCodeAlignedAuditTaskNotAligned ErrCode = -29003 // 数据库该类审核作业不对齐
|
||||
|
||||
// Media: 60xxx
|
||||
ErrCodeMediaSrvOk ErrCode = ErrCodeOk
|
||||
ErrCodeMediaSrvFail ErrCode = -60001 // 媒体服务错误
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package proto
|
||||
|
||||
import "service/api/base"
|
||||
|
||||
// op 列表
|
||||
type OpListReq struct {
|
||||
base.BaseRequest
|
||||
RouteUrl *string `json:"route_url"`
|
||||
AssociativeDatabase *string `json:"associative_data_base"`
|
||||
AssociativeTableName *string `json:"associative_tabel_name"`
|
||||
AssociativeTableId *int64 `json:"associative_tabel_id"`
|
||||
BatchId *string `json:"batch_id"`
|
||||
Status *int64 `json:"status"`
|
||||
Offset int `json:"offset"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
|
||||
type OpListData struct {
|
||||
List []*AlignedAuditTaskVO `json:"list"`
|
||||
Offset int `json:"offset"`
|
||||
More int `json:"more"`
|
||||
}
|
||||
|
||||
type OpListResp struct {
|
||||
base.BaseResponse
|
||||
Data *OpListData `json:"data"`
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package proto
|
||||
|
||||
import (
|
||||
imageaudittaskproto "service/api/proto/imageaudittask/proto"
|
||||
textaudittaskproto "service/api/proto/textaudittask/proto"
|
||||
)
|
||||
|
||||
type AlignedAuditTaskVO struct {
|
||||
ImageAuditTaskVO *imageaudittaskproto.ImageAuditTaskVO `json:"image_audit_task_vo"`
|
||||
TextAuditTaskVO *textaudittaskproto.TextAuditTaskVO `json:"text_audit_task_vo"`
|
||||
}
|
|
@ -24,6 +24,7 @@ func (p *ApiUpdateReq) ProvideNotNullValue() (params []*validator.JsonParam) {
|
|||
params = make([]*validator.JsonParam, 0)
|
||||
|
||||
params = append(params, validator.NewInt64PtrParam("请确认待更新动态的id!", p.Moment.Id))
|
||||
params = append(params, validator.NewStructPtrParam("动态内容不能为空!", p.Moment))
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"service/api/consts"
|
||||
"service/api/errcode"
|
||||
alignedaudittaskproto "service/api/proto/alignedaudittask/proto"
|
||||
"service/app/mix/service"
|
||||
"service/bizcommon/util"
|
||||
"service/library/logger"
|
||||
"service/library/mediafiller"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func OpGetAlignedAuditTaskList(ctx *gin.Context) {
|
||||
req := ctx.MustGet("client_req").(*alignedaudittaskproto.OpListReq)
|
||||
|
||||
//设置默认页长
|
||||
if req.Limit == 0 {
|
||||
req.Limit = consts.DefaultPageSize
|
||||
}
|
||||
|
||||
list, ec := service.DefaultService.OpGetAlignedAuditTaskVOList(ctx, req)
|
||||
if ec != errcode.ErrCodeAlignedAuditTaskSrvOk {
|
||||
logger.Error("OpGetAlignedAuditTaskList fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrCodeMsg(ctx, ec)
|
||||
return
|
||||
}
|
||||
|
||||
//填充媒体切片
|
||||
objectMediaNum := 2 //
|
||||
mediaFillableList := make([]mediafiller.MediaFillable, len(list)*objectMediaNum)
|
||||
for i, task := range list {
|
||||
mediaFillableList[objectMediaNum*i+0] = task.ImageAuditTaskVO.AuditedMedia
|
||||
mediaFillableList[objectMediaNum*i+1] = task.ImageAuditTaskVO.OldMedia
|
||||
}
|
||||
mediafiller.FillList(ctx, mediaFillableList)
|
||||
|
||||
data := &alignedaudittaskproto.OpListData{
|
||||
List: list,
|
||||
Offset: req.Offset + len(list),
|
||||
}
|
||||
if len(list) >= req.Limit {
|
||||
data.More = 1
|
||||
}
|
||||
ReplyOk(ctx, data)
|
||||
}
|
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
alignedaudittaskproto "service/api/proto/alignedaudittask/proto"
|
||||
imageaudittaskproto "service/api/proto/imageaudittask/proto"
|
||||
mediaproto "service/api/proto/media/proto"
|
||||
"service/library/logger"
|
||||
|
@ -372,6 +373,10 @@ func Init(r *gin.Engine) {
|
|||
opTextAuditTaskGroup.POST("list", middleware.JSONParamValidator(textaudittaskproto.OpListReq{}), middleware.JwtAuthenticator(), OpGetTextAuditTaskList)
|
||||
opTextAuditTaskGroup.POST("pass_batch", middleware.JSONParamValidator(textaudittaskproto.OpPassBatchReq{}), middleware.JwtAuthenticator(), OpPassTextAuditTaskBatch)
|
||||
|
||||
// 已对齐的任务
|
||||
opAlignedAuditTaskGroup := r.Group("/op/aligned_audit_task", PrepareOp())
|
||||
opAlignedAuditTaskGroup.POST("list", middleware.JSONParamValidator(alignedaudittaskproto.OpListReq{}), middleware.JwtAuthenticator(), OpGetAlignedAuditTaskList)
|
||||
|
||||
// 媒体相关
|
||||
mediaGroup := r.Group("/api/media", PrepareToC())
|
||||
mediaGroup.POST("auth", middleware.JSONParamValidator(mediaproto.MediaAuthReq{}), middleware.JwtAuthenticator(), MediaAuth)
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
|
||||
accountproto "service/api/proto/account/proto"
|
||||
accountrelationproto "service/api/proto/accountrelation/proto"
|
||||
alignedaudittaskproto "service/api/proto/alignedaudittask/proto"
|
||||
appconfigproto "service/api/proto/app_config/proto"
|
||||
callhistoryproto "service/api/proto/callhistory/proto"
|
||||
contact_customer_service_proto "service/api/proto/contact_customer_service/proto"
|
||||
|
@ -2786,6 +2787,76 @@ func (m *Mongo) UpdateOverdueTextAuditTasksStatus(ctx *gin.Context, textaudittas
|
|||
return result, err
|
||||
}
|
||||
|
||||
func (m *Mongo) GetAlignedImageAuditTaskList(ctx *gin.Context, req *alignedaudittaskproto.OpListReq) ([]*dbstruct.ImageAuditTask, error) {
|
||||
list := make([]*dbstruct.ImageAuditTask, 0)
|
||||
col := m.getColImageAuditTask()
|
||||
query := qmgo.M{
|
||||
"del_flag": 0,
|
||||
}
|
||||
if req.RouteUrl != nil {
|
||||
query["route_url"] = util.DerefString(req.RouteUrl)
|
||||
}
|
||||
if req.AssociativeDatabase != nil {
|
||||
query["associative_data_base"] = util.DerefString(req.AssociativeDatabase)
|
||||
}
|
||||
if req.AssociativeTableName != nil {
|
||||
query["associative_tabel_name"] = util.DerefString(req.AssociativeTableName)
|
||||
}
|
||||
if req.AssociativeTableId != nil {
|
||||
query["associative_tabel_id"] = util.DerefInt64(req.AssociativeTableId)
|
||||
}
|
||||
if req.BatchId != nil {
|
||||
query["batch_id"] = util.DerefString(req.BatchId)
|
||||
}
|
||||
if req.Status != nil {
|
||||
query["status"] = qmgo.M{
|
||||
"$in": []int64{util.DerefInt64(req.Status), consts.ImageAudit_ForAlignment},
|
||||
}
|
||||
}
|
||||
sortClause := []string{"associative_data_base", "associative_tabel_name", "associative_tabel_id", "associative_table_column"}
|
||||
err := col.Find(ctx, query).Sort(sortClause...).Skip(int64(req.Offset)).Limit(int64(req.Limit)).All(&list)
|
||||
if err == qmgo.ErrNoSuchDocuments {
|
||||
err = nil
|
||||
return list, err
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
func (m *Mongo) GetAlignedTextAuditTaskList(ctx *gin.Context, req *alignedaudittaskproto.OpListReq) ([]*dbstruct.TextAuditTask, error) {
|
||||
list := make([]*dbstruct.TextAuditTask, 0)
|
||||
col := m.getColTextAuditTask()
|
||||
query := qmgo.M{
|
||||
"del_flag": 0,
|
||||
}
|
||||
if req.RouteUrl != nil {
|
||||
query["route_url"] = util.DerefString(req.RouteUrl)
|
||||
}
|
||||
if req.AssociativeDatabase != nil {
|
||||
query["associative_data_base"] = util.DerefString(req.AssociativeDatabase)
|
||||
}
|
||||
if req.AssociativeTableName != nil {
|
||||
query["associative_tabel_name"] = util.DerefString(req.AssociativeTableName)
|
||||
}
|
||||
if req.AssociativeTableId != nil {
|
||||
query["associative_tabel_id"] = util.DerefInt64(req.AssociativeTableId)
|
||||
}
|
||||
if req.BatchId != nil {
|
||||
query["batch_id"] = util.DerefString(req.BatchId)
|
||||
}
|
||||
if req.Status != nil {
|
||||
query["status"] = qmgo.M{
|
||||
"$in": []int64{util.DerefInt64(req.Status), consts.TextAudit_ForAlignment},
|
||||
}
|
||||
}
|
||||
sortClause := []string{"associative_data_base", "associative_tabel_name", "associative_tabel_id", "associative_table_column"}
|
||||
err := col.Find(ctx, query).Sort(sortClause...).Skip(int64(req.Offset)).Limit(int64(req.Limit)).All(&list)
|
||||
if err == qmgo.ErrNoSuchDocuments {
|
||||
err = nil
|
||||
return list, err
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// 联系客服对话表相关
|
||||
func (m *Mongo) CreateContactCustomerServiceSession(ctx *gin.Context, contact_customer_service_session *dbstruct.ContactCustomerServiceSession) error {
|
||||
col := m.getColContactCustomerServiceSession()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"service/api/consts"
|
||||
"service/dbstruct"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -59,6 +60,7 @@ func (s *Service) CreateUpdateStreamerImageAudit(ctx *gin.Context, oldStreamer *
|
|||
|
||||
func (s *Service) CreateMomentImageAudit(ctx *gin.Context, newMoment *dbstruct.Moment) (tasks []*dbstruct.ImageAuditTask) {
|
||||
|
||||
// 内容为空,则创建一个对齐任务,保证Moment所有图像和文字审核均对齐,便于后续查询
|
||||
if newMoment.MediaComp != nil {
|
||||
tasks = append(tasks, &dbstruct.ImageAuditTask{
|
||||
RouteUrl: goproto.String(ctx.Request.URL.Path),
|
||||
|
@ -68,6 +70,19 @@ func (s *Service) CreateMomentImageAudit(ctx *gin.Context, newMoment *dbstruct.M
|
|||
AssociativeTableColumn: goproto.String("media_component"),
|
||||
AuditedMedia: newMoment.MediaComp,
|
||||
OldMedia: nil,
|
||||
IsAligned: goproto.Int64(consts.ImageAuditIsAligned_Yes),
|
||||
})
|
||||
} else {
|
||||
tasks = append(tasks, &dbstruct.ImageAuditTask{
|
||||
RouteUrl: goproto.String(ctx.Request.URL.Path),
|
||||
AssociativeDatabase: goproto.String("moment"),
|
||||
AssociativeTableName: goproto.String("moment"),
|
||||
AssociativeTableId: newMoment.Id,
|
||||
AssociativeTableColumn: goproto.String("media_component"),
|
||||
AuditedMedia: newMoment.MediaComp,
|
||||
OldMedia: nil,
|
||||
IsAligned: goproto.Int64(consts.ImageAuditIsAligned_Yes),
|
||||
Status: goproto.Int64(consts.ImageAudit_ForAlignment),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package logic
|
|||
|
||||
import (
|
||||
"service/api/consts"
|
||||
alignedaudittaskproto "service/api/proto/alignedaudittask/proto"
|
||||
imageaudittaskproto "service/api/proto/imageaudittask/proto"
|
||||
"service/app/mix/dao"
|
||||
"service/dbstruct"
|
||||
|
@ -64,6 +65,15 @@ func (p *ImageAuditTask) OpList(ctx *gin.Context, req *imageaudittaskproto.OpLis
|
|||
return list, nil
|
||||
}
|
||||
|
||||
func (p *ImageAuditTask) OpListAligned(ctx *gin.Context, req *alignedaudittaskproto.OpListReq) ([]*dbstruct.ImageAuditTask, error) {
|
||||
list, err := p.store.GetAlignedImageAuditTaskList(ctx, req)
|
||||
if err != nil {
|
||||
logger.Error("GetAlignedImageAuditTaskList fail, err: %v", err)
|
||||
return make([]*dbstruct.ImageAuditTask, 0), err
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (p *ImageAuditTask) OpUpdateByBatchId(ctx *gin.Context, batchId string, imageaudittask *dbstruct.ImageAuditTask) error {
|
||||
err := p.store.UpdateImageAuditTaskByBatchId(ctx, batchId, imageaudittask)
|
||||
if err != nil {
|
||||
|
|
|
@ -2,6 +2,7 @@ package logic
|
|||
|
||||
import (
|
||||
"service/api/consts"
|
||||
alignedaudittaskproto "service/api/proto/alignedaudittask/proto"
|
||||
textaudittaskproto "service/api/proto/textaudittask/proto"
|
||||
"service/app/mix/dao"
|
||||
"service/dbstruct"
|
||||
|
@ -64,6 +65,15 @@ func (p *TextAuditTask) OpList(ctx *gin.Context, req *textaudittaskproto.OpListR
|
|||
return list, nil
|
||||
}
|
||||
|
||||
func (p *TextAuditTask) OpListAligned(ctx *gin.Context, req *alignedaudittaskproto.OpListReq) ([]*dbstruct.TextAuditTask, error) {
|
||||
list, err := p.store.GetAlignedTextAuditTaskList(ctx, req)
|
||||
if err != nil {
|
||||
logger.Error("GetAlignedTextAuditTaskList fail, err: %v", err)
|
||||
return make([]*dbstruct.TextAuditTask, 0), err
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (p *TextAuditTask) OpUpdateByBatchId(ctx *gin.Context, batchId string, textaudittask *dbstruct.TextAuditTask) error {
|
||||
err := p.store.UpdateTextAuditTaskByBatchId(ctx, batchId, textaudittask)
|
||||
if err != nil {
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"service/api/errcode"
|
||||
accountproto "service/api/proto/account/proto"
|
||||
accountrelationproto "service/api/proto/accountrelation/proto"
|
||||
alignedaudittaskproto "service/api/proto/alignedaudittask/proto"
|
||||
appconfigproto "service/api/proto/app_config/proto"
|
||||
callhistoryproto "service/api/proto/callhistory/proto"
|
||||
contact_customer_service_proto "service/api/proto/contact_customer_service/proto"
|
||||
|
@ -1068,6 +1069,23 @@ func (s *Service) OpPassTextAuditTaskBatchBusinessValidate(ctx *gin.Context, req
|
|||
return
|
||||
}
|
||||
|
||||
func (s *Service) OpGetAlignedAuditTaskVOListBusinessValidate(ctx *gin.Context, req *alignedaudittaskproto.OpListReq) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeAlignedAuditTaskSrvOk
|
||||
|
||||
// 1.业务校验
|
||||
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
||||
QueryAccount(_DefaultAccount.OpListByMid).
|
||||
EnsureAccountExist().
|
||||
EnsureIsOpRole().
|
||||
Validate().
|
||||
Collect()
|
||||
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
||||
logger.Error("OpGetAlignedAuditTaskVOList business validation failed")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Service) OpCreateContactCustomerServiceSessionBusinessValidate(ctx *gin.Context, req *contact_customer_service_sessionproto.OpCreateReq) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeContactCustomerServiceSessionSrvOk
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"service/api/errs"
|
||||
accountproto "service/api/proto/account/proto"
|
||||
accountrelationproto "service/api/proto/accountrelation/proto"
|
||||
alignedaudittaskproto "service/api/proto/alignedaudittask/proto"
|
||||
appconfigproto "service/api/proto/app_config/proto"
|
||||
bannerproto "service/api/proto/banner/proto"
|
||||
callhistoryproto "service/api/proto/callhistory/proto"
|
||||
|
@ -18,7 +19,6 @@ import (
|
|||
daily_statementproto "service/api/proto/daily_statement/proto"
|
||||
feedbackproto "service/api/proto/feedback/proto"
|
||||
footprintproto "service/api/proto/footprint/proto"
|
||||
imageauditproto "service/api/proto/imageaudit/proto"
|
||||
imageaudittaskproto "service/api/proto/imageaudittask/proto"
|
||||
loginproto "service/api/proto/login/proto"
|
||||
mediaproto "service/api/proto/media/proto"
|
||||
|
@ -29,7 +29,6 @@ import (
|
|||
streamerproto "service/api/proto/streamer/proto"
|
||||
streamerauthapprovalproto "service/api/proto/streamerauthapproval/proto"
|
||||
streamerlinkproto "service/api/proto/streamerlink/proto"
|
||||
textauditproto "service/api/proto/textaudit/proto"
|
||||
textaudittaskproto "service/api/proto/textaudittask/proto"
|
||||
thumbsupproto "service/api/proto/thumbsup/proto"
|
||||
tokenproto "service/api/proto/token/proto"
|
||||
|
@ -2464,24 +2463,10 @@ func (s *Service) OpGetImageAuditTaskVOList(ctx *gin.Context, req *imageaudittas
|
|||
volist[i] = &imageaudittaskproto.ImageAuditTaskVO{
|
||||
ImageAuditTask: task,
|
||||
}
|
||||
if util.DerefInt64(task.IsFragmented) == 1 {
|
||||
imageaudits, err := _DefaultImageAudit.GetListByIds(ctx, util.DerefStringSlice(task.ImageAuditFragmentIds))
|
||||
if err != nil {
|
||||
logger.Error("GetListByIds fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeImageAuditSrvFail
|
||||
return
|
||||
}
|
||||
volist[i].CopyImageAudits(imageaudits)
|
||||
} else {
|
||||
imageaudit, err := _DefaultImageAudit.OpList(ctx, &imageauditproto.OpListReq{
|
||||
Id: task.ImageAuditId,
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error("OpList fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeImageAuditSrvFail
|
||||
return
|
||||
}
|
||||
volist[i].CopyImageAudits([]*dbstruct.ImageAudit{imageaudit})
|
||||
if err := s.utilFillImageAuditTaskVO(ctx, volist[i]); err != nil {
|
||||
logger.Error("utilFillImageAuditTaskVO fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeImageAuditSrvFail
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2538,15 +2523,11 @@ func (s *Service) OpGetTextAuditTaskVOList(ctx *gin.Context, req *textaudittaskp
|
|||
volist[i] = &textaudittaskproto.TextAuditTaskVO{
|
||||
TextAuditTask: task,
|
||||
}
|
||||
textaudit, err := _DefaultTextAudit.OpList(ctx, &textauditproto.OpListReq{
|
||||
Id: task.TextAuditId,
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error("OpList fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeTextAuditSrvFail
|
||||
if err := s.utilFillTextAuditTaskVO(ctx, volist[i]); err != nil {
|
||||
logger.Error("utilFillTextAuditTaskVO fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeImageAuditSrvFail
|
||||
return
|
||||
}
|
||||
volist[i].CopyTextAudit(textaudit)
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -2583,6 +2564,63 @@ func (s *Service) OpPassTextAuditTaskBatch(ctx *gin.Context, req *textaudittaskp
|
|||
return
|
||||
}
|
||||
|
||||
func (s *Service) OpGetAlignedAuditTaskVOList(ctx *gin.Context, req *alignedaudittaskproto.OpListReq) (volist []*alignedaudittaskproto.AlignedAuditTaskVO, ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeAlignedAuditTaskSrvOk
|
||||
|
||||
if ec = s.OpGetAlignedAuditTaskVOListBusinessValidate(ctx, req); ec != errcode.ErrCodeAlignedAuditTaskSrvOk {
|
||||
return
|
||||
}
|
||||
|
||||
// 分别从图像和文字审核表中查询出符合条件的任务
|
||||
imageAuditTaskList, err := _DefaultImageAuditTask.OpListAligned(ctx, req)
|
||||
if err != nil {
|
||||
logger.Error("OpListAligned fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeImageAuditTaskSrvFail
|
||||
return
|
||||
}
|
||||
|
||||
textAuditTaskList, err := _DefaultTextAuditTask.OpListAligned(ctx, req)
|
||||
if err != nil {
|
||||
logger.Error("OpListAligned fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeTextAuditTaskSrvFail
|
||||
return
|
||||
}
|
||||
|
||||
if len(imageAuditTaskList) != len(textAuditTaskList) {
|
||||
logger.Error("The lengths of aligned tasks do not match! req: %v", util.ToJson(req))
|
||||
ec = errcode.ErrCodeAlignedAuditTaskNotAligned
|
||||
return
|
||||
}
|
||||
|
||||
// 填充内容
|
||||
volist = make([]*alignedaudittaskproto.AlignedAuditTaskVO, len(imageAuditTaskList))
|
||||
for i := range imageAuditTaskList {
|
||||
imageAuditTaskVO := &imageaudittaskproto.ImageAuditTaskVO{
|
||||
ImageAuditTask: imageAuditTaskList[i],
|
||||
}
|
||||
if err := s.utilFillImageAuditTaskVO(ctx, imageAuditTaskVO); err != nil {
|
||||
logger.Error("utilFillImageAuditTaskVO fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeImageAuditSrvFail
|
||||
return
|
||||
}
|
||||
textAuditTaskVO := &textaudittaskproto.TextAuditTaskVO{
|
||||
TextAuditTask: textAuditTaskList[i],
|
||||
}
|
||||
if err := s.utilFillTextAuditTaskVO(ctx, textAuditTaskVO); err != nil {
|
||||
logger.Error("utilFillTextAuditTaskVO fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeTextAuditSrvFail
|
||||
return
|
||||
}
|
||||
volist[i] = &alignedaudittaskproto.AlignedAuditTaskVO{
|
||||
ImageAuditTaskVO: imageAuditTaskVO,
|
||||
TextAuditTaskVO: textAuditTaskVO,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ContactCustomerServiceSession
|
||||
func (s *Service) OpCreateContactCustomerServiceSession(ctx *gin.Context, req *contact_customer_service_sessionproto.OpCreateReq) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeContactCustomerServiceSessionSrvOk
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"service/api/consts"
|
||||
"service/dbstruct"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -61,6 +62,7 @@ func (s *Service) CreateUpdateStreamerTextAudit(ctx *gin.Context, oldStreamer *d
|
|||
|
||||
func (s *Service) CreateMomentTextAudit(ctx *gin.Context, newMoment *dbstruct.Moment) (tasks []*dbstruct.TextAuditTask) {
|
||||
|
||||
// 内容为空,则创建一个对齐任务,保证Moment所有图像和文字审核均对齐,便于后续查询
|
||||
if newMoment.Text != nil {
|
||||
tasks = append(tasks, &dbstruct.TextAuditTask{
|
||||
RouteUrl: goproto.String(ctx.Request.URL.Path),
|
||||
|
@ -70,6 +72,19 @@ func (s *Service) CreateMomentTextAudit(ctx *gin.Context, newMoment *dbstruct.Mo
|
|||
AssociativeTableColumn: goproto.String("text"),
|
||||
AuditedText: newMoment.Text,
|
||||
OldText: nil,
|
||||
IsAligned: goproto.Int64(consts.TextAuditIsAligned_Yes),
|
||||
})
|
||||
} else {
|
||||
tasks = append(tasks, &dbstruct.TextAuditTask{
|
||||
RouteUrl: goproto.String(ctx.Request.URL.Path),
|
||||
AssociativeDatabase: goproto.String("moment"),
|
||||
AssociativeTableName: goproto.String("moment"),
|
||||
AssociativeTableId: newMoment.Id,
|
||||
AssociativeTableColumn: goproto.String("text"),
|
||||
AuditedText: newMoment.Text,
|
||||
OldText: nil,
|
||||
IsAligned: goproto.Int64(consts.TextAuditIsAligned_Yes),
|
||||
Status: goproto.Int64(consts.TextAudit_ForAlignment),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -8,10 +8,14 @@ import (
|
|||
accountproto "service/api/proto/account/proto"
|
||||
accountrelationproto "service/api/proto/accountrelation/proto"
|
||||
contact_customer_service_sessionproto "service/api/proto/contact_customer_service_session/proto"
|
||||
imageauditproto "service/api/proto/imageaudit/proto"
|
||||
imageaudittaskproto "service/api/proto/imageaudittask/proto"
|
||||
loginproto "service/api/proto/login/proto"
|
||||
momentproto "service/api/proto/moment/proto"
|
||||
streamerproto "service/api/proto/streamer/proto"
|
||||
streamerlinkproto "service/api/proto/streamerlink/proto"
|
||||
textauditproto "service/api/proto/textaudit/proto"
|
||||
textaudittaskproto "service/api/proto/textaudittask/proto"
|
||||
thumbsupproto "service/api/proto/thumbsup/proto"
|
||||
"service/bizcommon/util"
|
||||
"service/dbstruct"
|
||||
|
@ -447,3 +451,44 @@ func (s *Service) utilFillIsThumbedUpFillable(ctx *gin.Context, visitorMid int64
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) utilFillImageAuditTaskVO(ctx *gin.Context, vo *imageaudittaskproto.ImageAuditTaskVO) error {
|
||||
task := vo.ImageAuditTask
|
||||
if task.IsForAlignment() {
|
||||
return nil
|
||||
}
|
||||
if util.DerefInt64(task.IsFragmented) == 1 {
|
||||
imageaudits, err := _DefaultImageAudit.GetListByIds(ctx, util.DerefStringSlice(task.ImageAuditFragmentIds))
|
||||
if err != nil {
|
||||
logger.Error("GetListByIds fail, err: %v", err)
|
||||
return err
|
||||
}
|
||||
vo.CopyImageAudits(imageaudits)
|
||||
} else {
|
||||
imageaudit, err := _DefaultImageAudit.OpList(ctx, &imageauditproto.OpListReq{
|
||||
Id: task.ImageAuditId,
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error("OpList fail, err: %v", err)
|
||||
return err
|
||||
}
|
||||
vo.CopyImageAudits([]*dbstruct.ImageAudit{imageaudit})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) utilFillTextAuditTaskVO(ctx *gin.Context, vo *textaudittaskproto.TextAuditTaskVO) error {
|
||||
task := vo.TextAuditTask
|
||||
if task.IsForAlignment() {
|
||||
return nil
|
||||
}
|
||||
textaudit, err := _DefaultTextAudit.OpList(ctx, &textauditproto.OpListReq{
|
||||
Id: task.TextAuditId,
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error("OpList fail, err: %v", err)
|
||||
return err
|
||||
}
|
||||
vo.CopyTextAudit(textaudit)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package dbstruct
|
||||
|
||||
import "service/bizcommon/util"
|
||||
import (
|
||||
"service/api/consts"
|
||||
"service/bizcommon/util"
|
||||
)
|
||||
|
||||
type ImageAuditTask struct {
|
||||
Id *string `json:"id" bson:"_id"` // 图像审核任务表id
|
||||
|
@ -16,6 +19,7 @@ type ImageAuditTask struct {
|
|||
FragmentsNum *int64 `json:"fragments_num" bson:"fragments_num"` // 分片数量
|
||||
ImageAuditId *string `json:"image_audit_id" bson:"image_audit_id"` // 图像审核表id(未分片时通过该id关联图像审核表)
|
||||
ImageAuditFragmentIds *[]string `json:"image_audit_fragment_ids" bson:"image_audit_fragment_ids"` // 图像审核表分片id(分片时通过该id关联图像审核表)
|
||||
IsAligned *int64 `json:"is_aligned" bson:"is_aligned"` // 是否已经对齐(详见consts->status->aligned)
|
||||
Status *int64 `json:"status" bson:"status"` // 审核状态
|
||||
Remarks *string `json:"remarks" bson:"remarks"` // 备注
|
||||
Ct *int64 `json:"ct" bson:"ct"` // 创建时间
|
||||
|
@ -30,3 +34,10 @@ func (p *ImageAuditTask) IsEmpty() bool {
|
|||
return p.Id == nil || p.AuditedMedia.IsEmpty() || util.DerefString(p.AssociativeDatabase) == "" || util.DerefString(p.AssociativeTableName) == "" ||
|
||||
p.AssociativeTableId == nil || util.DerefString(p.AssociativeTableColumn) == ""
|
||||
}
|
||||
|
||||
func (p *ImageAuditTask) IsForAlignment() bool {
|
||||
if p == nil || p.Status == nil {
|
||||
return false
|
||||
}
|
||||
return util.DerefInt64(p.Status) == consts.ImageAudit_ForAlignment
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package dbstruct
|
||||
|
||||
import "service/bizcommon/util"
|
||||
import (
|
||||
"service/api/consts"
|
||||
"service/bizcommon/util"
|
||||
)
|
||||
|
||||
type TextAuditTask struct {
|
||||
Id *string `json:"id" bson:"_id"` // 文字审核任务表id
|
||||
|
@ -13,6 +16,7 @@ type TextAuditTask struct {
|
|||
AssociativeTableColumn *string `json:"associative_table_column" bson:"associative_table_column"` // 关联表字段
|
||||
BatchId *string `json:"batch_id" bson:"batch_id"` // 批次号
|
||||
TextAuditId *string `json:"text_audit_id" bson:"text_audit_id"` // 关联文字审核Id号
|
||||
IsAligned *int64 `json:"is_aligned" bson:"is_aligned"` // 是否已经对齐(详见consts->status->aligned)
|
||||
Status *int64 `json:"status" bson:"status"` // 审核状态
|
||||
Remarks *string `json:"remarks" bson:"remarks"` // 备注
|
||||
Ct *int64 `json:"ct" bson:"ct"` // 创建时间
|
||||
|
@ -28,3 +32,10 @@ func (p *TextAuditTask) IsEmpty() bool {
|
|||
return p.Id == nil || p.AuditedText == nil || util.DerefString(p.AssociativeDatabase) == "" || util.DerefString(p.AssociativeTableName) == "" ||
|
||||
p.AssociativeTableId == nil || util.DerefString(p.AssociativeTableColumn) == ""
|
||||
}
|
||||
|
||||
func (p *TextAuditTask) IsForAlignment() bool {
|
||||
if p == nil || p.Status == nil {
|
||||
return false
|
||||
}
|
||||
return util.DerefInt64(p.Status) == consts.TextAudit_ForAlignment
|
||||
}
|
||||
|
|
|
@ -23,32 +23,35 @@ func AddTasks(tasks []*dbstruct.ImageAuditTask) error {
|
|||
}
|
||||
|
||||
func AddTask(task *dbstruct.ImageAuditTask) error {
|
||||
if task == nil || task.AuditedMedia == nil {
|
||||
return nil
|
||||
}
|
||||
fragmentNum := len(task.AuditedMedia.GetImageIds())
|
||||
if fragmentNum == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
task.BatchId = goproto.String(defaultImageAuditTaskScheduler.batchId)
|
||||
task.Status = goproto.Int64(consts.ImageAudit_Created)
|
||||
|
||||
if fragmentNum == 1 {
|
||||
task.IsFragmented = goproto.Int64(0)
|
||||
task.FragmentsNum = goproto.Int64(1)
|
||||
|
||||
// 写入图像审核表
|
||||
if err := prepareNotFragmentedImageAuditTask(task); err != nil {
|
||||
return err
|
||||
// 若非对齐任务,则进行插入前预处理
|
||||
if !task.IsForAlignment() {
|
||||
if task == nil || task.AuditedMedia == nil {
|
||||
return nil
|
||||
}
|
||||
fragmentNum := len(task.AuditedMedia.GetImageIds())
|
||||
if fragmentNum == 0 {
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
task.IsFragmented = goproto.Int64(1)
|
||||
task.FragmentsNum = goproto.Int64(int64(fragmentNum))
|
||||
|
||||
// 写入图像审核表
|
||||
if err := prepareFragmentedImageAuditTask(task); err != nil {
|
||||
return err
|
||||
task.BatchId = goproto.String(defaultImageAuditTaskScheduler.batchId)
|
||||
task.Status = goproto.Int64(consts.ImageAudit_Created)
|
||||
|
||||
if fragmentNum == 1 {
|
||||
task.IsFragmented = goproto.Int64(0)
|
||||
task.FragmentsNum = goproto.Int64(1)
|
||||
|
||||
// 写入图像审核表
|
||||
if err := prepareNotFragmentedImageAuditTask(task); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
task.IsFragmented = goproto.Int64(1)
|
||||
task.FragmentsNum = goproto.Int64(int64(fragmentNum))
|
||||
|
||||
// 写入图像审核表
|
||||
if err := prepareFragmentedImageAuditTask(task); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,30 +22,33 @@ func AddTasks(tasks []*dbstruct.TextAuditTask) error {
|
|||
}
|
||||
|
||||
func AddTask(task *dbstruct.TextAuditTask) error {
|
||||
if task == nil || task.AuditedText == nil {
|
||||
return nil
|
||||
// 若非对齐任务,则进行插入前预处理
|
||||
if !task.IsForAlignment() {
|
||||
if task == nil || task.AuditedText == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
task.BatchId = goproto.String(defaultTextAuditTaskScheduler.batchId)
|
||||
task.Status = goproto.Int64(consts.TextAudit_Created)
|
||||
|
||||
// 1.写入文字审核表
|
||||
ctx := &gin.Context{}
|
||||
|
||||
textAudit := &dbstruct.TextAudit{
|
||||
AuditedText: task.AuditedText,
|
||||
BatchId: task.BatchId,
|
||||
Status: goproto.Int64(consts.TextAudit_Created),
|
||||
}
|
||||
if err := _DefaultTextAudit.OpCreate(ctx, &textauditproto.OpCreateReq{
|
||||
TextAudit: textAudit,
|
||||
}); err != nil {
|
||||
logger.Error("Textaudit OpCreate failed: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
task.TextAuditId = textAudit.Id
|
||||
}
|
||||
|
||||
task.BatchId = goproto.String(defaultTextAuditTaskScheduler.batchId)
|
||||
task.Status = goproto.Int64(consts.TextAudit_Created)
|
||||
|
||||
// 1.写入文字审核表
|
||||
ctx := &gin.Context{}
|
||||
|
||||
textAudit := &dbstruct.TextAudit{
|
||||
AuditedText: task.AuditedText,
|
||||
BatchId: task.BatchId,
|
||||
Status: goproto.Int64(consts.TextAudit_Created),
|
||||
}
|
||||
if err := _DefaultTextAudit.OpCreate(ctx, &textauditproto.OpCreateReq{
|
||||
TextAudit: textAudit,
|
||||
}); err != nil {
|
||||
logger.Error("Textaudit OpCreate failed: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
task.TextAuditId = textAudit.Id
|
||||
|
||||
// 2.写入文字审核任务表
|
||||
if err := _DefaultTextAuditTask.OpCreate(&gin.Context{}, &textaudittaskproto.OpCreateReq{
|
||||
TextAuditTask: task,
|
||||
|
|
Loading…
Reference in New Issue