Merge pull request 'by Robin at 20240525' (#501) from feat-IRONFANS-118-Robin-2 into main
Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/501
This commit is contained in:
commit
2e572ca814
|
@ -667,6 +667,24 @@ func (l *AuthBusinessValidator) EnsureZtpSharingRatioIsEnoughAfterUpdatingAColla
|
|||
return l
|
||||
}
|
||||
|
||||
func (l *AuthBusinessValidator) EnsureZoneThirdPartnerIsNotZoneCreater(fun func(*gin.Context, int64) (*dbstruct.Zone, error), zid int64, ztpMid int64) *AuthBusinessValidator {
|
||||
|
||||
l.oplist = append(l.oplist, func() {
|
||||
// 查询空间
|
||||
zone, err := fun(l.ctx, zid)
|
||||
if err != nil {
|
||||
logger.Error("Zone GetById fail, err: %v", err)
|
||||
l.ec = errcode.ErrCodeZoneSrvFail
|
||||
return
|
||||
}
|
||||
if zone.GetMid() == ztpMid {
|
||||
l.ec = errcode.ErrCodeZoneThirdPartnerWrongThirdPartner
|
||||
return
|
||||
}
|
||||
})
|
||||
return l
|
||||
}
|
||||
|
||||
// 执行校验
|
||||
func (a *AuthBusinessValidator) Validate() *AuthBusinessValidator {
|
||||
a.BusinessValidateStream.Validate()
|
||||
|
|
|
@ -1445,3 +1445,21 @@ func (s *Service) OpUpdateZoneThirdPartnerBusinessValidate(ctx *gin.Context, req
|
|||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 代运营
|
||||
func (s *Service) OpCreateZoneThirdPartnerBusinessValidate(ctx *gin.Context, req *zone_third_partner_proto.OpCreateReq) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeZoneThirdPartnerSrvOk
|
||||
|
||||
// 1.鉴权校验
|
||||
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
||||
EnsureZoneThirdPartnerIsNotZoneCreater(_DefaultZone.GetById, req.ZoneThirdPartner.GetZid(), req.ZoneThirdPartner.GetThirdPartnerMid()).
|
||||
Validate().
|
||||
Collect()
|
||||
ec, _ = result[0].(errcode.ErrCode)
|
||||
if ec != errcode.ErrCodeOk {
|
||||
logger.Error("OpCreateZoneThirdPartner business validation failed!")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
@ -3761,6 +3761,10 @@ func (s *Service) OpSetPrivateZoneMoment(ctx *gin.Context, req *zonemomentproto.
|
|||
func (s *Service) OpCreateZoneThirdPartner(ctx *gin.Context, req *zone_third_partner_proto.OpCreateReq) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeZoneThirdPartnerSrvOk
|
||||
|
||||
if ec = s.OpCreateZoneThirdPartnerBusinessValidate(ctx, req); ec != errcode.ErrCodeZoneThirdPartnerSrvOk {
|
||||
return
|
||||
}
|
||||
|
||||
err := _DefaultZoneThirdPartner.OpCreate(ctx, req)
|
||||
if err != nil {
|
||||
logger.Error("OpCreate fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
|
|
Loading…
Reference in New Issue