by Robin at 20241004; fix
This commit is contained in:
parent
9be64dca0c
commit
e6794cf887
|
@ -172,7 +172,7 @@ var ErrCodeMsgMap = map[ErrCode]string{
|
|||
|
||||
ErrCodeMomentCreateTimesSrvFail: "动态创建频次表服务错误",
|
||||
ErrCodeMomentCreateTimesNotExist: "动态创建频次表不存在",
|
||||
ErrCodeMomentCreateTimesReachedDailyUpperbound: "每天仅可发布三条动态",
|
||||
ErrCodeMomentCreateTimesReachedDailyUpperbound: "每天仅可发布%d条动态",
|
||||
|
||||
ErrCodeMomentAuditTaskSrvFail: "动态审核任务表服务错误",
|
||||
ErrCodeMomentAuditTaskNotExist: "动态审核任务表不存在",
|
||||
|
@ -223,7 +223,7 @@ var ErrCodeMsgMap = map[ErrCode]string{
|
|||
|
||||
ErrCodeZoneMomentCreateTimesSrvFail: "空间动态创建频次表服务错误",
|
||||
ErrCodeZoneMomentCreateTimesNotExist: "空间动态创建频次表不存在",
|
||||
ErrCodeZoneMomentCreateTimesReachedDailyUpperbound: "每天仅可发布十条空间动态",
|
||||
ErrCodeZoneMomentCreateTimesReachedDailyUpperbound: "每天仅可发布%d条空间动态",
|
||||
|
||||
ErrCodeDailyStatementZoneInfoSrvFail: "空间相关每日报表服务错误",
|
||||
ErrCodeDailyStatementZoneInfoNotExist: "空间相关每日报表不存在",
|
||||
|
|
|
@ -14,12 +14,17 @@ import (
|
|||
|
||||
func ApiCreateMoment(ctx *gin.Context) {
|
||||
req := ctx.MustGet("client_req").(*momentproto.ApiCreateReq)
|
||||
ec, acctPunEndTime := service.DefaultService.ApiCreateMoment(ctx, req)
|
||||
ec, acctPunEndTime, maxDailyMomentCreateTimes := service.DefaultService.ApiCreateMoment(ctx, req)
|
||||
if ec == errcode.ErrCodeFunctionBlocked {
|
||||
logger.Error("ApiCreateMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrCodeMsgAndDetail(ctx, ec, acctPunEndTime)
|
||||
return
|
||||
}
|
||||
if ec == errcode.ErrCodeMomentCreateTimesReachedDailyUpperbound {
|
||||
logger.Error("ApiCreateMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrCodeMsgAndDetail(ctx, ec, maxDailyMomentCreateTimes)
|
||||
return
|
||||
}
|
||||
if ec != errcode.ErrCodeMomentSrvOk {
|
||||
logger.Error("ApiCreateMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrCodeMsg(ctx, ec)
|
||||
|
|
|
@ -14,12 +14,17 @@ import (
|
|||
|
||||
func ApiCreateZoneMoment(ctx *gin.Context) {
|
||||
req := ctx.MustGet("client_req").(*zonemomentproto.ApiCreateReq)
|
||||
ec, acctPunEndTime := service.DefaultService.ApiCreateZoneMoment(ctx, req)
|
||||
ec, acctPunEndTime, maxZoneMomentCreateTimes := service.DefaultService.ApiCreateZoneMoment(ctx, req)
|
||||
if ec == errcode.ErrCodeFunctionBlocked {
|
||||
logger.Error("ApiCreateMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrCodeMsgAndDetail(ctx, ec, acctPunEndTime)
|
||||
return
|
||||
}
|
||||
if ec == errcode.ErrCodeZoneMomentCreateTimesReachedDailyUpperbound {
|
||||
logger.Error("ApiCreateMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrCodeMsgAndDetail(ctx, ec, maxZoneMomentCreateTimes)
|
||||
return
|
||||
}
|
||||
if ec != errcode.ErrCodeZoneMomentSrvOk {
|
||||
logger.Error("ApiCreateMoment fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrCodeMsg(ctx, ec)
|
||||
|
|
|
@ -2148,12 +2148,12 @@ func (s *Service) ApiGetContactCustomerServiceSessionListByMid(ctx *gin.Context,
|
|||
}
|
||||
|
||||
// Moment
|
||||
func (s *Service) ApiCreateMoment(ctx *gin.Context, req *momentproto.ApiCreateReq) (ec errcode.ErrCode, acctPunEndTime string) {
|
||||
func (s *Service) ApiCreateMoment(ctx *gin.Context, req *momentproto.ApiCreateReq) (ec errcode.ErrCode, acctPunEndTime string, maxDailyMomentCreateTimes int) {
|
||||
ec = errcode.ErrCodeMomentSrvOk
|
||||
|
||||
req.Moment.Mid = goproto.Int64(req.BaseRequest.Mid)
|
||||
var accountpunishment *dbstruct.AccountPunishment
|
||||
if ec, accountpunishment = s.ApiCreateMomentBusinessValidate(ctx, req); ec != errcode.ErrCodeMomentSrvOk {
|
||||
if ec, accountpunishment, maxDailyMomentCreateTimes = s.ApiCreateMomentBusinessValidate(ctx, req); ec != errcode.ErrCodeMomentSrvOk {
|
||||
if ec == errcode.ErrCodeRolePrivilegesNotEnough {
|
||||
ec = errcode.ErrCodeMomentNotAStreamer
|
||||
return
|
||||
|
@ -2972,12 +2972,12 @@ func (s *Service) ApiGetZoneListByUserIdFromOutside(ctx *gin.Context, req *zonep
|
|||
}
|
||||
|
||||
// ZoneMoment
|
||||
func (s *Service) ApiCreateZoneMoment(ctx *gin.Context, req *zonemomentproto.ApiCreateReq) (ec errcode.ErrCode, acctPunEndTime string) {
|
||||
func (s *Service) ApiCreateZoneMoment(ctx *gin.Context, req *zonemomentproto.ApiCreateReq) (ec errcode.ErrCode, acctPunEndTime string, maxZoneMomentCreateTimes int) {
|
||||
ec = errcode.ErrCodeZoneMomentSrvOk
|
||||
|
||||
req.ZoneMoment.Mid = goproto.Int64(req.BaseRequest.Mid)
|
||||
var accountpunishment *dbstruct.AccountPunishment
|
||||
if ec, accountpunishment = s.ApiCreateZoneMomentBusinessValidate(ctx, req); ec != errcode.ErrCodeZoneMomentSrvOk {
|
||||
if ec, accountpunishment, maxZoneMomentCreateTimes = s.ApiCreateZoneMomentBusinessValidate(ctx, req); ec != errcode.ErrCodeZoneMomentSrvOk {
|
||||
if ec == errcode.ErrCodeAccountPunishmentExist {
|
||||
if accountpunishment.IsPermanent() {
|
||||
ec = errcode.ErrCodeFunctionBlockedPermanently
|
||||
|
|
|
@ -583,7 +583,7 @@ func (s *Service) ApiGetStreamerWxIdBusinessValidate(ctx *gin.Context, req *stre
|
|||
return
|
||||
}
|
||||
|
||||
func (s *Service) ApiCreateMomentBusinessValidate(ctx *gin.Context, req *momentproto.ApiCreateReq) (ec errcode.ErrCode, accountpunishment *dbstruct.AccountPunishment) {
|
||||
func (s *Service) ApiCreateMomentBusinessValidate(ctx *gin.Context, req *momentproto.ApiCreateReq) (ec errcode.ErrCode, accountpunishment *dbstruct.AccountPunishment, maxDailyMomentCreateTimes int) {
|
||||
ec = errcode.ErrCodeMomentSrvOk
|
||||
|
||||
resultList := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
||||
|
@ -598,6 +598,7 @@ func (s *Service) ApiCreateMomentBusinessValidate(ctx *gin.Context, req *momentp
|
|||
Collect()
|
||||
ec, _ = resultList[0].(errcode.ErrCode)
|
||||
accountpunishment, _ = resultList[3].(*dbstruct.AccountPunishment)
|
||||
maxDailyMomentCreateTimes, _ = resultList[4].(int)
|
||||
if ec != errcode.ErrCodeOk {
|
||||
logger.Error("ApiCreateMomentBusinessValidate business validation failed!")
|
||||
return
|
||||
|
@ -625,7 +626,7 @@ func (s *Service) ApiUpdateMomentBusinessValidate(ctx *gin.Context, req *momentp
|
|||
return
|
||||
}
|
||||
|
||||
func (s *Service) ApiCreateZoneMomentBusinessValidate(ctx *gin.Context, req *zonemomentproto.ApiCreateReq) (ec errcode.ErrCode, accountpunishment *dbstruct.AccountPunishment) {
|
||||
func (s *Service) ApiCreateZoneMomentBusinessValidate(ctx *gin.Context, req *zonemomentproto.ApiCreateReq) (ec errcode.ErrCode, accountpunishment *dbstruct.AccountPunishment, maxZoneMomentCreateTimes int) {
|
||||
ec = errcode.ErrCodeMomentSrvOk
|
||||
|
||||
pType := int64(0)
|
||||
|
@ -652,6 +653,7 @@ func (s *Service) ApiCreateZoneMomentBusinessValidate(ctx *gin.Context, req *zon
|
|||
Collect()
|
||||
ec, _ = resultList[0].(errcode.ErrCode)
|
||||
accountpunishment, _ = resultList[3].(*dbstruct.AccountPunishment)
|
||||
maxZoneMomentCreateTimes, _ = resultList[5].(int)
|
||||
if ec != errcode.ErrCodeOk {
|
||||
logger.Error("ApiCreateZoneMomentBusinessValidate business validation failed!")
|
||||
return
|
||||
|
|
|
@ -23,11 +23,13 @@ type AuthBusinessValidator struct {
|
|||
// 操作来源校验
|
||||
OperMid int64 // 操作用户
|
||||
|
||||
account *dbstruct.Account
|
||||
accountrelation *dbstruct.AccountRelation
|
||||
momentCreateTimes *dbstruct.MomentCreateTimes
|
||||
accountpunishment *dbstruct.AccountPunishment
|
||||
zoneThirdPartner *dbstruct.ZoneThirdPartner
|
||||
account *dbstruct.Account
|
||||
accountrelation *dbstruct.AccountRelation
|
||||
momentCreateTimes *dbstruct.MomentCreateTimes
|
||||
accountpunishment *dbstruct.AccountPunishment
|
||||
zoneThirdPartner *dbstruct.ZoneThirdPartner
|
||||
maxDailyZoneMomentCreateTimes int
|
||||
maxDailyMomentCreateTimes int
|
||||
}
|
||||
|
||||
func NewAuthBusinessValidator(ctx *gin.Context, req any) *AuthBusinessValidator {
|
||||
|
@ -339,6 +341,7 @@ func (l *AuthBusinessValidator) EnsureMomentCreateTimesNotReachedDailyUpperbound
|
|||
if l.momentCreateTimes.CreateTimes >= int64(maxDailyMomentCreateTimes) {
|
||||
logger.Error("the moment create times of this mid has reached its daily upperbound")
|
||||
l.ec = errcode.ErrCodeMomentCreateTimesReachedDailyUpperbound
|
||||
l.maxDailyMomentCreateTimes = maxDailyMomentCreateTimes
|
||||
return
|
||||
}
|
||||
})
|
||||
|
@ -482,8 +485,10 @@ func (l *AuthBusinessValidator) EnsureZoneMomentCreateTimesNotReachedDailyUpperb
|
|||
if zoneMomentCreateTimes.CreateTimes >= int64(maxDailyZoneMomentCreateTimes) {
|
||||
logger.Error("the zone moment create times of this mid has reached its daily upperbound")
|
||||
l.ec = errcode.ErrCodeZoneMomentCreateTimesReachedDailyUpperbound
|
||||
l.maxDailyZoneMomentCreateTimes = maxDailyZoneMomentCreateTimes
|
||||
return
|
||||
}
|
||||
|
||||
})
|
||||
return l
|
||||
}
|
||||
|
@ -784,5 +789,7 @@ func (a *AuthBusinessValidator) Collect() []any {
|
|||
resultList[1] = a.account
|
||||
resultList[2] = a.accountrelation
|
||||
resultList[3] = a.accountpunishment
|
||||
resultList[4] = a.maxDailyMomentCreateTimes
|
||||
resultList[5] = a.maxDailyZoneMomentCreateTimes
|
||||
return resultList
|
||||
}
|
||||
|
|
|
@ -1441,7 +1441,7 @@ func (s *Service) OpCreateZoneThirdPartnerBusinessValidate(ctx *gin.Context, req
|
|||
return
|
||||
}
|
||||
|
||||
func (s *Service) OpCreateZoneMomentBusinessValidate(ctx *gin.Context, req *zonemomentproto.OpCreateReq) (ec errcode.ErrCode, accountpunishment *dbstruct.AccountPunishment) {
|
||||
func (s *Service) OpCreateZoneMomentBusinessValidate(ctx *gin.Context, req *zonemomentproto.OpCreateReq) (ec errcode.ErrCode, accountpunishment *dbstruct.AccountPunishment, maxZoneMomentCreateTimes int) {
|
||||
ec = errcode.ErrCodeMomentSrvOk
|
||||
|
||||
mediaVisibleRange := int64(0)
|
||||
|
@ -1460,6 +1460,7 @@ func (s *Service) OpCreateZoneMomentBusinessValidate(ctx *gin.Context, req *zone
|
|||
Collect()
|
||||
ec, _ = resultList[0].(errcode.ErrCode)
|
||||
accountpunishment, _ = resultList[3].(*dbstruct.AccountPunishment)
|
||||
maxZoneMomentCreateTimes, _ = resultList[5].(int)
|
||||
if ec != errcode.ErrCodeOk {
|
||||
logger.Error("OpCreateZoneMomentBusinessValidate business validation failed!")
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue