Merge pull request 'conf' (#394) from conf into test
Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/394
This commit is contained in:
commit
4019cf0dd1
|
@ -51,8 +51,8 @@ const (
|
|||
DefaultMomentTextKey = "default_moment_text"
|
||||
MaxDailyZoneMomentCreateTimesKey = "max_daily_zone_moment_create_times"
|
||||
ReferentialZoneMomentKey = "referential_zone_moment"
|
||||
RestrictedVisitorMomentKey = "restricted_visitor_moment"
|
||||
IsMomentImageEncryptEnabledKey = "is_moment_image_encrypt_enabled"
|
||||
RestrictedVisitorMomentKey = "restricted_visitor_moment"
|
||||
)
|
||||
|
||||
// del_flag
|
||||
|
|
|
@ -2,6 +2,7 @@ package proto
|
|||
|
||||
import (
|
||||
"service/api/consts"
|
||||
"service/bizcommon/util"
|
||||
"service/library/validator"
|
||||
)
|
||||
|
||||
|
@ -9,10 +10,42 @@ func (p *OpCreateReq) ProvideNotNullValue() (params []*validator.JsonParam) {
|
|||
params = make([]*validator.JsonParam, 0)
|
||||
|
||||
params = append(params, validator.NewInt64PtrParam("请确认创建动态的所属空间id!", p.ZoneMoment.Zid))
|
||||
params = append(params, validator.NewInt64PtrParam("请确认创建动态的可见范围!", p.ZoneMoment.Status))
|
||||
params = append(params, validator.NewInt64PtrParam("请确认创建动态的可见范围!", p.ZoneMoment.CType))
|
||||
params = append(params, validator.NewInt64PtrParam("请确认创建动态的媒体类型!", p.ZoneMoment.MType))
|
||||
params = append(params, validator.NewStringPtrParam("请确认创建动态的文案!", p.Text))
|
||||
params = append(params, validator.NewStructPtrParam("请确认创建动态的媒体!", p.MediaComp))
|
||||
|
||||
switch util.DerefInt64(p.ZoneMoment.CType) {
|
||||
case consts.ZoneMomentCType_Paid:
|
||||
params = append(params, validator.NewInt64PtrParam("请确认创建动态的文字可见范围!", p.ZoneMoment.TextVisibleRange))
|
||||
params = append(params, validator.NewInt64PtrParam("请确认创建动态的价格!", p.ZoneMoment.Price))
|
||||
switch util.DerefInt64(p.ZoneMoment.MType) {
|
||||
case consts.MediaTypeImg:
|
||||
params = append(params, validator.NewInt64PtrParam("请确认创建动态的媒体可见范围!", p.ZoneMoment.MediaVisibleRange))
|
||||
case consts.MediaTypeVideo:
|
||||
params = append(params, validator.NewInt64PtrParam("请确认创建动态是否要模糊封面!", p.ZoneMoment.IsBlurringCover))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (p *OpUpdateReq) ProvideNotNullValue() (params []*validator.JsonParam) {
|
||||
params = make([]*validator.JsonParam, 0)
|
||||
|
||||
params = append(params, validator.NewInt64PtrParam("请确认创建动态的可见范围!", p.ZoneMoment.CType))
|
||||
params = append(params, validator.NewInt64PtrParam("请确认创建动态的媒体类型!", p.ZoneMoment.MType))
|
||||
|
||||
switch util.DerefInt64(p.ZoneMoment.CType) {
|
||||
case consts.ZoneMomentCType_Paid:
|
||||
if p.Text != nil {
|
||||
params = append(params, validator.NewStringPtrParam("请确认创建动态的文案!", p.Text))
|
||||
}
|
||||
if p.MediaComp != nil {
|
||||
params = append(params, validator.NewStructPtrParam("请确认创建动态的媒体!", p.MediaComp))
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -3255,23 +3255,89 @@ func (s *Service) OpCreateZoneMoment(ctx *gin.Context, req *zonemomentproto.OpCr
|
|||
req.ZoneMoment.ImageAuditStatus = goproto.Int64(consts.ImageAudit_Created) // 创建
|
||||
req.ZoneMoment.MediaAmount = goproto.Int64(int64(len(req.ZoneMoment.MediaComp.GetImageIds())))
|
||||
} else {
|
||||
req.ZoneMoment.ImageAuditStatus = goproto.Int64(consts.ImageAudit_Passed) // 视频贴默认已通过
|
||||
req.ZoneMoment.ImageAuditStatus = goproto.Int64(consts.VideoModeration_Created)
|
||||
req.ZoneMoment.MediaAmount = goproto.Int64(int64(len(req.ZoneMoment.MediaComp.GetVideoIds())))
|
||||
}
|
||||
req.ZoneMoment.TextAuditStatus = goproto.Int64(consts.TextAudit_Created) // 创建
|
||||
req.ZoneMoment.ManuallyReviewStatus = goproto.Int64(consts.ZoneMomentManuallyReview_Waiting) // 等待复审
|
||||
_, err := _DefaultZoneMoment.OpCreate(ctx, req)
|
||||
|
||||
momentId, err := _DefaultZoneMoment.OpCreate(ctx, req)
|
||||
if err != nil {
|
||||
logger.Error("OpCreate fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeZoneMomentSrvFail
|
||||
return
|
||||
}
|
||||
|
||||
// 添加审核任务
|
||||
imageaudittasks := s.CreateZoneMomentImageAudit(ctx, req.ZoneMoment)
|
||||
textaudittasks := s.CreateZoneMomentTextAudit(ctx, req.ZoneMoment)
|
||||
videomoderationtasks := s.CreateZoneMomentVideoModeration(ctx, req.ZoneMoment)
|
||||
imageaudit.AddTasks(imageaudittasks)
|
||||
textaudit.AddTasks(textaudittasks)
|
||||
videomoderation.AddTasks(videomoderationtasks)
|
||||
|
||||
// 设置价格
|
||||
if req.ZoneMoment.GetCType() == consts.ZoneMomentCType_Paid {
|
||||
err = _DefaultVas.UpdateZoneMomentPrice(ctx, &vasproto.UpdateZoneMomentPriceReq{
|
||||
ZoneMomentPrice: &dbstruct.ZoneMomentPrice{
|
||||
MomentId: momentId,
|
||||
Zid: *req.ZoneMoment.Zid,
|
||||
Mid: *req.ZoneMoment.Mid,
|
||||
Price: *req.ZoneMoment.Price,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error("UpdateZoneMomentPrice fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeZoneMomentSrvFail
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Service) OpUpdateZoneMoment(ctx *gin.Context, req *zonemomentproto.OpUpdateReq) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeZoneMomentSrvOk
|
||||
err := _DefaultZoneMoment.OpUpdate(ctx, req)
|
||||
|
||||
zonemoment, err := _DefaultZoneMoment.GetById(ctx, req.ZoneMoment.GetId())
|
||||
if err != nil {
|
||||
logger.Error("_DefaultZoneMoment GetById fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeZoneMomentSrvFail
|
||||
return
|
||||
}
|
||||
if zonemoment == nil {
|
||||
ec = errcode.ErrCodeZoneMomentNotExist
|
||||
return
|
||||
}
|
||||
|
||||
zmStatus := zonemoment.GetStatus()
|
||||
|
||||
// 抹消审核信息,回退到初始
|
||||
isReauditRequired := false
|
||||
if req.ZoneMoment.MediaComp != nil && req.ZoneMoment.GetMType() == consts.MediaTypeImg {
|
||||
isReauditRequired = true
|
||||
req.ZoneMoment.ImageAuditStatus = goproto.Int64(consts.ImageAudit_Created) // 创建
|
||||
req.ZoneMoment.ImageAuditOpinion = goproto.String("") // 信息抹除
|
||||
req.ZoneMoment.MediaAmount = goproto.Int64(int64(len(req.ZoneMoment.MediaComp.GetImageIds())))
|
||||
}
|
||||
if req.ZoneMoment.MediaComp != nil && req.ZoneMoment.GetMType() == consts.MediaTypeVideo {
|
||||
req.ZoneMoment.ImageAuditStatus = goproto.Int64(consts.VideoModeration_Created) // 创建
|
||||
req.ZoneMoment.ImageAuditOpinion = goproto.String("") // 信息抹除
|
||||
req.ZoneMoment.MediaAmount = goproto.Int64(int64(len(req.ZoneMoment.MediaComp.GetVideoIds())))
|
||||
}
|
||||
if req.ZoneMoment.Text != nil {
|
||||
isReauditRequired = true
|
||||
req.ZoneMoment.TextAuditStatus = goproto.Int64(consts.TextAudit_Created) // 创建
|
||||
req.ZoneMoment.TextAuditOpinion = goproto.String("") // 信息抹除
|
||||
}
|
||||
|
||||
if isReauditRequired {
|
||||
req.ZoneMoment.Status = goproto.Int64(consts.ZoneMoment_Auditing) // 正在审核中
|
||||
req.ZoneMoment.ManuallyReviewStatus = goproto.Int64(consts.ZoneMomentManuallyReview_Waiting) // 等待复审
|
||||
req.ZoneMoment.ManuallyReviewOpinion = goproto.String("") // 信息抹除
|
||||
req.ZoneMoment.ManuallyReviewOperator = goproto.Int64(0) // 信息抹除
|
||||
}
|
||||
|
||||
err = _DefaultZoneMoment.OpUpdate(ctx, req)
|
||||
if err == qmgo.ErrNoSuchDocuments {
|
||||
ec = errcode.ErrCodeZoneMomentNotExist
|
||||
err = nil
|
||||
|
@ -3282,6 +3348,27 @@ func (s *Service) OpUpdateZoneMoment(ctx *gin.Context, req *zonemomentproto.OpUp
|
|||
ec = errcode.ErrCodeZoneMomentSrvFail
|
||||
return
|
||||
}
|
||||
|
||||
// 回退空间内统计总数,只回退公开的情况
|
||||
if zmStatus == consts.ZoneMoment_Public && isReauditRequired {
|
||||
mediaCountInc := len(zonemoment.MediaComp.GetImageIds())
|
||||
videoCountInc := len(zonemoment.MediaComp.GetVideoIds())
|
||||
err := _DefaultZone.RecordStatisticsById(ctx, zonemoment.GetZid(), -1, -int64(mediaCountInc), -int64(videoCountInc))
|
||||
if err != nil {
|
||||
logger.Error("RecordStatisticsById fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeZoneSrvFail
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 添加审核任务
|
||||
imageaudittasks := s.CreateZoneMomentImageAudit(ctx, req.ZoneMoment)
|
||||
textaudittasks := s.CreateZoneMomentTextAudit(ctx, req.ZoneMoment)
|
||||
videomoderationtasks := s.CreateZoneMomentVideoModeration(ctx, req.ZoneMoment)
|
||||
imageaudit.AddTasks(imageaudittasks)
|
||||
textaudit.AddTasks(textaudittasks)
|
||||
videomoderation.AddTasks(videomoderationtasks)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -3328,7 +3415,7 @@ func (s *Service) OpDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.OpDe
|
|||
Id: goproto.Int64(zid),
|
||||
LastZoneMomentCt: goproto.Int64(0),
|
||||
},
|
||||
}, util.DerefInt64(zone.LastZoneMomentCt))
|
||||
}, zone.GetLastZoneMomentCt())
|
||||
if err != nil {
|
||||
logger.Error("OpUpdate fail, err: %v", err)
|
||||
ec = errcode.ErrCodeZoneMomentSrvFail
|
||||
|
@ -3337,13 +3424,13 @@ func (s *Service) OpDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.OpDe
|
|||
} else {
|
||||
//还有动态,看最后一条更新的动态的更新时间是否比删除的那条动态更早,若更早,则需要把空间的更新时间回拨
|
||||
lastzonemoment := list[0]
|
||||
if util.DerefInt64(lastzonemoment.Ut) < util.DerefInt64(zonemoment.Ut) {
|
||||
if lastzonemoment.GetUt() < zonemoment.GetUt() {
|
||||
err = _DefaultZone.OpUpdateByIdAndLastZoneMomentCt(ctx, &zoneproto.OpUpdateReq{
|
||||
Zone: &dbstruct.Zone{
|
||||
Id: goproto.Int64(zid),
|
||||
LastZoneMomentCt: lastzonemoment.Ut,
|
||||
},
|
||||
}, util.DerefInt64(zone.LastZoneMomentCt))
|
||||
}, zone.GetLastZoneMomentCt())
|
||||
if err != nil {
|
||||
logger.Error("OpUpdate fail, err: %v", err)
|
||||
ec = errcode.ErrCodeZoneMomentSrvFail
|
||||
|
@ -3352,15 +3439,18 @@ func (s *Service) OpDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.OpDe
|
|||
}
|
||||
}
|
||||
|
||||
// 回退空间内统计总数
|
||||
// 回退空间内统计总数,只回退公开的情况
|
||||
if zonemoment.GetStatus() == consts.ZoneMoment_Public {
|
||||
mediaCountInc := len(zonemoment.MediaComp.GetImageIds())
|
||||
videoCountInc := len(zonemoment.MediaComp.GetVideoIds())
|
||||
err = _DefaultZone.RecordStatisticsById(ctx, util.DerefInt64(zonemoment.Zid), -1, -int64(mediaCountInc), -int64(videoCountInc))
|
||||
err = _DefaultZone.RecordStatisticsById(ctx, zonemoment.GetZid(), -1, -int64(mediaCountInc), -int64(videoCountInc))
|
||||
if err != nil {
|
||||
logger.Error("RecordStatisticsById fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeZoneSrvFail
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -115,13 +115,21 @@ func handleVideoModeration(result *green20220302.VideoModerationResultResponseBo
|
|||
audioResult := result.Data.AudioResult
|
||||
|
||||
// 解析信息
|
||||
frameSummaries, isFramesPassed := buildFrameSummaries(frameResult.FrameSummarys)
|
||||
isFramesPassed := true
|
||||
isAudioPassed := true
|
||||
if frameResult != nil {
|
||||
var frameSummaries []*dbstruct.FrameSummary
|
||||
frameSummaries, isFramesPassed = buildFrameSummaries(frameResult.FrameSummarys)
|
||||
frameDetails := buildFrameDetails(frameResult.Frames)
|
||||
audioSummaries, isAudioPassed := buildAudioSummaries(audioResult.AudioSummarys)
|
||||
audioDetails := buildAudioDetails(result.Data.AudioResult.SliceDetails)
|
||||
|
||||
videomoderation.SetFrameSummaries(frameSummaries).SetFrameDetails(frameDetails)
|
||||
videomoderation.FrameNum = frameResult.FrameNum
|
||||
videomoderation.SetFrameSummaries(frameSummaries).SetFrameDetails(frameDetails).SetAudioSummaries(audioSummaries).SetAudioDetails(audioDetails)
|
||||
}
|
||||
if audioResult != nil {
|
||||
var audioSummaries []*dbstruct.AudioSummary
|
||||
audioSummaries, isAudioPassed = buildAudioSummaries(audioResult.AudioSummarys)
|
||||
audioDetails := buildAudioDetails(audioResult.SliceDetails)
|
||||
videomoderation.SetAudioSummaries(audioSummaries).SetAudioDetails(audioDetails)
|
||||
}
|
||||
|
||||
// 判定检测结果
|
||||
if isFramesPassed && isAudioPassed {
|
||||
|
@ -165,6 +173,7 @@ func buildFrameSummaries(summaries []*green20220302.VideoModerationResultRespons
|
|||
isPassed = true
|
||||
frameSummaries = make([]*dbstruct.FrameSummary, 0)
|
||||
for _, summary := range summaries {
|
||||
if summary != nil {
|
||||
frameSummaries = append(frameSummaries, &dbstruct.FrameSummary{
|
||||
Label: summary.Label,
|
||||
LabelSum: summary.LabelSum,
|
||||
|
@ -173,41 +182,48 @@ func buildFrameSummaries(summaries []*green20220302.VideoModerationResultRespons
|
|||
isPassed = false
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func buildFrameDetails(details []*green20220302.VideoModerationResultResponseBodyDataFrameResultFrames) (frameDetails []*dbstruct.FrameDetail) {
|
||||
frameDetails = make([]*dbstruct.FrameDetail, 0)
|
||||
for _, detail := range details {
|
||||
if detail != nil {
|
||||
frameDetail := &dbstruct.FrameDetail{
|
||||
Offset: detail.Offset,
|
||||
}
|
||||
frameDetail.SetFrameServiceDetails(buildFrameServiceDetails(detail.Results))
|
||||
frameDetails = append(frameDetails, frameDetail)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func buildFrameServiceDetails(details []*green20220302.VideoModerationResultResponseBodyDataFrameResultFramesResults) (frameServiceDetails []*dbstruct.FrameServiceDetail) {
|
||||
frameServiceDetails = make([]*dbstruct.FrameServiceDetail, 0)
|
||||
for _, detail := range details {
|
||||
if detail != nil {
|
||||
frameServiceDetail := &dbstruct.FrameServiceDetail{
|
||||
Service: detail.Service,
|
||||
}
|
||||
frameServiceDetail.SetFrameLabelDetails(buildFrameLabelDetails(detail.Result))
|
||||
frameServiceDetails = append(frameServiceDetails, frameServiceDetail)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func buildFrameLabelDetails(details []*green20220302.VideoModerationResultResponseBodyDataFrameResultFramesResultsResult) (frameLabelDetails []*dbstruct.FrameLabelDetail) {
|
||||
frameLabelDetails = make([]*dbstruct.FrameLabelDetail, 0)
|
||||
for _, detail := range details {
|
||||
if detail != nil {
|
||||
frameLabelDetails = append(frameLabelDetails, &dbstruct.FrameLabelDetail{
|
||||
Confidence: detail.Confidence,
|
||||
Label: detail.Label,
|
||||
})
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -215,6 +231,7 @@ func buildAudioSummaries(summaries []*green20220302.VideoModerationResultRespons
|
|||
isPassed = true
|
||||
audioSummaries = make([]*dbstruct.AudioSummary, 0)
|
||||
for _, summary := range summaries {
|
||||
if summary != nil {
|
||||
audioSummaries = append(audioSummaries, &dbstruct.AudioSummary{
|
||||
Label: summary.Label,
|
||||
LabelSum: summary.LabelSum,
|
||||
|
@ -223,12 +240,14 @@ func buildAudioSummaries(summaries []*green20220302.VideoModerationResultRespons
|
|||
isPassed = false
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func buildAudioDetails(details []*green20220302.VideoModerationResultResponseBodyDataAudioResultSliceDetails) (audioDetails []*dbstruct.AudioDetail) {
|
||||
audioDetails = make([]*dbstruct.AudioDetail, 0)
|
||||
for _, detail := range details {
|
||||
if detail != nil {
|
||||
audioDetails = append(audioDetails, &dbstruct.AudioDetail{
|
||||
EndTime: detail.EndTime,
|
||||
EndTimestamp: detail.EndTimestamp,
|
||||
|
@ -242,6 +261,7 @@ func buildAudioDetails(details []*green20220302.VideoModerationResultResponseBod
|
|||
Text: detail.Text,
|
||||
})
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue