by Robin at 20231222; op list by userid

This commit is contained in:
Leufolium 2023-12-22 17:00:57 +08:00
parent 4b56ad1be5
commit a39852ff69
3 changed files with 25 additions and 1 deletions

View File

@ -201,7 +201,7 @@ func Init(r *gin.Engine) {
opAccountGroup.POST("update", middleware.JSONParamValidator(accountproto.OpUpdateReq{}), middleware.JwtAuthenticator(), middleware.RequestDecryptor(), OpUpdateAccount)
//opAccountGroup.POST("list_by_mid", middleware.JSONParamValidator(accountproto.OpListByMidReq{}), middleware.JwtAuthenticator(), OpGetAccountListByMid)
//opAccountGroup.POST("list_by_mids", middleware.JSONParamValidator(accountproto.OpListByMidsReq{}), middleware.JwtAuthenticator(), OpGetAccountListByMids)
//opAccountGroup.POST("list_by_user_id", middleware.JSONParamValidator(accountproto.OpListByUserIdReq{}), middleware.JwtAuthenticator(), OpGetAccountListByUserId)
opAccountGroup.POST("list_by_user_id", middleware.JSONParamValidator(accountproto.OpListByUserIdReq{}), middleware.JwtAuthenticator(), OpGetAccountListByUserId)
opAccountGroup.POST("list_fuzzily_by_user_id", middleware.JSONParamValidator(accountproto.OpListFuzzilyByUserIdReq{}), middleware.JwtAuthenticator(), OpGetAccountListFuzzilyByUserId)
opAccountGroup.POST("list_fuzzily_by_name", middleware.JSONParamValidator(accountproto.OpListFuzzilyByNameReq{}), middleware.JwtAuthenticator(), OpGetAccountListFuzzilyByName)
opAccountGroup.POST("list_others_by_mid", middleware.JSONParamValidator(accountproto.OpListOthersByMidReq{}), middleware.JwtAuthenticator(), OpGetAccountListForOthersByMid)

View File

@ -218,6 +218,24 @@ func (s *Service) OpUpdateAccountBusinessValidate(ctx *gin.Context, req *account
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) OpGetAccountListFuzzilyByUserIdBusinessValidate(ctx *gin.Context, req *accountproto.OpListFuzzilyByUserIdReq) (ec errcode.ErrCode) {
ec = errcode.ErrCodeAccountSrvOk

View File

@ -775,6 +775,12 @@ func (s *Service) OpGetAccountListByMids(ctx *gin.Context, req *accountproto.OpL
func (s *Service) OpGetAccountListByUserId(ctx *gin.Context, req *accountproto.OpListByUserIdReq) (vo *accountproto.OpListVO, ec errcode.ErrCode) {
ec = errcode.ErrCodeAccountSrvOk
// 业务鉴权
if ec = s.OpGetAccountListByUserIdBusinessValidate(ctx, req); ec != errcode.ErrCodeAccountSrvOk {
return
}
account, err := _DefaultAccount.OpListByUserId(ctx, req)
if err != nil {
logger.Error("OpListByUserId fail, err: %v", err)