Merge pull request 'feat-IRONFANS-70' (#305) from feat-IRONFANS-70 into test

Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/305
This commit is contained in:
chenhao 2024-04-18 17:43:42 +08:00
commit cb592d0113
5 changed files with 43 additions and 5 deletions

View File

@ -180,6 +180,7 @@ var ErrCodeMsgMap = map[ErrCode]string{
ErrCodeZoneMomentSrvFail: "私密圈动态服务错误",
ErrCodeZoneMomentNotExist: "私密圈动态不存在",
ErrCodePaidZoneMomentCreateTimesReachedUpperbound: "付费动态不能多于免费动态",
ErrCodeZoneMomentImagesNotEnoughForEncryption: "预览图片数不得大于等于上传图片数",
ErrCodeZoneMomentThumbsUpSrvFail: "私密圈点赞服务错误",
ErrCodeZoneMomentThumbsUpNotExist: "私密圈点赞不存在",
@ -445,6 +446,7 @@ const (
ErrCodeZoneMomentSrvFail ErrCode = -34001 // 私密圈动态服务错误
ErrCodeZoneMomentNotExist ErrCode = -34002 // 私密圈动态不存在
ErrCodePaidZoneMomentCreateTimesReachedUpperbound ErrCode = -34003 // 私密圈付费动态创建次数已达上限
ErrCodeZoneMomentImagesNotEnoughForEncryption ErrCode = -34004 // 私密圈图片贴图片数量少于可预览图片数
// ZoneMomentThumbsUp: 35xxx
ErrCodeZoneMomentThumbsUpSrvOk ErrCode = ErrCodeOk

View File

@ -549,7 +549,7 @@ func (s *Service) ApiCreateZoneMomentBusinessValidate(ctx *gin.Context, req *zon
ec = errcode.ErrCodeMomentSrvOk
pType := int64(0)
switch util.DerefInt64(req.ZoneMoment.CType) {
switch req.ZoneMoment.GetCType() {
case consts.ZoneMomentCType_Free:
pType = consts.AccountPunishment_BlockFromCreatingFreeZoneMoment
case consts.ZoneMomentCType_Paid:
@ -563,7 +563,8 @@ func (s *Service) ApiCreateZoneMomentBusinessValidate(ctx *gin.Context, req *zon
EnsureSuchAccountPunishmentNotExist(req.GetBaseRequest().Mid, consts.AccountPunishment_BlockFromCreatingZoneMoment, _DefaultAccountPunishment.OpListByMidAndType).
EnsureSuchAccountPunishmentNotExist(req.GetBaseRequest().Mid, pType, _DefaultAccountPunishment.OpListByMidAndType).
EnsureZoneMomentCreateTimesNotReachedDailyUpperbound(_DefaultZoneMomentCreateTimes.OpGetAndUpdate, req.GetBaseRequest().Mid).
EnsureAmongZoneMomentsPaidItemsLessThanFreeItems(_DefaultZoneMoment.OpCountByMidAndCType, req.GetBaseRequest().Mid, util.DerefInt64(req.CType)).
EnsureAmongZoneMomentsPaidItemsLessThanFreeItems(_DefaultZoneMoment.OpCountByMidAndCType, req.GetBaseRequest().Mid, req.ZoneMoment.GetCType()).
EnsureZoneMomentImagesEnoughForEncryption(req.ZoneMoment.GetMType(), req.ZoneMoment.MediaComp, req.ZoneMoment.GetMediaVisibleRange()).
Validate().
Collect()
ec, _ = resultList[0].(errcode.ErrCode)

View File

@ -437,6 +437,23 @@ func (l *AuthBusinessValidator) EnsureZoneMomentCreateTimesNotReachedDailyUpperb
return l
}
func (l *AuthBusinessValidator) EnsureZoneMomentImagesEnoughForEncryption(mType int64, media *dbstruct.MediaComponent, mediaVisibleRange int64) *AuthBusinessValidator {
l.oplist = append(l.oplist, func() {
if mType == consts.MediaTypeVideo {
return
}
if len(media.GetImageIds()) <= int(mediaVisibleRange) {
logger.Error("images of this zone moment are not enough for encryption")
l.ec = errcode.ErrCodeZoneMomentImagesNotEnoughForEncryption
return
}
})
return l
}
// 执行校验
func (a *AuthBusinessValidator) Validate() *AuthBusinessValidator {
a.BusinessValidateStream.Validate()

View File

@ -883,9 +883,13 @@ func (s *Service) utilUnThumbsZoneMoment(ctx *gin.Context, req *zonemomentproto.
// 加密未解锁身份的动态
func (s *Service) utilEncryptInaccessibleZoneMoment(vo *zonemomentproto.ApiZoneMomentVO) {
if util.DerefInt64(vo.MType) == consts.MediaTypeImg {
if vo.GetMType() == consts.MediaTypeImg {
imageIds := vo.MediaComp.GetImageIds()
mediaVisibleRange := util.DerefInt64(vo.MediaVisibleRange)
mediaVisibleRange := vo.GetMediaVisibleRange()
// 为0也至少下发一张图片
if mediaVisibleRange == 0 {
mediaVisibleRange = 1
}
if len(imageIds) <= int(mediaVisibleRange) {
return
}
@ -907,7 +911,7 @@ func (s *Service) utilFillIsZoneMomentUnlocked(vo *zonemomentproto.ApiZoneMoment
case consts.ZoneMomentCType_Paid:
if vo.IsSuperfanshipUnlocked == consts.IsSuperfanshipUnlocked_Yes { // 超粉解锁
vo.SetIsZoneMomentUnlocked(consts.IsZoneMomentUnlocked_Yes)
} else if util.DerefInt64(vo.IsIronfanVisible) == consts.IsIronfanVisible_Yes && vo.IsIronfanshipUnlocked == consts.IsIronfanshipUnlocked_Yes { // 铁粉可见
} else if vo.GetIsIronfanVisible() == consts.IsIronfanVisible_Yes && vo.IsIronfanshipUnlocked == consts.IsIronfanshipUnlocked_Yes { // 铁粉可见
vo.SetIsZoneMomentUnlocked(consts.IsZoneMomentUnlocked_Yes)
} else if momentIdZmuMap[vo.ZoneMoment.GetId()].IsUnlock() { // 动态已购买
vo.SetIsZoneMomentUnlocked(consts.IsZoneMomentUnlocked_Yes)

View File

@ -67,6 +67,20 @@ func (p *ZoneMoment) GetCType() int64 {
return 0
}
func (p *ZoneMoment) GetMediaVisibleRange() int64 {
if p != nil && p.MediaVisibleRange != nil {
return *p.MediaVisibleRange
}
return 0
}
func (p *ZoneMoment) GetIsIronfanVisible() int64 {
if p != nil && p.IsIronfanVisible != nil {
return *p.IsIronfanVisible
}
return 0
}
func (p *ZoneMoment) GetUt() int64 {
if p != nil && p.Ut != nil {
return *p.Ut