1495 lines
48 KiB
Go
1495 lines
48 KiB
Go
package service
|
|
|
|
import (
|
|
"service/api/consts"
|
|
"service/api/errcode"
|
|
accountproto "service/api/proto/account/proto"
|
|
accountpunishmentproto "service/api/proto/accountpunishment/proto"
|
|
accountrelationproto "service/api/proto/accountrelation/proto"
|
|
appconfigproto "service/api/proto/app_config/proto"
|
|
callhistoryproto "service/api/proto/callhistory/proto"
|
|
contact_customer_service_proto "service/api/proto/contact_customer_service/proto"
|
|
contact_customer_service_sessionproto "service/api/proto/contact_customer_service_session/proto"
|
|
feedbackproto "service/api/proto/feedback/proto"
|
|
imageaudittaskproto "service/api/proto/imageaudittask/proto"
|
|
loginproto "service/api/proto/login/proto"
|
|
momentproto "service/api/proto/moment/proto"
|
|
moment_audit_taskproto "service/api/proto/moment_audit_task/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"
|
|
thumbsupproto "service/api/proto/thumbsup/proto"
|
|
userwxaddcheckproto "service/api/proto/userwxaddcheck/proto"
|
|
vericodeproto "service/api/proto/vericode/proto"
|
|
zone_collaborator_proto "service/api/proto/zone_collaborator/proto"
|
|
zone_third_partner_proto "service/api/proto/zone_third_partner/proto"
|
|
zonemomentproto "service/api/proto/zonemoment/proto"
|
|
businessvalidator "service/app/mix/service/business_validator"
|
|
"service/bizcommon/util"
|
|
"service/dbstruct"
|
|
"service/library/logger"
|
|
"service/library/mycrypto"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
goproto "google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// 发送验证码
|
|
func (s *Service) OpSendVeriCodeBusinessValidate(ctx *gin.Context, req *vericodeproto.OpSendReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeLoginSrvOk
|
|
|
|
if req.Did == "" {
|
|
logger.Info("H5 send : %v", req.MobilePhone)
|
|
req.Did = mycrypto.CryptoServiceInstance().SHA256.Encrypt([]byte(req.MobilePhone))
|
|
}
|
|
|
|
resultList := businessvalidator.NewLoginBusinessValidator(ctx, req).
|
|
QueryVeriCodeSendTimes(_DefaultVeriCodeSendTimes.OpGetAndUpdate, req.Did).
|
|
EnsureVeriCodeSendTimesNotReachedDailyUpperbound().
|
|
Validate().
|
|
Collect()
|
|
ec, _ = resultList[0].(errcode.ErrCode)
|
|
if ec != errcode.ErrCodeLoginSrvOk {
|
|
logger.Error("OpSendVeriCodeBusinessValidate business validation failed!")
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// 密码登录
|
|
func (s *Service) OpLoginByPswdBusinessValidate(ctx *gin.Context, req *loginproto.OpLoginByPswdReq) (login *dbstruct.Login, account *dbstruct.Account, ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeLoginSrvOk
|
|
|
|
// 1.业务校验
|
|
req.CalcPhoneHash() //计算手机号哈希
|
|
resultList := businessvalidator.NewLoginBusinessValidator(ctx, req).
|
|
QueryLogin(_DefaultLogin.OpListByPhoneHash).
|
|
EnsureLoginExist().
|
|
EnsureLoginAcctEnabled().
|
|
EnsureLoginAcctNotLocked().
|
|
EnsureLoginAcctNotBanned().
|
|
EnsurePasswordIsCorrect().
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
ec, _ = resultList[0].(errcode.ErrCode)
|
|
|
|
// 2.密码错误处理
|
|
if ec == errcode.ErrCodeLoginWrongPswd {
|
|
login, _ := resultList[1].(*dbstruct.Login)
|
|
if err := _DefaultLogin.OpHandleWrongPswd(ctx, login); err != nil {
|
|
logger.Error("OpHandleWrongPswd failed, err : %v", err)
|
|
}
|
|
}
|
|
|
|
// 3.验证失败则返回
|
|
if ec != errcode.ErrCodeLoginSrvOk {
|
|
logger.Error("OpLoginByPswd business validation failed!")
|
|
return
|
|
}
|
|
|
|
// 4.获取业务数据
|
|
login, _ = resultList[1].(*dbstruct.Login)
|
|
account, _ = resultList[2].(*dbstruct.Account)
|
|
return
|
|
}
|
|
|
|
// 验证码登录
|
|
func (s *Service) OpLoginByVeriCodeBusinessValidate(ctx *gin.Context, req *loginproto.OpLoginByVeriCodeReq) (login *dbstruct.Login, account *dbstruct.Account, vericode *dbstruct.VeriCode, ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeLoginSrvOk
|
|
|
|
// 1.业务校验
|
|
req.CalcPhoneHash() //计算手机号哈希
|
|
resultList := businessvalidator.NewLoginBusinessValidator(ctx, req).
|
|
QueryVeriCode(_DefaultVeriCode.OpListByPhoneHash).
|
|
EnsureVeriCodeExist().
|
|
EnsureVeriCodeIsCorrect().
|
|
EnsureVeriCodeIsValid().
|
|
QueryLogin(_DefaultLogin.OpListByPhoneHash).
|
|
EnsureLoginExist().
|
|
EnsureLoginAcctNotLocked().
|
|
EnsureLoginAcctNotBanned().
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
ec, _ = resultList[0].(errcode.ErrCode)
|
|
|
|
// 2.如果错误码是登录信息不存在,则判断为首次登录,将创建用户信息
|
|
if ec == errcode.ErrCodeLoginNotExist {
|
|
vericode, _ = resultList[3].(*dbstruct.VeriCode)
|
|
return
|
|
} else if ec == errcode.ErrCodeLoginSrvOk {
|
|
login, _ = resultList[1].(*dbstruct.Login)
|
|
account, _ = resultList[2].(*dbstruct.Account)
|
|
vericode, _ = resultList[3].(*dbstruct.VeriCode)
|
|
} else {
|
|
logger.Error("OpLoginByPswd business validation failed!")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
// 登录后第一次设置密码
|
|
func (s *Service) OpSetPasswordBusinessValidate(ctx *gin.Context, req *loginproto.OpSetPswdReq) (login *dbstruct.Login, account *dbstruct.Account, ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeLoginSrvOk
|
|
|
|
// 1.业务校验
|
|
req.CalcPhoneHash() //计算手机号哈希
|
|
resultList := businessvalidator.NewLoginBusinessValidator(ctx, req).
|
|
QueryLogin(_DefaultLogin.OpListByPhoneHash).
|
|
EnsureLoginExist().
|
|
EnsureLoginAcctNotLocked().
|
|
EnsureLoginAcctNotBanned().
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
|
|
// 2.校验结果
|
|
ec, _ = resultList[0].(errcode.ErrCode)
|
|
if ec != errcode.ErrCodeLoginSrvOk {
|
|
logger.Error("OpSetPassword business validation failed")
|
|
return
|
|
}
|
|
|
|
login, _ = resultList[1].(*dbstruct.Login)
|
|
account, _ = resultList[2].(*dbstruct.Account)
|
|
return
|
|
}
|
|
|
|
// 重置密码
|
|
func (s *Service) OpResetPasswordBusinessValidate(ctx *gin.Context, req *loginproto.OpResetPswdReq) (login *dbstruct.Login, account *dbstruct.Account, vericode *dbstruct.VeriCode, ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeLoginSrvOk
|
|
|
|
// 1.业务校验
|
|
req.CalcPhoneHash() //计算手机号哈希
|
|
resultList := businessvalidator.NewLoginBusinessValidator(ctx, req).
|
|
QueryVeriCode(_DefaultVeriCode.OpListByPhoneHash).
|
|
EnsureVeriCodeExist().
|
|
EnsureVeriCodeIsCorrect().
|
|
EnsureVeriCodeIsValid().
|
|
QueryLogin(_DefaultLogin.OpListByPhoneHash).
|
|
EnsureLoginExist().
|
|
EnsureLoginAcctEnabled().
|
|
EnsureLoginAcctNotBanned().
|
|
EnsureNewPasswordIsChanged().
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
|
|
// 2.校验结果
|
|
ec, _ = resultList[0].(errcode.ErrCode)
|
|
if ec != errcode.ErrCodeLoginSrvOk {
|
|
logger.Error("OpResetPassword business validation failed")
|
|
return
|
|
}
|
|
|
|
login, _ = resultList[1].(*dbstruct.Login)
|
|
account, _ = resultList[2].(*dbstruct.Account)
|
|
vericode, _ = resultList[3].(*dbstruct.VeriCode)
|
|
return
|
|
}
|
|
|
|
// 更新密码
|
|
func (s *Service) OpUpdatePasswordBusinessValidate(ctx *gin.Context, req *loginproto.OpUpdatePswdReq) (login *dbstruct.Login, account *dbstruct.Account, vericode *dbstruct.VeriCode, ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeLoginSrvOk
|
|
|
|
// 1.业务校验
|
|
req.CalcPhoneHash() //计算手机号哈希
|
|
resultList := businessvalidator.NewLoginBusinessValidator(ctx, req).
|
|
QueryVeriCode(_DefaultVeriCode.OpListByPhoneHash).
|
|
EnsureVeriCodeExist().
|
|
EnsureVeriCodeIsCorrect().
|
|
EnsureVeriCodeIsValid().
|
|
QueryLogin(_DefaultLogin.OpListByPhoneHash).
|
|
EnsureLoginExist().
|
|
EnsureLoginAcctEnabled().
|
|
EnsureLoginAcctNotLocked().
|
|
EnsureLoginAcctNotBanned().
|
|
EnsureOldPasswordIsCorrect().
|
|
EnsureNewPasswordIsChanged().
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
|
|
// 2.校验结果
|
|
ec, _ = resultList[0].(errcode.ErrCode)
|
|
if ec != errcode.ErrCodeLoginSrvOk {
|
|
logger.Error("OpUpdatePassword business validation failed")
|
|
return
|
|
}
|
|
|
|
login, _ = resultList[1].(*dbstruct.Login)
|
|
account, _ = resultList[2].(*dbstruct.Account)
|
|
vericode, _ = resultList[3].(*dbstruct.VeriCode)
|
|
return
|
|
}
|
|
|
|
// Account
|
|
func (s *Service) OpUpdateAccountBusinessValidate(ctx *gin.Context, req *accountproto.OpUpdateReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeAccountSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
EnsureMediaIsSuccessfullyUploaded(req.Account.Avatar).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpUpdateAccount business validation failed")
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetAccountListByUserIdBusinessValidate(ctx *gin.Context, req *accountproto.OpListByUserIdReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeAccountSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetAccountListByUserId business validation failed")
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetMobilePhoneByUserIdBusinessValidate(ctx *gin.Context, req *accountproto.OpGetMobilePhoneByUserIdReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeAccountSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetMobilePhoneByUserId business validation failed")
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetAccountListForOthersByMiBusinessValidated(ctx *gin.Context, req *accountproto.OpListOthersByMidReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeAccountSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetAccountListForOthersByMid business validation failed")
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetAccountListForOthersByMidsBusinessValidate(ctx *gin.Context, req *accountproto.OpListOthersByMidsReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeAccountSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetAccountListForOthersByMids business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetAccountCountBusinessValidate(ctx *gin.Context, req *accountproto.OpCountReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeAccountSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetAccountCount business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetFollowAccountRelationListBusinessValidate(ctx *gin.Context, req *accountrelationproto.OpListReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeAccountRelationSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetFollowAccountRelationList business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetIsFollowedAccountRelationListBusinessValidate(ctx *gin.Context, req *accountrelationproto.OpListReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeAccountRelationSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetIsFollowedAccountRelationList business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetFriendAccountRelationListBusinessValidate(ctx *gin.Context, req *accountrelationproto.OpListReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeAccountRelationSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetFriendAccountRelationList business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetIgnoreAccountRelationListBusinessValidate(ctx *gin.Context, req *accountrelationproto.OpListReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeAccountRelationSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetIgnoreAccountRelationList business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetAbleToAccessWeixinOfAccountRelationListBusinessValidate(ctx *gin.Context, req *accountrelationproto.OpListReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeAccountRelationSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetAbleToAccessWeixinOfAccountRelationList business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetAccountRelationCountBusinessValidate(ctx *gin.Context, req *accountrelationproto.OpCountReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeAccountRelationSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetAccountRelationCount business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetAccountRelationBySentenceBusinessValidate(ctx *gin.Context, req *accountrelationproto.OpListBySentenceReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeAccountRelationSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetAccountRelationBySentence business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetStreamerAuthApprovalListBusinessValidate(ctx *gin.Context, req *streamerauthapprovalproto.OpListReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeStreamerAuthApprovalSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetStreamerAuthApprovalList business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpApproveStreamerAuthApprovalBusinessValidate(ctx *gin.Context, req *streamerauthapprovalproto.OpApproveReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeStreamerAuthApprovalSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
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).
|
|
EnsureMediaIsSuccessfullyUploaded(req.Streamer.Album).
|
|
EnsureMediaIsSuccessfullyUploaded(req.Streamer.Shorts).
|
|
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) 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) OpGetContactCustomerServiceListBySessionIdBusinessValidate(ctx *gin.Context, req *contact_customer_service_proto.OpListBySessionIdReq) (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("OpGetContactCustomerServiceListBySessionId business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetContactCustomerServiceListUnreadGroupByMidBusinessValidate(ctx *gin.Context, req *contact_customer_service_proto.OpListUnreadReq) (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) 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) OpGetMomentAuditTaskListBusinessValidate(ctx *gin.Context, req *moment_audit_taskproto.OpListReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeMomentAuditTaskSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetAlignedAuditTaskVOList business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpCreateContactCustomerServiceSessionBusinessValidate(ctx *gin.Context, req *contact_customer_service_sessionproto.OpCreateReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeContactCustomerServiceSessionSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpCreateContactCustomerServiceSession business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetContactCustomerServiceSessionListByMidBusinessValidate(ctx *gin.Context, req *contact_customer_service_sessionproto.OpListByMidReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeContactCustomerServiceSessionSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetContactCustomerServiceSessionListByMid business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetContactCustomerServiceSessionListBySessionIdBusinessValidate(ctx *gin.Context, req *contact_customer_service_sessionproto.OpListBySessionIdReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeContactCustomerServiceSessionSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetContactCustomerServiceSessionListBySessionId business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetContactCustomerServiceSessionListBusinessValidate(ctx *gin.Context, req *contact_customer_service_sessionproto.OpListReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeContactCustomerServiceSessionSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetContactCustomerServiceSessionList business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpCreateMomentBusinessValidate(ctx *gin.Context, req *momentproto.OpCreateReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeMomentSrvOk
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
EnsureMediaIsSuccessfullyUploaded(req.Moment.MediaComp).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpCreateMoment business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpUpdateMomentBusinessValidate(ctx *gin.Context, req *momentproto.OpUpdateReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeMomentSrvOk
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
EnsureMediaIsSuccessfullyUploaded(req.Moment.MediaComp).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpUpdateMoment business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpDeleteMomentBusinessValidate(ctx *gin.Context, req *momentproto.OpDeleteReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeMomentSrvOk
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpDeleteMoment business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetMomentListBusinessValidate(ctx *gin.Context, req *momentproto.OpListReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeMomentSrvOk
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetMomentList business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetMomentListByMidBusinessValidate(ctx *gin.Context, req *momentproto.OpListByMidReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeMomentSrvOk
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetMomentListByMid business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetMomentListByIdsBusinessValidate(ctx *gin.Context, req *momentproto.OpListByIdsReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeMomentSrvOk
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetMomentListByIds business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpThumbsUpMomentBusinessValidate(ctx *gin.Context, req *momentproto.OpThumbsUpReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeMomentSrvOk
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpThumbsUpMoment business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpReviewMomentBusinessValidate(ctx *gin.Context, req *momentproto.OpReviewReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeMomentSrvOk
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpReviewMoment business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetThumbsUpListBusinessValidate(ctx *gin.Context, req *thumbsupproto.OpListReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeContactCustomerServiceSessionSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetThumbsUpList business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpUpdateAppConfigBusinessValidate(ctx *gin.Context, req *appconfigproto.OpUpdateReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeAppConfigSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpUpdateAppConfig business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetAppConfigListByKeyBusinessValidate(ctx *gin.Context, req *appconfigproto.OpListByKeyReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeAppConfigSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetAppConfigListByKey business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpCreateAccountPunishmentBusinessValidate(ctx *gin.Context, req *accountpunishmentproto.OpCreateReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeAccountPunishmentSrvOk
|
|
|
|
uid := util.DerefInt64(req.AccountPunishment.Mid)
|
|
typ := util.DerefInt64(req.AccountPunishment.Type)
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
EnsureAccountPunishmentMatchesRoleOfTarget(uid, typ, _DefaultAccount.OpListByMid).
|
|
EnsureSuchAccountPunishmentNotExist(uid, typ, _DefaultAccountPunishment.OpListByMidAndType).
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpCreateAccountPunishment business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpUnblockAccountPunishmentBusinessValidate(ctx *gin.Context, req *accountpunishmentproto.OpUnblockReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeAccountPunishmentSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
EnsureAccountPunishmentHasNotTerminated(util.DerefInt64(req.Id), _DefaultAccountPunishment.OpListById).
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpUnblockAccountPunishment business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetAccountPunishmentListBusinessValidate(ctx *gin.Context, req *accountpunishmentproto.OpListReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeAccountPunishmentSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetAccountPunishmentList business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpGetTerminatedAccountPunishmentListBusinessValidate(ctx *gin.Context, req *accountpunishmentproto.OpListTerminatedReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeAccountPunishmentSrvOk
|
|
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpGetAccountPunishmentList business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpReviewZoneMomentBusinessValidate(ctx *gin.Context, req *zonemomentproto.OpReviewReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeMomentSrvOk
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpReviewMoment business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpHeadZoneMomentBusinessValidate(ctx *gin.Context, req *zonemomentproto.OpHeadReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeMomentSrvOk
|
|
// 1.业务校验
|
|
result := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
QueryAccount(_DefaultAccount.OpListByMid).
|
|
EnsureAccountExist().
|
|
EnsureIsOpRole().
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpHeadMoment business validation failed")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpUpdateZoneThirdPartnerBusinessValidate(ctx *gin.Context, req *zone_third_partner_proto.OpUpdateReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeZoneThirdPartnerSrvOk
|
|
// 1.业务校验
|
|
validator := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
EnsureZoneThirdPartnerIsNotZoneCreater(_DefaultZone.GetById, req.ZoneThirdPartner.GetZid(), req.ZoneThirdPartner.GetThirdPartnerMid()).
|
|
EnsureZoneThirdPartnerSharingRatioIsNotTooLarge(req.ZoneThirdPartner.GetSharingRatio())
|
|
// 若不更新代运营,则确保代运营分成比例足够
|
|
if req.ZoneThirdPartner.ThirdPartnerMid == nil {
|
|
validator.EnsureZoneThirdPartnerSharingRatioIsEnough(func(ctx *gin.Context, zid int64) ([]*dbstruct.ZoneCollaborator, error) {
|
|
return _DefaultZoneCollaborator.OpList(ctx, &zone_collaborator_proto.OpListReq{
|
|
Zid: goproto.Int64(zid),
|
|
})
|
|
}, req.ZoneThirdPartner.GetZid(), req.ZoneThirdPartner.GetSharingRatio())
|
|
}
|
|
result := validator.
|
|
Validate().
|
|
Collect()
|
|
if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk {
|
|
logger.Error("OpUpdateZoneThirdPartner business validation failed")
|
|
return
|
|
}
|
|
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()).
|
|
EnsureZoneThirdPartnerSharingRatioIsNotTooLarge(req.ZoneThirdPartner.GetSharingRatio()).
|
|
Validate().
|
|
Collect()
|
|
ec, _ = result[0].(errcode.ErrCode)
|
|
if ec != errcode.ErrCodeOk {
|
|
logger.Error("OpCreateZoneThirdPartner business validation failed!")
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpCreateZoneMomentBusinessValidate(ctx *gin.Context, req *zonemomentproto.OpCreateReq) (ec errcode.ErrCode, accountpunishment *dbstruct.AccountPunishment, maxZoneMomentCreateTimes int) {
|
|
ec = errcode.ErrCodeMomentSrvOk
|
|
|
|
mediaVisibleRange := int64(0)
|
|
switch req.ZoneMoment.GetCType() {
|
|
case consts.ZoneMomentCType_Free:
|
|
case consts.ZoneMomentCType_Paid:
|
|
mediaVisibleRange = req.ZoneMoment.GetMediaVisibleRange()
|
|
}
|
|
|
|
resultList := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
EnsureMediaIsSuccessfullyUploaded(req.ZoneMoment.MediaComp).
|
|
EnsureZoneMomentImagesEnoughForEncryption(req.ZoneMoment.GetMType(), req.ZoneMoment.MediaComp, mediaVisibleRange).
|
|
EnsureAmongZoneMomentsPaidItemsLessThanFreeItems(_DefaultZoneMoment.OpCountByMidAndCType, req.ZoneMoment.GetMid(), req.ZoneMoment.GetCType()).
|
|
EnsureZoneMomentCreateTimesNotReachedDailyUpperbound(_DefaultZoneMomentCreateTimes.OpGetAndUpdate, req.ZoneMoment.GetMid(), req.ZoneMoment.GetCType()).
|
|
Validate().
|
|
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
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func (s *Service) OpUpdateZoneMomentBusinessValidate(ctx *gin.Context, req *zonemomentproto.OpUpdateReq) (ec errcode.ErrCode) {
|
|
ec = errcode.ErrCodeMomentSrvOk
|
|
|
|
mediaVisibleRange := int64(0)
|
|
switch req.ZoneMoment.GetCType() {
|
|
case consts.ZoneMomentCType_Paid:
|
|
mediaVisibleRange = req.ZoneMoment.GetMediaVisibleRange()
|
|
}
|
|
|
|
resultList := businessvalidator.NewAuthBusinessValidator(ctx, req).
|
|
EnsureMediaIsSuccessfullyUploaded(req.ZoneMoment.MediaComp).
|
|
EnsureZoneMomentImagesEnoughForEncryption(req.ZoneMoment.GetMType(), req.ZoneMoment.MediaComp, mediaVisibleRange).
|
|
Validate().
|
|
Collect()
|
|
ec, _ = resultList[0].(errcode.ErrCode)
|
|
if ec != errcode.ErrCodeOk {
|
|
logger.Error("OpUpdateZoneMomentBusinessValidate business validation failed!")
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|