Merge pull request 'feat-IRONFANS-70' (#391) from feat-IRONFANS-70 into main

Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/391
This commit is contained in:
chenhao 2024-05-01 02:35:47 +08:00
commit cf4068ddca
10 changed files with 329 additions and 60 deletions

View File

@ -51,6 +51,7 @@ const (
DefaultMomentTextKey = "default_moment_text"
MaxDailyZoneMomentCreateTimesKey = "max_daily_zone_moment_create_times"
ReferentialZoneMomentKey = "referential_zone_moment"
IsMomentImageEncryptEnabledKey = "is_moment_image_encrypt_enabled"
RestrictedVisitorMomentKey = "restricted_visitor_moment"
)

View File

@ -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
}

View File

@ -73,11 +73,12 @@ type OpListByMidReq struct {
base.BaseRequest
MType *int64 `json:"m_type"` // 媒体类型
Status *int64 `json:"status"` // 状态
CtUpperBound *int64 `json:"ct_upper_bound"` //创建时间上界,闭区间
CtLowerBound *int64 `json:"ct_lower_bound"` //创建时间下界开区间可为0
CtUpperBound *int64 `json:"ct_upper_bound"` // 创建时间上界,闭区间
CtLowerBound *int64 `json:"ct_lower_bound"` // 创建时间下界开区间可为0
Offset int `json:"offset"`
Limit int `json:"limit"`
Sort []string
Uid *int64
}
type OpListByMidData struct {
@ -140,6 +141,27 @@ type OpListByZidResp struct {
Data *OpListByZidData `json:"data"`
}
// op 列表-user_id直查
type OpListByUserIdReq struct {
base.BaseRequest
UserId int64 `json:"user_id"` //user_id
CtUpperBound *int64 `json:"ct_upper_bound"` //创建时间上界,闭区间
CtLowerBound *int64 `json:"ct_lower_bound"` //创建时间下界开区间可为0
Offset int `json:"offset"`
Limit int `json:"limit"`
}
type OpListByUserIdData struct {
ListByUserId []*OpZoneMomentVO `json:"list"`
Offset int `json:"offset"`
More int `json:"more"`
}
type OpListByUserIdResp struct {
base.BaseResponse
Data *OpListByUserIdData `json:"data"`
}
// op 点赞
type OpZoneMomentThumbsUpReq struct {
base.BaseRequest

View File

@ -70,3 +70,14 @@ func OpGetUploadMediaFailConfigList(ctx *gin.Context) {
ReplyOk(ctx, config)
}
func OpGetIsMomentImageEncryptEnabled(ctx *gin.Context) {
isEnabled, ec := service.DefaultConfigService.OpGetIsMomentImageEncryptEnabled(ctx)
if ec != errcode.ErrCodeOk {
logger.Error("OpGetIsMomentImageEncryptEnabled fail, ec: %v", ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, isEnabled)
}

View File

@ -115,6 +115,7 @@ func Init(r *gin.Engine) {
apiMomentGroup.POST("thumbs_up", middleware.JSONParamValidator(momentproto.ApiThumbsUpReq{}), middleware.JwtAuthenticator(), ApiThumbsUpMoment)
apiMomentGroup.POST("list_by_ids", middleware.JSONParamValidator(momentproto.ApiListByIdsReq{}), middleware.JwtAuthenticator(), ApiGetMomentListByIds)
apiMomentGroup.POST("recomm_list", middleware.JSONParamValidator(momentproto.ApiRecommListReq{}), middleware.JwtAuthenticator(), ApiGetMomentRecommList)
apiMomentGroup.POST("is_moment_image_encrypt_enabled", middleware.JSONParamValidator(base.BaseRequest{}), middleware.JwtAuthenticator(), OpGetIsMomentImageEncryptEnabled)
// 足迹
// apiFootPrintGroup := r.Group("/api/footprint", PrepareToC())
@ -505,6 +506,7 @@ func Init(r *gin.Engine) {
opZoneMomentGroup.POST("update", middleware.JSONParamValidator(zonemomentproto.OpUpdateReq{}), middleware.JwtAuthenticator(), OpUpdateZoneMoment)
opZoneMomentGroup.POST("delete", middleware.JSONParamValidator(zonemomentproto.OpDeleteReq{}), middleware.JwtAuthenticator(), OpDeleteZoneMoment)
opZoneMomentGroup.POST("list", middleware.JSONParamValidator(zonemomentproto.OpListReq{}), middleware.JwtAuthenticator(), OpGetZoneMomentList)
opZoneMomentGroup.POST("list_by_user_id", middleware.JSONParamValidator(zonemomentproto.OpListByUserIdReq{}), middleware.JwtAuthenticator(), OpGetZoneMomentListByUserId)
opZoneMomentGroup.POST("review", middleware.JSONParamValidator(zonemomentproto.OpReviewReq{}), middleware.JwtAuthenticator(), OpReviewZoneMoment)
opZoneMomentGroup.POST("head", middleware.JSONParamValidator(zonemomentproto.OpHeadReq{}), middleware.JwtAuthenticator(), OpHeadZoneMoment)

View File

@ -80,6 +80,38 @@ func OpGetZoneMomentList(ctx *gin.Context) {
ReplyOk(ctx, data)
}
func OpGetZoneMomentListByUserId(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*zonemomentproto.OpListByUserIdReq)
//设置默认页长
if req.Limit == 0 {
req.Limit = consts.DefaultPageSize
}
list, ec := service.DefaultService.OpGetZoneMomentListByUserId(ctx, req)
if ec != errcode.ErrCodeZoneMomentSrvOk {
logger.Error("OpGetZoneMomentListByUserId fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
//填充媒体切片
mediaFillableList := make([]mediafiller.MediaFillable, len(list))
for i, media := range list {
mediaFillableList[i] = media.MediaComp
}
mediafiller.FillList(ctx, mediaFillableList)
data := &zonemomentproto.OpListByUserIdData{
ListByUserId: list,
Offset: req.Offset + len(list),
}
if len(list) >= req.Limit {
data.More = 1
}
ReplyOk(ctx, data)
}
func OpReviewZoneMoment(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*zonemomentproto.OpReviewReq)
ec := service.DefaultService.OpReviewZoneMoment(ctx, req)

View File

@ -4204,6 +4204,12 @@ func (m *Mongo) GetZoneMomentListByMid(ctx *gin.Context, req *zonemomentproto.Op
"mid": req.GetBaseRequest().Mid,
"del_flag": 0,
}
if req.Uid != nil {
query["mid"] = util.DerefInt64(req.Uid)
} else {
query["mid"] = req.GetBaseRequest().Mid
}
if req.MType != nil {
query["m_type"] = util.DerefInt64(req.MType)
}

View File

@ -171,3 +171,18 @@ func (s *ConfigService) OpGetUploadMediaFailConfigList(ctx *gin.Context) (upload
return
}
func (s *ConfigService) OpGetIsMomentImageEncryptEnabled(ctx *gin.Context) (isEnabled int64, ec errcode.ErrCode) {
ec = errcode.ErrCodeOk
isMomentImageEncryptEnabled, err := apollo.GetIntValue(consts.IsMomentImageEncryptEnabledKey, apollo.ApolloOpts().SetNamespace("application"))
if err != nil {
logger.Error("Apollo read failed : %v", err)
ec = errcode.ErrCodeApolloReadFail
return
}
isEnabled = int64(isMomentImageEncryptEnabled)
return
}

View File

@ -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
}
}
// 回退空间内统计总数
mediaCountInc := len(zonemoment.MediaComp.GetImageIds())
videoCountInc := len(zonemoment.MediaComp.GetVideoIds())
err = _DefaultZone.RecordStatisticsById(ctx, util.DerefInt64(zonemoment.Zid), -1, -int64(mediaCountInc), -int64(videoCountInc))
if err != nil {
logger.Error("RecordStatisticsById fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeZoneSrvFail
return
// 回退空间内统计总数,只回退公开的情况
if zonemoment.GetStatus() == consts.ZoneMoment_Public {
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
}
}
return
}
@ -3383,6 +3473,43 @@ func (s *Service) OpGetZoneMomentList(ctx *gin.Context, req *zonemomentproto.OpL
return
}
func (s *Service) OpGetZoneMomentListByUserId(ctx *gin.Context, req *zonemomentproto.OpListByUserIdReq) (volist []*zonemomentproto.OpZoneMomentVO, ec errcode.ErrCode) {
ec = errcode.ErrCodeZoneMomentSrvOk
account, err := _DefaultAccount.OpListByUserId(ctx, &accountproto.OpListByUserIdReq{
UserId: goproto.Int64(req.UserId),
})
if err != nil {
logger.Error("_DefaultAccount OpListByUserId fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeAccountSrvFail
return
}
if account == nil {
return
}
list, err := _DefaultZoneMoment.OpListByMid(ctx, &zonemomentproto.OpListByMidReq{
BaseRequest: req.BaseRequest,
Uid: account.Mid,
CtUpperBound: req.CtUpperBound,
CtLowerBound: req.CtLowerBound,
})
if err != nil {
logger.Error("OpGetZoneMomentListByMid fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeZoneMomentSrvFail
return
}
// 填充信息
volist, err = s.utilFillZoneMomentsWithOpVOInfo(ctx, list)
if err != nil {
logger.Error("utilFillZoneMomentsWithOpVOInfo fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeZoneMomentSrvFail
return
}
return
}
func (s *Service) OpReviewZoneMoment(ctx *gin.Context, req *zonemomentproto.OpReviewReq) (ec errcode.ErrCode) {
ec = errcode.ErrCodeZoneMomentSrvOk

View File

@ -115,13 +115,21 @@ func handleVideoModeration(result *green20220302.VideoModerationResultResponseBo
audioResult := result.Data.AudioResult
// 解析信息
frameSummaries, isFramesPassed := buildFrameSummaries(frameResult.FrameSummarys)
frameDetails := buildFrameDetails(frameResult.Frames)
audioSummaries, isAudioPassed := buildAudioSummaries(audioResult.AudioSummarys)
audioDetails := buildAudioDetails(result.Data.AudioResult.SliceDetails)
videomoderation.FrameNum = frameResult.FrameNum
videomoderation.SetFrameSummaries(frameSummaries).SetFrameDetails(frameDetails).SetAudioSummaries(audioSummaries).SetAudioDetails(audioDetails)
isFramesPassed := true
isAudioPassed := true
if frameResult != nil {
var frameSummaries []*dbstruct.FrameSummary
frameSummaries, isFramesPassed = buildFrameSummaries(frameResult.FrameSummarys)
frameDetails := buildFrameDetails(frameResult.Frames)
videomoderation.SetFrameSummaries(frameSummaries).SetFrameDetails(frameDetails)
videomoderation.FrameNum = frameResult.FrameNum
}
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,12 +173,14 @@ func buildFrameSummaries(summaries []*green20220302.VideoModerationResultRespons
isPassed = true
frameSummaries = make([]*dbstruct.FrameSummary, 0)
for _, summary := range summaries {
frameSummaries = append(frameSummaries, &dbstruct.FrameSummary{
Label: summary.Label,
LabelSum: summary.LabelSum,
})
if util.DerefString(summary.Label) != VideoModerationPassLabel {
isPassed = false
if summary != nil {
frameSummaries = append(frameSummaries, &dbstruct.FrameSummary{
Label: summary.Label,
LabelSum: summary.LabelSum,
})
if util.DerefString(summary.Label) != VideoModerationPassLabel {
isPassed = false
}
}
}
return
@ -179,11 +189,13 @@ func buildFrameSummaries(summaries []*green20220302.VideoModerationResultRespons
func buildFrameDetails(details []*green20220302.VideoModerationResultResponseBodyDataFrameResultFrames) (frameDetails []*dbstruct.FrameDetail) {
frameDetails = make([]*dbstruct.FrameDetail, 0)
for _, detail := range details {
frameDetail := &dbstruct.FrameDetail{
Offset: detail.Offset,
if detail != nil {
frameDetail := &dbstruct.FrameDetail{
Offset: detail.Offset,
}
frameDetail.SetFrameServiceDetails(buildFrameServiceDetails(detail.Results))
frameDetails = append(frameDetails, frameDetail)
}
frameDetail.SetFrameServiceDetails(buildFrameServiceDetails(detail.Results))
frameDetails = append(frameDetails, frameDetail)
}
return
}
@ -191,11 +203,13 @@ func buildFrameDetails(details []*green20220302.VideoModerationResultResponseBod
func buildFrameServiceDetails(details []*green20220302.VideoModerationResultResponseBodyDataFrameResultFramesResults) (frameServiceDetails []*dbstruct.FrameServiceDetail) {
frameServiceDetails = make([]*dbstruct.FrameServiceDetail, 0)
for _, detail := range details {
frameServiceDetail := &dbstruct.FrameServiceDetail{
Service: detail.Service,
if detail != nil {
frameServiceDetail := &dbstruct.FrameServiceDetail{
Service: detail.Service,
}
frameServiceDetail.SetFrameLabelDetails(buildFrameLabelDetails(detail.Result))
frameServiceDetails = append(frameServiceDetails, frameServiceDetail)
}
frameServiceDetail.SetFrameLabelDetails(buildFrameLabelDetails(detail.Result))
frameServiceDetails = append(frameServiceDetails, frameServiceDetail)
}
return
}
@ -203,10 +217,12 @@ func buildFrameServiceDetails(details []*green20220302.VideoModerationResultResp
func buildFrameLabelDetails(details []*green20220302.VideoModerationResultResponseBodyDataFrameResultFramesResultsResult) (frameLabelDetails []*dbstruct.FrameLabelDetail) {
frameLabelDetails = make([]*dbstruct.FrameLabelDetail, 0)
for _, detail := range details {
frameLabelDetails = append(frameLabelDetails, &dbstruct.FrameLabelDetail{
Confidence: detail.Confidence,
Label: detail.Label,
})
if detail != nil {
frameLabelDetails = append(frameLabelDetails, &dbstruct.FrameLabelDetail{
Confidence: detail.Confidence,
Label: detail.Label,
})
}
}
return
}
@ -215,12 +231,14 @@ func buildAudioSummaries(summaries []*green20220302.VideoModerationResultRespons
isPassed = true
audioSummaries = make([]*dbstruct.AudioSummary, 0)
for _, summary := range summaries {
audioSummaries = append(audioSummaries, &dbstruct.AudioSummary{
Label: summary.Label,
LabelSum: summary.LabelSum,
})
if util.DerefString(summary.Label) != AudioModerationPassLabel {
isPassed = false
if summary != nil {
audioSummaries = append(audioSummaries, &dbstruct.AudioSummary{
Label: summary.Label,
LabelSum: summary.LabelSum,
})
if util.DerefString(summary.Label) != AudioModerationPassLabel {
isPassed = false
}
}
}
return
@ -229,18 +247,20 @@ func buildAudioSummaries(summaries []*green20220302.VideoModerationResultRespons
func buildAudioDetails(details []*green20220302.VideoModerationResultResponseBodyDataAudioResultSliceDetails) (audioDetails []*dbstruct.AudioDetail) {
audioDetails = make([]*dbstruct.AudioDetail, 0)
for _, detail := range details {
audioDetails = append(audioDetails, &dbstruct.AudioDetail{
EndTime: detail.EndTime,
EndTimestamp: detail.EndTimestamp,
Extend: detail.Extend,
Labels: detail.Labels,
RiskTips: detail.RiskTips,
RiskWords: detail.RiskWords,
Score: detail.Score,
StartTime: detail.StartTime,
StartTimestamp: detail.StartTimestamp,
Text: detail.Text,
})
if detail != nil {
audioDetails = append(audioDetails, &dbstruct.AudioDetail{
EndTime: detail.EndTime,
EndTimestamp: detail.EndTimestamp,
Extend: detail.Extend,
Labels: detail.Labels,
RiskTips: detail.RiskTips,
RiskWords: detail.RiskWords,
Score: detail.Score,
StartTime: detail.StartTime,
StartTimestamp: detail.StartTimestamp,
Text: detail.Text,
})
}
}
return
}