From 1cbc732469920210158f99766330bc11e3ab9e73 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Fri, 22 Dec 2023 12:53:21 +0800 Subject: [PATCH] by Robin at 20231222; Op service validate --- .../service/opservice_business_validation.go | 607 +++++++++++++++++- app/mix/service/service.go | 171 ++++- 2 files changed, 757 insertions(+), 21 deletions(-) diff --git a/app/mix/service/opservice_business_validation.go b/app/mix/service/opservice_business_validation.go index 3711929e..d3a525a2 100644 --- a/app/mix/service/opservice_business_validation.go +++ b/app/mix/service/opservice_business_validation.go @@ -4,8 +4,18 @@ import ( "service/api/errcode" accountproto "service/api/proto/account/proto" accountrelationproto "service/api/proto/accountrelation/proto" + callhistoryproto "service/api/proto/callhistory/proto" + contact_customer_service_proto "service/api/proto/contact_customer_service/proto" + feedbackproto "service/api/proto/feedback/proto" + imageaudittaskproto "service/api/proto/imageaudittask/proto" loginproto "service/api/proto/login/proto" + mediaproto "service/api/proto/media/proto" + realname_authenticationproto "service/api/proto/realname_authentication/proto" + streamerproto "service/api/proto/streamer/proto" streamerauthapprovalproto "service/api/proto/streamerauthapproval/proto" + streamerlinkproto "service/api/proto/streamerlink/proto" + textaudittaskproto "service/api/proto/textaudittask/proto" + userwxaddcheckproto "service/api/proto/userwxaddcheck/proto" businessvalidator "service/app/mix/service/business_validator" "service/dbstruct" "service/library/logger" @@ -427,7 +437,602 @@ func (s *Service) OpApproveStreamerAuthApprovalBusinessValidate(ctx *gin.Context Validate(). Collect() if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { - logger.Error("OpGetStreamerAuthApprovalList business validation failed") + logger.Error("OpApproveStreamerAuthApproval business validation failed") + return + } + return +} + +func (s *Service) OpCreateStreamerBusinessValidate(ctx *gin.Context, req *streamerproto.OpCreateReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeStreamerSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpCreateStreamer business validation failed") + return + } + return +} + +func (s *Service) OpUpdateStreamerBusinessValidate(ctx *gin.Context, req *streamerproto.OpUpdateReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeStreamerSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpUpdateStreamer business validation failed") + return + } + return +} + +func (s *Service) OpGetStreamerListBusinessValidate(ctx *gin.Context, req *streamerproto.OpListReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeStreamerSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetStreamerList business validation failed") + return + } + return +} + +func (s *Service) OpGetStreamerListByMidBusinessValidate(ctx *gin.Context, req *streamerproto.OpListByMidReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeStreamerSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetStreamerListByMid business validation failed") + return + } + return +} + +func (s *Service) OpGetStreamerExtListByMidBusinessValidate(ctx *gin.Context, req *streamerproto.OpListExtByMidReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeStreamerSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetStreamerExtListByMid business validation failed") + return + } + return +} + +func (s *Service) OpGetStreamerExtListByMidsBusinessValidate(ctx *gin.Context, req *streamerproto.OpListExtByMidsReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeStreamerSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetStreamerExtListByMids business validation failed") + return + } + return +} + +func (s *Service) OpGetStreamerExtListByUserIdBusinessValidate(ctx *gin.Context, req *streamerproto.OpListExtByUserIdReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeStreamerSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetStreamerExtListByUserId business validation failed") + return + } + return +} + +func (s *Service) OpGetStreamerExtListFuzzilyByUserIdBusinessValidate(ctx *gin.Context, req *streamerproto.OpListExtFuzzilyByUserIdReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeStreamerSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetStreamerExtListFuzzilyByUserId business validation failed") + return + } + return +} + +func (s *Service) OpGetStreamerExtListFuzzilyByNameBusinessValidate(ctx *gin.Context, req *streamerproto.OpListExtFuzzilyByNameReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeStreamerSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetStreamerExtListFuzzilyByName business validation failed") + return + } + return +} + +func (s *Service) OpGetStreamerWxIdBusinessValidate(ctx *gin.Context, req *streamerproto.OpListStreamerWxIdReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeStreamerSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetStreamerWxId business validation failed") + return + } + return +} + +func (s *Service) OpGetStreamerRecommListBusinessValidate(ctx *gin.Context, req *streamerproto.OpRecommListReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeStreamerSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetStreamerRecommList business validation failed") + return + } + return +} + +func (s *Service) OpCreateFeedbackBusinessValidate(ctx *gin.Context, req *feedbackproto.OpCreateReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeFeedbackSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpCreateFeedback business validation failed") + return + } + return +} + +func (s *Service) OpUpdateFeedbackBusinessValidate(ctx *gin.Context, req *feedbackproto.OpUpdateReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeFeedbackSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpUpdateFeedback business validation failed") + return + } + return +} + +func (s *Service) OpGetFeedbackListBusinessValidate(ctx *gin.Context, req *feedbackproto.OpListReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeFeedbackSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetFeedbackList business validation failed") + return + } + return +} + +func (s *Service) OpCreateCallHistoryBusinessValidate(ctx *gin.Context, req *callhistoryproto.OpCreateReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeCallHistorySrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpCreateCallHistory business validation failed") + return + } + return +} + +func (s *Service) OpUpdateCallHistoryBusinessValidate(ctx *gin.Context, req *callhistoryproto.OpUpdateReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeCallHistorySrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpUpdateCallHistory business validation failed") + return + } + return +} + +func (s *Service) OpGetCallHistoryListBusinessValidate(ctx *gin.Context, req *callhistoryproto.OpListReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeCallHistorySrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetCallHistoryList business validation failed") + return + } + return +} + +func (s *Service) OpGetCallHistoryCountBusinessValidate(ctx *gin.Context, req *callhistoryproto.OpCountReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeCallHistorySrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetCallHistoryCount business validation failed") + return + } + return +} + +func (s *Service) OpGetCallEvaluationListBusinessValidate(ctx *gin.Context, req *callhistoryproto.OpCallEvaluationListReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeCallHistorySrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetCallEvaluationList business validation failed") + return + } + return +} + +func (s *Service) OpGetStreamerLinkListByMidBusinessValidate(ctx *gin.Context, req *streamerlinkproto.OpListByMidReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeStreamerLinkSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetStreamerLinkListByMid business validation failed") + return + } + return +} + +func (s *Service) OpCreateUserWxAddCheckBusinessValidate(ctx *gin.Context, req *userwxaddcheckproto.OpCreateReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeUserWxAddCheckSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpCreateUserWxAddCheck business validation failed") + return + } + return +} + +func (s *Service) OpUpdateUserWxAddCheckBusinessValidate(ctx *gin.Context, req *userwxaddcheckproto.OpUpdateReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeUserWxAddCheckSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpUpdateUserWxAddCheck business validation failed") + return + } + return +} + +func (s *Service) OpGetUserWxAddCheckListBusinessValidate(ctx *gin.Context, req *userwxaddcheckproto.OpListReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeUserWxAddCheckSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetUserWxAddCheckList business validation failed") + return + } + return +} + +func (s *Service) MediaAuthBusinessValidate(ctx *gin.Context, req *mediaproto.MediaAuthReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeMediaSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("MediaAuth business validation failed") + return + } + return +} + +func (s *Service) CUploadBusinessValidate(ctx *gin.Context, req *mediaproto.CUploadReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeMediaSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("CUpload business validation failed") + return + } + return +} + +func (s *Service) OpGetRealNameAuthenticationListBusinessValidate(ctx *gin.Context, req *realname_authenticationproto.OpListReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeRealNameAuthenticationSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetRealNameAuthenticationList business validation failed") + return + } + return +} + +func (s *Service) OpApproveRealNameAuthenticationBusinessValidate(ctx *gin.Context, req *realname_authenticationproto.OpApproveReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeRealNameAuthenticationSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpApproveRealNameAuthentication business validation failed") + return + } + return +} + +func (s *Service) OpCreateContactCustomerServiceBusinessValidate(ctx *gin.Context, req *contact_customer_service_proto.OpCreateReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeContactCustomerServiceSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpCreateContactCustomerService business validation failed") + return + } + return +} + +func (s *Service) OpUpdateContactCustomerServiceByIdsBusinessValidate(ctx *gin.Context, req *contact_customer_service_proto.OpUpdateByIdsReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeContactCustomerServiceSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpUpdateContactCustomerServiceByIds business validation failed") + return + } + return +} + +func (s *Service) OpGetContactCustomerServiceListByMidBusinessValidate(ctx *gin.Context, req *contact_customer_service_proto.OpListByMidReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeContactCustomerServiceSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetContactCustomerServiceListByMid business validation failed") + return + } + return +} + +func (s *Service) OpGetContactCustomerServiceListUnreadGroupByMidBusinessValidate(ctx *gin.Context, req *contact_customer_service_proto.OpListReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeContactCustomerServiceSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetContactCustomerServiceListUnreadGroupByMid business validation failed") + return + } + return +} + +func (s *Service) OpGetImageAuditTaskVOListBusinessValidate(ctx *gin.Context, req *imageaudittaskproto.OpListReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeImageAuditTaskSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetImageAuditTaskVOList business validation failed") + return + } + return +} + +func (s *Service) OpPassImageAuditTaskBatchBusinessValidate(ctx *gin.Context, req *imageaudittaskproto.OpPassBatchReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeImageAuditTaskSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpPassImageAuditTaskBatch business validation failed") + return + } + return +} + +func (s *Service) OpGetTextAuditTaskVOListBusinessValidate(ctx *gin.Context, req *textaudittaskproto.OpListReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeTextAuditTaskSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetTextAuditTaskVOList business validation failed") + return + } + return +} + +func (s *Service) OpPassTextAuditTaskBatchBusinessValidate(ctx *gin.Context, req *textaudittaskproto.OpPassBatchReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeTextAuditTaskSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpPassTextAuditTaskBatch business validation failed") return } return diff --git a/app/mix/service/service.go b/app/mix/service/service.go index fd4db5d8..d1c8f86e 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -36,7 +36,6 @@ import ( "service/apollostruct" "service/app/mix/conf" "service/app/mix/dao" - businessvalidator "service/app/mix/service/business_validator" "service/app/mix/service/logic" "service/bizcommon/util" "service/dbstruct" @@ -1411,6 +1410,11 @@ func (s *Service) OpApproveStreamerAuthApproval(ctx *gin.Context, req *streamera // Streamer func (s *Service) OpCreateStreamer(ctx *gin.Context, req *streamerproto.OpCreateReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeStreamerSrvOk + + if ec = s.OpCreateStreamerBusinessValidate(ctx, req); ec != errcode.ErrCodeStreamerSrvOk { + return + } + err := _DefaultStreamer.OpCreate(ctx, req) if err != nil { logger.Error("OpCreate fail, req: %v, err: %v", util.ToJson(req), err) @@ -1422,6 +1426,11 @@ func (s *Service) OpCreateStreamer(ctx *gin.Context, req *streamerproto.OpCreate func (s *Service) OpUpdateStreamer(ctx *gin.Context, req *streamerproto.OpUpdateReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeStreamerSrvOk + + if ec = s.OpUpdateStreamerBusinessValidate(ctx, req); ec != errcode.ErrCodeStreamerSrvOk { + return + } + err := _DefaultStreamer.OpUpdate(ctx, req) if err == qmgo.ErrNoSuchDocuments { ec = errcode.ErrCodeStreamerNotExist @@ -1450,6 +1459,10 @@ func (s *Service) OpDeleteStreamer(ctx *gin.Context, id int64) (ec errcode.ErrCo func (s *Service) OpGetStreamerList(ctx *gin.Context, req *streamerproto.OpListReq) (list []*dbstruct.Streamer, ec errcode.ErrCode) { ec = errcode.ErrCodeStreamerSrvOk + if ec = s.OpGetStreamerListBusinessValidate(ctx, req); ec != errcode.ErrCodeStreamerSrvOk { + return + } + list, err := _DefaultStreamer.OpList(ctx, req) if err != nil { logger.Error("OpList fail, req: %v, err: %v", util.ToJson(req), err) @@ -1463,9 +1476,8 @@ func (s *Service) OpGetStreamerListByMid(ctx *gin.Context, req *streamerproto.Op ec = errcode.ErrCodeStreamerSrvOk //业务校验 - if req.BaseRequest.Mid != util.DerefInt64(req.Mid) { - logger.Error("OpGetAccountListByMid: Business exception: header Uid and body Uid do not refer to the same person") - return nil, errcode.ErrCodeSelfOnlyOperation + if ec = s.OpGetStreamerListByMidBusinessValidate(ctx, req); ec != errcode.ErrCodeStreamerSrvOk { + return } streamer, err := _DefaultStreamer.OpListByMid(ctx, req) @@ -1482,6 +1494,10 @@ func (s *Service) OpGetStreamerExtListByMid(ctx *gin.Context, req *streamerproto ec = errcode.ErrCodeStreamerSrvOk + if ec = s.OpGetStreamerExtListByMidBusinessValidate(ctx, req); ec != errcode.ErrCodeStreamerSrvOk { + return + } + //1.从用户表中查询主播信息 account, err := _DefaultAccount.OpListByMid(ctx, &accountproto.OpListByMidReq{ Mid: req.Mid, @@ -1506,6 +1522,10 @@ func (s *Service) OpGetStreamerExtListByMids(ctx *gin.Context, req *streamerprot ec = errcode.ErrCodeStreamerSrvOk + if ec = s.OpGetStreamerExtListByMidsBusinessValidate(ctx, req); ec != errcode.ErrCodeStreamerSrvOk { + return + } + //1.从用户表中查询所有主播信息的用户侧数据,按mid正序排序 accountList, err := _DefaultAccount.OpListByMids(ctx, &accountproto.OpListByMidsReq{ Mids: req.Mids, @@ -1541,6 +1561,10 @@ func (s *Service) OpGetStreamerExtListByUserId(ctx *gin.Context, req *streamerpr ec = errcode.ErrCodeStreamerSrvOk + if ec = s.OpGetStreamerExtListByUserIdBusinessValidate(ctx, req); ec != errcode.ErrCodeStreamerSrvOk { + return + } + //1.从用户表中查询主播信息 account, err := _DefaultAccount.OpListByUserId(ctx, &accountproto.OpListByUserIdReq{ UserId: req.UserId, @@ -1565,6 +1589,10 @@ func (s *Service) OpGetStreamerExtListFuzzilyByUserId(ctx *gin.Context, req *str ec = errcode.ErrCodeStreamerSrvOk + if ec = s.OpGetStreamerExtListFuzzilyByUserIdBusinessValidate(ctx, req); ec != errcode.ErrCodeStreamerSrvOk { + return + } + //1.从用户表中模糊匹配所有主播信息的用户侧数据,按mid正序排序 accountList, err := _DefaultAccount.OpListFuzzilyByUserId(ctx, &accountproto.OpListFuzzilyByUserIdReq{ UserId: req.UserId, @@ -1601,6 +1629,10 @@ func (s *Service) OpGetStreamerExtListFuzzilyByName(ctx *gin.Context, req *strea ec = errcode.ErrCodeStreamerSrvOk + if ec = s.OpGetStreamerExtListFuzzilyByNameBusinessValidate(ctx, req); ec != errcode.ErrCodeStreamerSrvOk { + return + } + //1.从用户表中模糊匹配所有主播信息的用户侧数据,按mid正序排序 accountList, err := _DefaultAccount.OpListFuzzilyByName(ctx, &accountproto.OpListFuzzilyByNameReq{ Name: req.Name, @@ -1675,6 +1707,10 @@ func (s *Service) OpGetStreamerRecommList(ctx *gin.Context, req *streamerproto.O ec = errcode.ErrCodeStreamerSrvOk + if ec = s.OpGetStreamerRecommListBusinessValidate(ctx, req); ec != errcode.ErrCodeStreamerSrvOk { + return + } + //1.从redis中获取数据 err := redis.GetRedisClient().GetObject(consts.RedisStreamerPrefix+"recomm_list", &recommlist) if err != nil { @@ -1723,6 +1759,11 @@ func (s *Service) OpGetStreamerRecommList(ctx *gin.Context, req *streamerproto.O // Feedback func (s *Service) OpCreateFeedback(ctx *gin.Context, req *feedbackproto.OpCreateReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeFeedbackSrvOk + + if ec = s.OpCreateFeedbackBusinessValidate(ctx, req); ec != errcode.ErrCodeFeedbackSrvOk { + return + } + err := _DefaultFeedback.OpCreate(ctx, req) if err != nil { logger.Error("OpCreate fail, req: %v, err: %v", util.ToJson(req), err) @@ -1734,6 +1775,11 @@ func (s *Service) OpCreateFeedback(ctx *gin.Context, req *feedbackproto.OpCreate func (s *Service) OpUpdateFeedback(ctx *gin.Context, req *feedbackproto.OpUpdateReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeFeedbackSrvOk + + if ec = s.OpUpdateFeedbackBusinessValidate(ctx, req); ec != errcode.ErrCodeFeedbackSrvOk { + return + } + err := _DefaultFeedback.OpUpdate(ctx, req) if err == qmgo.ErrNoSuchDocuments { ec = errcode.ErrCodeFeedbackNotExist @@ -1761,6 +1807,11 @@ func (s *Service) OpDeleteFeedback(ctx *gin.Context, id int64) (ec errcode.ErrCo func (s *Service) OpGetFeedbackList(ctx *gin.Context, req *feedbackproto.OpListReq) (list []*dbstruct.Feedback, ec errcode.ErrCode) { ec = errcode.ErrCodeFeedbackSrvOk + + if ec = s.OpGetFeedbackListBusinessValidate(ctx, req); ec != errcode.ErrCodeFeedbackSrvOk { + return + } + list, err := _DefaultFeedback.OpList(ctx, req) if err != nil { logger.Error("OpGetFeedbackList fail, req: %v, err: %v", util.ToJson(req), err) @@ -1773,6 +1824,11 @@ func (s *Service) OpGetFeedbackList(ctx *gin.Context, req *feedbackproto.OpListR // CallHistory func (s *Service) OpCreateCallHistory(ctx *gin.Context, req *callhistoryproto.OpCreateReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeCallHistorySrvOk + + if ec = s.OpCreateCallHistoryBusinessValidate(ctx, req); ec != errcode.ErrCodeCallHistorySrvOk { + return + } + err := _DefaultCallHistory.OpCreate(ctx, req) if err != nil { logger.Error("OpCreate fail, req: %v, err: %v", util.ToJson(req), err) @@ -1784,6 +1840,11 @@ func (s *Service) OpCreateCallHistory(ctx *gin.Context, req *callhistoryproto.Op func (s *Service) OpUpdateCallHistory(ctx *gin.Context, req *callhistoryproto.OpUpdateReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeCallHistorySrvOk + + if ec = s.OpUpdateCallHistoryBusinessValidate(ctx, req); ec != errcode.ErrCodeCallHistorySrvOk { + return + } + err := _DefaultCallHistory.OpUpdate(ctx, req) if err == qmgo.ErrNoSuchDocuments { ec = errcode.ErrCodeCallHistoryNotExist @@ -1811,6 +1872,11 @@ func (s *Service) OpDeleteCallHistory(ctx *gin.Context, id int64) (ec errcode.Er func (s *Service) OpGetCallHistoryList(ctx *gin.Context, req *callhistoryproto.OpListReq) (list []*dbstruct.CallHistory, ec errcode.ErrCode) { ec = errcode.ErrCodeCallHistorySrvOk + + if ec = s.OpGetCallHistoryListBusinessValidate(ctx, req); ec != errcode.ErrCodeCallHistorySrvOk { + return + } + list, err := _DefaultCallHistory.OpList(ctx, req) if err != nil { logger.Error("OpGetCallHistoryList fail, req: %v, err: %v", util.ToJson(req), err) @@ -1822,6 +1888,11 @@ func (s *Service) OpGetCallHistoryList(ctx *gin.Context, req *callhistoryproto.O func (s *Service) OpGetCallHistoryCount(ctx *gin.Context, req *callhistoryproto.OpCountReq) (countMap map[int64]int64, ec errcode.ErrCode) { ec = errcode.ErrCodeCallHistorySrvOk + + if ec = s.OpGetCallHistoryCountBusinessValidate(ctx, req); ec != errcode.ErrCodeCallHistorySrvOk { + return + } + countMap, err := _DefaultCallHistory.OpCount(ctx, req) if err != nil { logger.Error("OpCount fail, req: %v, err: %v", util.ToJson(req), err) @@ -1834,6 +1905,10 @@ func (s *Service) OpGetCallHistoryCount(ctx *gin.Context, req *callhistoryproto. func (s *Service) OpGetCallEvaluationList(ctx *gin.Context, req *callhistoryproto.OpCallEvaluationListReq) (list []*callhistoryproto.OpListCallEvaluationVO, ec errcode.ErrCode) { ec = errcode.ErrCodeCallHistorySrvOk + if ec = s.OpGetCallEvaluationListBusinessValidate(ctx, req); ec != errcode.ErrCodeCallHistorySrvOk { + return + } + //1.查出该主播的通话记录侧数据 callHistoryList, err := _DefaultCallHistory.OpList(ctx, &callhistoryproto.OpListReq{ Mid: req.Mid, @@ -1895,6 +1970,11 @@ func (s *Service) OpGetCallEvaluationList(ctx *gin.Context, req *callhistoryprot // StreamerLink func (s *Service) OpGetStreamerLinkListByMid(ctx *gin.Context, req *streamerlinkproto.OpListByMidReq) (list []*dbstruct.StreamerLink, ec errcode.ErrCode) { ec = errcode.ErrCodeStreamerLinkSrvOk + + if ec = s.OpGetStreamerLinkListByMidBusinessValidate(ctx, req); ec != errcode.ErrCodeStreamerLinkSrvOk { + return + } + list, err := _DefaultStreamerLink.OpListByMid(ctx, req) if err != nil { logger.Error("OpListByMid fail, req: %v, err: %v", util.ToJson(req), err) @@ -1907,6 +1987,11 @@ func (s *Service) OpGetStreamerLinkListByMid(ctx *gin.Context, req *streamerlink // UserWxAddCheck func (s *Service) OpCreateUserWxAddCheck(ctx *gin.Context, req *userwxaddcheckproto.OpCreateReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeUserWxAddCheckSrvOk + + if ec = s.OpCreateUserWxAddCheckBusinessValidate(ctx, req); ec != errcode.ErrCodeUserWxAddCheckSrvOk { + return + } + err := _DefaultUserWxAddCheck.OpCreate(ctx, req) if err != nil { logger.Error("OpCreate fail, req: %v, err: %v", util.ToJson(req), err) @@ -1918,6 +2003,11 @@ func (s *Service) OpCreateUserWxAddCheck(ctx *gin.Context, req *userwxaddcheckpr func (s *Service) OpUpdateUserWxAddCheck(ctx *gin.Context, req *userwxaddcheckproto.OpUpdateReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeUserWxAddCheckSrvOk + + if ec = s.OpUpdateUserWxAddCheckBusinessValidate(ctx, req); ec != errcode.ErrCodeUserWxAddCheckSrvOk { + return + } + err := _DefaultUserWxAddCheck.OpUpdate(ctx, req) if err == qmgo.ErrNoSuchDocuments { ec = errcode.ErrCodeUserWxAddCheckNotExist @@ -1945,6 +2035,11 @@ func (s *Service) OpDeleteUserWxAddCheck(ctx *gin.Context, id int64) (ec errcode func (s *Service) OpGetUserWxAddCheckList(ctx *gin.Context, req *userwxaddcheckproto.OpListReq) (list []*dbstruct.UserWxAddCheck, ec errcode.ErrCode) { ec = errcode.ErrCodeUserWxAddCheckSrvOk + + if ec = s.OpGetUserWxAddCheckListBusinessValidate(ctx, req); ec != errcode.ErrCodeUserWxAddCheckSrvOk { + return + } + list, err := _DefaultUserWxAddCheck.OpList(ctx, req) if err != nil { logger.Error("OpGetUserWxAddCheckList fail, req: %v, err: %v", util.ToJson(req), err) @@ -1956,6 +2051,11 @@ func (s *Service) OpGetUserWxAddCheckList(ctx *gin.Context, req *userwxaddcheckp func (s *Service) MediaAuth(ctx *gin.Context, req *mediaproto.MediaAuthReq) (policyToken *mediaproto.PolicyToken, ec errcode.ErrCode) { ec = errcode.ErrCodeMediaSrvOk + + if ec = s.MediaAuthBusinessValidate(ctx, req); ec != errcode.ErrCodeMediaSrvOk { + return + } + policyToken, err := _DefaultMedia.GetPolicyToken(req.Mtype) if err != nil { logger.Error("GetPolicyToken fail, req: %v, err: %v", util.ToJson(req), err) @@ -1967,6 +2067,11 @@ func (s *Service) MediaAuth(ctx *gin.Context, req *mediaproto.MediaAuthReq) (pol func (s *Service) CUpload(ctx *gin.Context, req *mediaproto.CUploadReq) (ret interface{}, ec errcode.ErrCode) { ec = errcode.ErrCodeMediaSrvOk + + if ec = s.CUploadBusinessValidate(ctx, req); ec != errcode.ErrCodeMediaSrvOk { + return + } + ret, err := _DefaultMedia.Upload(ctx, req.Mtype, req.Item) if err != nil { logger.Error("Upload fail, req: %v, err: %v", util.ToJson(req), err) @@ -2023,14 +2128,7 @@ func (s *Service) OpGetRealNameAuthenticationList(ctx *gin.Context, req *realnam ec = errcode.ErrCodeRealNameAuthenticationSrvOk // 1.业务校验,鉴权 - result := businessvalidator.NewAuthBusinessValidator(ctx, req). - QueryAccount(_DefaultAccount.OpListByMid). - EnsureAccountExist(). - EnsureIsOpRole(). - Validate(). - Collect() - if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { - logger.Error("OpCreateRealNameAuthentication business validation failed") + if ec = s.OpGetRealNameAuthenticationListBusinessValidate(ctx, req); ec != errcode.ErrCodeRealNameAuthenticationSrvOk { return } @@ -2047,14 +2145,7 @@ func (s *Service) OpApproveRealNameAuthentication(ctx *gin.Context, req *realnam ec = errcode.ErrCodeRealNameAuthenticationSrvOk // 1.业务校验,鉴权 - result := businessvalidator.NewAuthBusinessValidator(ctx, req). - QueryAccount(_DefaultAccount.OpListByMid). - EnsureAccountExist(). - EnsureIsOpRole(). - Validate(). - Collect() - if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { - logger.Error("OpCreateRealNameAuthentication business validation failed") + if ec = s.OpApproveRealNameAuthenticationBusinessValidate(ctx, req); ec != errcode.ErrCodeRealNameAuthenticationSrvOk { return } @@ -2095,6 +2186,11 @@ func (s *Service) OpApproveRealNameAuthentication(ctx *gin.Context, req *realnam // ContactCustomerService func (s *Service) OpCreateContactCustomerService(ctx *gin.Context, req *contact_customer_service_proto.OpCreateReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeContactCustomerServiceSrvOk + + if ec = s.OpCreateContactCustomerServiceBusinessValidate(ctx, req); ec != errcode.ErrCodeContactCustomerServiceSrvOk { + return + } + err := _DefaultContactCustomerService.OpCreate(ctx, req) if err != nil { logger.Error("OpCreate fail, req: %v, err: %v", util.ToJson(req), err) @@ -2106,6 +2202,11 @@ func (s *Service) OpCreateContactCustomerService(ctx *gin.Context, req *contact_ func (s *Service) OpUpdateContactCustomerServiceByIds(ctx *gin.Context, req *contact_customer_service_proto.OpUpdateByIdsReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeContactCustomerServiceSrvOk + + if ec = s.OpUpdateContactCustomerServiceByIdsBusinessValidate(ctx, req); ec != errcode.ErrCodeContactCustomerServiceSrvOk { + return + } + err := _DefaultContactCustomerService.OpUpdateByIds(ctx, req) if err == qmgo.ErrNoSuchDocuments { ec = errcode.ErrCodeContactCustomerServiceNotExist @@ -2133,6 +2234,11 @@ func (s *Service) OpDeleteContactCustomerService(ctx *gin.Context, id int64) (ec func (s *Service) OpGetContactCustomerServiceListByMid(ctx *gin.Context, req *contact_customer_service_proto.OpListByMidReq) (list []*dbstruct.ContactCustomerService, ec errcode.ErrCode) { ec = errcode.ErrCodeContactCustomerServiceSrvOk + + if ec = s.OpGetContactCustomerServiceListByMidBusinessValidate(ctx, req); ec != errcode.ErrCodeContactCustomerServiceSrvOk { + return + } + list, err := _DefaultContactCustomerService.OpListByMid(ctx, req) if err != nil { logger.Error("OpGetContactCustomerServiceListByMid fail, req: %v, err: %v", util.ToJson(req), err) @@ -2144,6 +2250,11 @@ func (s *Service) OpGetContactCustomerServiceListByMid(ctx *gin.Context, req *co func (s *Service) OpGetContactCustomerServiceListUnreadGroupByMid(ctx *gin.Context, req *contact_customer_service_proto.OpListReq) (volist []*contact_customer_service_proto.ContactCustomerServiceOpVO, ec errcode.ErrCode) { ec = errcode.ErrCodeContactCustomerServiceSrvOk + + if ec = s.OpGetContactCustomerServiceListUnreadGroupByMidBusinessValidate(ctx, req); ec != errcode.ErrCodeContactCustomerServiceSrvOk { + return + } + list, err := _DefaultContactCustomerService.OpListUnread(ctx, req) if err != nil { logger.Error("OpGetContactCustomerServiceListUnread fail, req: %v, err: %v", util.ToJson(req), err) @@ -2172,6 +2283,11 @@ func (s *Service) OpGetContactCustomerServiceListUnreadGroupByMid(ctx *gin.Conte func (s *Service) OpGetImageAuditTaskVOList(ctx *gin.Context, req *imageaudittaskproto.OpListReq) (volist []*imageaudittaskproto.ImageAuditTaskVO, ec errcode.ErrCode) { ec = errcode.ErrCodeImageAuditTaskSrvOk + + if ec = s.OpGetImageAuditTaskVOListBusinessValidate(ctx, req); ec != errcode.ErrCodeImageAuditTaskSrvOk { + return + } + list, err := _DefaultImageAuditTask.OpList(ctx, req) if err != nil { logger.Error("OpGetImageAuditTaskListByMid fail, req: %v, err: %v", util.ToJson(req), err) @@ -2210,6 +2326,11 @@ func (s *Service) OpGetImageAuditTaskVOList(ctx *gin.Context, req *imageaudittas func (s *Service) OpPassImageAuditTaskBatch(ctx *gin.Context, req *imageaudittaskproto.OpPassBatchReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeImageAuditTaskSrvOk + + if ec = s.OpPassImageAuditTaskBatchBusinessValidate(ctx, req); ec != errcode.ErrCodeImageAuditTaskSrvOk { + return + } + ids := make([]string, 0) for i, task := range req.ImageAuditTasks { @@ -2236,6 +2357,11 @@ func (s *Service) OpPassImageAuditTaskBatch(ctx *gin.Context, req *imageaudittas func (s *Service) OpGetTextAuditTaskVOList(ctx *gin.Context, req *textaudittaskproto.OpListReq) (volist []*textaudittaskproto.TextAuditTaskVO, ec errcode.ErrCode) { ec = errcode.ErrCodeTextAuditTaskSrvOk + + if ec = s.OpGetTextAuditTaskVOListBusinessValidate(ctx, req); ec != errcode.ErrCodeTextAuditTaskSrvOk { + return + } + list, err := _DefaultTextAuditTask.OpList(ctx, req) if err != nil { logger.Error("OpGetTextAuditTaskListByMid fail, req: %v, err: %v", util.ToJson(req), err) @@ -2264,6 +2390,11 @@ func (s *Service) OpGetTextAuditTaskVOList(ctx *gin.Context, req *textaudittaskp func (s *Service) OpPassTextAuditTaskBatch(ctx *gin.Context, req *textaudittaskproto.OpPassBatchReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeTextAuditTaskSrvOk + + if ec = s.OpPassTextAuditTaskBatchBusinessValidate(ctx, req); ec != errcode.ErrCodeTextAuditTaskSrvOk { + return + } + ids := make([]string, 0) for i, task := range req.TextAuditTasks {