diff --git a/api/errcode/errcode.go b/api/errcode/errcode.go index 5cf4db1a..e6a4a227 100644 --- a/api/errcode/errcode.go +++ b/api/errcode/errcode.go @@ -145,9 +145,10 @@ var ErrCodeMsgMap = map[ErrCode]string{ ErrCodeHandleWsFail: "", - ErrCodeMediaSrvFail: "媒体服务错误", - ErrCodeMediaNotExist: "媒体不存在", - ErrCodeMediaUploadFail: "媒体上传失败", + ErrCodeMediaSrvFail: "媒体服务错误", + ErrCodeMediaNotExist: "媒体不存在", + ErrCodeMediaUploadFail: "媒体上传失败", + ErrCodeMediaVideoMustBeUnique: "只能上传一个视频,请删除多余视频", ErrCodeImageAuditTaskSrvFail: "图像审核任务服务错误", ErrCodeImageAuditTaskNotExist: "图像审核任务不存在", @@ -608,10 +609,11 @@ const ( ErrCodeNotificationCountRedisCacheInvalid ErrCode = -46003 // 系统通知表redis缓存失效 // Media: 60xxx - ErrCodeMediaSrvOk ErrCode = ErrCodeOk - ErrCodeMediaSrvFail ErrCode = -60001 // 媒体服务错误 - ErrCodeMediaNotExist ErrCode = -60002 // 媒体不存在 - ErrCodeMediaUploadFail ErrCode = -60003 // 媒体上传失败 + ErrCodeMediaSrvOk ErrCode = ErrCodeOk + ErrCodeMediaSrvFail ErrCode = -60001 // 媒体服务错误 + ErrCodeMediaNotExist ErrCode = -60002 // 媒体不存在 + ErrCodeMediaUploadFail ErrCode = -60003 // 媒体上传失败 + ErrCodeMediaVideoMustBeUnique ErrCode = -60004 // 视频必须唯一 // Hvyogo: 61xxx ErrCodeHvyogoSrvOk ErrCode = ErrCodeOk diff --git a/app/mix/service/apiservice_business_validation.go b/app/mix/service/apiservice_business_validation.go index 1a394e1d..2daca739 100644 --- a/app/mix/service/apiservice_business_validation.go +++ b/app/mix/service/apiservice_business_validation.go @@ -592,6 +592,7 @@ func (s *Service) ApiCreateMomentBusinessValidate(ctx *gin.Context, req *momentp QueryAccount(_DefaultAccount.OpListByMid). EnsureAccountExist(). EnsureIsThisRole(consts.Streamer). + EnsureVideoIsUnique(req.Moment.MediaComp). EnsureMediaIsSuccessfullyUploaded(req.Moment.MediaComp). EnsureSuchAccountPunishmentNotExist(req.GetBaseRequest().Mid, consts.AccountPunishment_BlockFromCreatingMoment, _DefaultAccountPunishment.OpListByMidAndType). QueryMomentCreateTimes(_DefaultMomentCreateTimes.OpGetAndUpdate, req.GetBaseRequest().Mid). @@ -616,6 +617,7 @@ func (s *Service) ApiUpdateMomentBusinessValidate(ctx *gin.Context, req *momentp QueryAccount(_DefaultAccount.OpListByMid). EnsureAccountExist(). EnsureIsThisRole(consts.Streamer). + EnsureVideoIsUnique(req.Moment.MediaComp). EnsureMediaIsSuccessfullyUploaded(req.Moment.MediaComp). Validate(). Collect() @@ -645,6 +647,7 @@ func (s *Service) ApiCreateZoneMomentBusinessValidate(ctx *gin.Context, req *zon QueryAccount(_DefaultAccount.OpListByMid). EnsureAccountExist(). EnsureIsThisRole(consts.Streamer). + EnsureVideoIsUnique(req.ZoneMoment.MediaComp). EnsureMediaIsSuccessfullyUploaded(req.ZoneMoment.MediaComp). EnsureSuchAccountPunishmentNotExist(req.GetBaseRequest().Mid, consts.AccountPunishment_BlockFromCreatingZoneMoment, _DefaultAccountPunishment.OpListByMidAndType). EnsureSuchAccountPunishmentNotExist(req.GetBaseRequest().Mid, pType, _DefaultAccountPunishment.OpListByMidAndType). @@ -677,6 +680,7 @@ func (s *Service) ApiUpdateZoneMomentBusinessValidate(ctx *gin.Context, req *zon QueryAccount(_DefaultAccount.OpListByMid). EnsureAccountExist(). EnsureIsThisRole(consts.Streamer). + EnsureVideoIsUnique(req.ZoneMoment.MediaComp). EnsureMediaIsSuccessfullyUploaded(req.ZoneMoment.MediaComp). EnsureZoneMomentImagesEnoughForEncryption(req.ZoneMoment.GetMType(), req.ZoneMoment.MediaComp, mediaVisibleRange). Validate(). diff --git a/app/mix/service/business_validator/auth.go b/app/mix/service/business_validator/auth.go index 572743e3..261d5e92 100644 --- a/app/mix/service/business_validator/auth.go +++ b/app/mix/service/business_validator/auth.go @@ -726,6 +726,17 @@ func (l *AuthBusinessValidator) EnsureZoneThirdPartnerIsNotZoneCreater(fun func( return l } +func (l *AuthBusinessValidator) EnsureVideoIsUnique(media *dbstruct.MediaComponent) *AuthBusinessValidator { + l.oplist = append(l.oplist, func() { + if len(media.GetVideoIds()) > 0 { + if len(media.GetVideoIds()) > 1 { + l.ec = errcode.ErrCodeMediaVideoMustBeUnique + } + } + }) + return l +} + func (l *AuthBusinessValidator) EnsureStreamerAuthApprovalBasicCreated(fun func(*gin.Context, int64) (*dbstruct.StreamerAuthApprovalBasic, error), mid int64) *AuthBusinessValidator { l.oplist = append(l.oplist, func() { streamerauthapprovalbasic, err := fun(l.ctx, mid)