Merge pull request 'feat-IRONFANS-160-Robin' (#586) from feat-IRONFANS-160-Robin into main

Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/586
This commit is contained in:
chenhao 2024-07-02 21:12:59 +08:00
commit 688470d37a
3 changed files with 17 additions and 5 deletions

View File

@ -73,6 +73,7 @@ var ErrCodeMsgMap = map[ErrCode]string{
ErrCodeMomentSrvFail: "动态服务错误",
ErrCodeMomentNotExist: "动态不存在",
ErrCodeMomentNotAStreamer: "当前账号无发帖权限",
// ErrCodeMomentBlockedFromCreatingMoment: "功能封禁中,截止时间:%s",
// ErrCodeMomentBlockedFromCreatingMomentPermanently: "该功能已被永久封禁",
@ -317,6 +318,7 @@ const (
ErrCodeMomentSrvOk ErrCode = ErrCodeOk
ErrCodeMomentSrvFail ErrCode = -8001 // 动态服务错误
ErrCodeMomentNotExist ErrCode = -8002 // 动态不存在
ErrCodeMomentNotAStreamer ErrCode = -8003 // 普通用户禁止发帖
// ErrCodeMomentBlockedFromCreatingMoment ErrCode = -8003 // 动态创建已被封禁
// ErrCodeMomentBlockedFromCreatingMomentPermanently ErrCode = -8004 // 动态创建已被永久封禁

View File

@ -1695,6 +1695,10 @@ func (s *Service) ApiCreateMoment(ctx *gin.Context, req *momentproto.ApiCreateRe
req.Moment.Mid = goproto.Int64(req.BaseRequest.Mid)
var accountpunishment *dbstruct.AccountPunishment
if ec, accountpunishment = s.ApiCreateMomentBusinessValidate(ctx, req); ec != errcode.ErrCodeMomentSrvOk {
if ec == errcode.ErrCodeRolePrivilegesNotEnough {
ec = errcode.ErrCodeMomentNotAStreamer
return
}
if ec == errcode.ErrCodeAccountPunishmentExist {
if accountpunishment.IsPermanent() {
ec = errcode.ErrCodeFunctionBlockedPermanently

View File

@ -536,6 +536,9 @@ func (s *Service) ApiCreateMomentBusinessValidate(ctx *gin.Context, req *momentp
ec = errcode.ErrCodeMomentSrvOk
resultList := businessvalidator.NewAuthBusinessValidator(ctx, req).
QueryAccount(_DefaultAccount.OpListByMid).
EnsureAccountExist().
EnsureIsThisRole(consts.Streamer).
EnsureMediaIsSuccessfullyUploaded(req.Moment.MediaComp).
EnsureSuchAccountPunishmentNotExist(req.GetBaseRequest().Mid, consts.AccountPunishment_BlockFromCreatingMoment, _DefaultAccountPunishment.OpListByMidAndType).
QueryMomentCreateTimes(_DefaultMomentCreateTimes.OpGetAndUpdate, req.GetBaseRequest().Mid).
@ -556,6 +559,9 @@ func (s *Service) ApiUpdateMomentBusinessValidate(ctx *gin.Context, req *momentp
ec = errcode.ErrCodeMomentSrvOk
resultList := businessvalidator.NewAuthBusinessValidator(ctx, req).
QueryAccount(_DefaultAccount.OpListByMid).
EnsureAccountExist().
EnsureIsThisRole(consts.Streamer).
EnsureMediaIsSuccessfullyUploaded(req.Moment.MediaComp).
Validate().
Collect()