Merge remote-tracking branch 'origin/feat-IRONFANS-125-Robin' into conflict
This commit is contained in:
commit
112125e003
|
@ -1723,6 +1723,10 @@ func (s *Service) ApiCreateMoment(ctx *gin.Context, req *momentproto.ApiCreateRe
|
|||
func (s *Service) ApiUpdateMoment(ctx *gin.Context, req *momentproto.ApiUpdateReq) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeMomentSrvOk
|
||||
|
||||
if ec = s.ApiUpdateMomentBusinessValidate(ctx, req); ec != errcode.ErrCodeMomentSrvOk {
|
||||
return
|
||||
}
|
||||
|
||||
req.Moment.Mid = goproto.Int64(req.BaseRequest.Mid)
|
||||
|
||||
err := _DefaultMoment.OpUpdate(ctx, &momentproto.OpUpdateReq{
|
||||
|
@ -2502,6 +2506,10 @@ func (s *Service) ApiCreateZoneMoment(ctx *gin.Context, req *zonemomentproto.Api
|
|||
func (s *Service) ApiUpdateZoneMoment(ctx *gin.Context, req *zonemomentproto.ApiUpdateReq) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeZoneMomentSrvOk
|
||||
|
||||
if ec = s.ApiUpdateZoneMomentBusinessValidate(ctx, req); ec != errcode.ErrCodeZoneMomentSrvOk {
|
||||
return
|
||||
}
|
||||
|
||||
zonemoment, err := _DefaultZoneMoment.GetById(ctx, req.ZoneMoment.GetId())
|
||||
if err != nil {
|
||||
logger.Error("_DefaultZoneMoment GetById fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
|
|
|
@ -531,6 +531,7 @@ func (s *Service) ApiCreateMomentBusinessValidate(ctx *gin.Context, req *momentp
|
|||
ec = errcode.ErrCodeMomentSrvOk
|
||||
|
||||
resultList := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
||||
EnsureMediaIsSuccessfullyUploaded(req.Moment.MediaComp).
|
||||
EnsureSuchAccountPunishmentNotExist(req.GetBaseRequest().Mid, consts.AccountPunishment_BlockFromCreatingMoment, _DefaultAccountPunishment.OpListByMidAndType).
|
||||
QueryMomentCreateTimes(_DefaultMomentCreateTimes.OpGetAndUpdate, req.GetBaseRequest().Mid).
|
||||
EnsureMomentCreateTimesNotReachedDailyUpperbound().
|
||||
|
@ -546,6 +547,22 @@ func (s *Service) ApiCreateMomentBusinessValidate(ctx *gin.Context, req *momentp
|
|||
return
|
||||
}
|
||||
|
||||
func (s *Service) ApiUpdateMomentBusinessValidate(ctx *gin.Context, req *momentproto.ApiUpdateReq) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeMomentSrvOk
|
||||
|
||||
resultList := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
||||
EnsureMediaIsSuccessfullyUploaded(req.Moment.MediaComp).
|
||||
Validate().
|
||||
Collect()
|
||||
ec, _ = resultList[0].(errcode.ErrCode)
|
||||
if ec != errcode.ErrCodeOk {
|
||||
logger.Error("ApiUpdateMomentBusinessValidate business validation failed!")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Service) ApiCreateZoneMomentBusinessValidate(ctx *gin.Context, req *zonemomentproto.ApiCreateReq) (ec errcode.ErrCode, accountpunishment *dbstruct.AccountPunishment) {
|
||||
ec = errcode.ErrCodeMomentSrvOk
|
||||
|
||||
|
@ -563,6 +580,7 @@ func (s *Service) ApiCreateZoneMomentBusinessValidate(ctx *gin.Context, req *zon
|
|||
QueryAccount(_DefaultAccount.OpListByMid).
|
||||
EnsureAccountExist().
|
||||
EnsureIsThisRole(consts.Streamer).
|
||||
EnsureMediaIsSuccessfullyUploaded(req.ZoneMoment.MediaComp).
|
||||
EnsureSuchAccountPunishmentNotExist(req.GetBaseRequest().Mid, consts.AccountPunishment_BlockFromCreatingZoneMoment, _DefaultAccountPunishment.OpListByMidAndType).
|
||||
EnsureSuchAccountPunishmentNotExist(req.GetBaseRequest().Mid, pType, _DefaultAccountPunishment.OpListByMidAndType).
|
||||
EnsureZoneMomentImagesEnoughForEncryption(req.ZoneMoment.GetMType(), req.ZoneMoment.MediaComp, mediaVisibleRange).
|
||||
|
@ -580,6 +598,32 @@ func (s *Service) ApiCreateZoneMomentBusinessValidate(ctx *gin.Context, req *zon
|
|||
return
|
||||
}
|
||||
|
||||
func (s *Service) ApiUpdateZoneMomentBusinessValidate(ctx *gin.Context, req *zonemomentproto.ApiUpdateReq) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeMomentSrvOk
|
||||
|
||||
mediaVisibleRange := int64(0)
|
||||
switch req.ZoneMoment.GetCType() {
|
||||
case consts.ZoneMomentCType_Paid:
|
||||
mediaVisibleRange = req.ZoneMoment.GetMediaVisibleRange()
|
||||
}
|
||||
|
||||
resultList := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
||||
QueryAccount(_DefaultAccount.OpListByMid).
|
||||
EnsureAccountExist().
|
||||
EnsureIsThisRole(consts.Streamer).
|
||||
EnsureMediaIsSuccessfullyUploaded(req.ZoneMoment.MediaComp).
|
||||
EnsureZoneMomentImagesEnoughForEncryption(req.ZoneMoment.GetMType(), req.ZoneMoment.MediaComp, mediaVisibleRange).
|
||||
Validate().
|
||||
Collect()
|
||||
ec, _ = resultList[0].(errcode.ErrCode)
|
||||
if ec != errcode.ErrCodeOk {
|
||||
logger.Error("ApiUpdateZoneMomentBusinessValidate business validation failed!")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 代运营创建验证码
|
||||
func (s *Service) ApiCreateZoneThirdPartnerBusinessValidate(ctx *gin.Context, req *zone_third_partner_proto.ApiCreateReq) (vericode *dbstruct.VeriCode, ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeLoginSrvOk
|
||||
|
|
|
@ -656,6 +656,42 @@ func (l *AuthBusinessValidator) EnsureZtpSharingRatioIsEnoughAfterUpdatingAColla
|
|||
return l
|
||||
}
|
||||
|
||||
func (l *AuthBusinessValidator) EnsureMediaIsSuccessfullyUploaded(media *dbstruct.MediaComponent) *AuthBusinessValidator {
|
||||
l.oplist = append(l.oplist, func() {
|
||||
|
||||
if len(media.GetImageIds()) > 0 {
|
||||
imageIdForUploadFail, err := apollo.GetIntValue(consts.ImageIdForUploadFail, apollo.ApolloOpts().SetNamespace("application"))
|
||||
if err != nil {
|
||||
logger.Error("Apollo read failed : %v", err)
|
||||
l.ec = errcode.ErrCodeApolloReadFail
|
||||
return
|
||||
}
|
||||
for _, imageId := range media.GetImageIds() {
|
||||
if int64(imageIdForUploadFail) == imageId {
|
||||
l.ec = errcode.ErrCodeMediaUploadFail
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(media.GetVideoIds()) > 0 {
|
||||
videoIdForUploadFail, err := apollo.GetIntValue(consts.VideoIdForUploadFail, apollo.ApolloOpts().SetNamespace("application"))
|
||||
if err != nil {
|
||||
logger.Error("Apollo read failed : %v", err)
|
||||
l.ec = errcode.ErrCodeApolloReadFail
|
||||
return
|
||||
}
|
||||
for _, videoId := range media.GetVideoIds() {
|
||||
if int64(videoIdForUploadFail) == videoId {
|
||||
l.ec = errcode.ErrCodeMediaUploadFail
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
return l
|
||||
}
|
||||
|
||||
// 执行校验
|
||||
func (a *AuthBusinessValidator) Validate() *AuthBusinessValidator {
|
||||
a.BusinessValidateStream.Validate()
|
||||
|
|
Loading…
Reference in New Issue