Merge pull request 'by Robin at 20240222; add mobile phone get' (#127) from feat-IRONFANS-57-Robin into main
Reviewed-on: #127
This commit is contained in:
commit
4f7246d133
|
@ -97,6 +97,21 @@ type OpListByUserIdResp struct {
|
|||
Data *OpListByUserIdData `json:"data"`
|
||||
}
|
||||
|
||||
// 根据UserId查询手机号
|
||||
type OpGetMobilePhoneByUserIdReq struct {
|
||||
base.BaseRequest
|
||||
UserId *int64 `json:"user_id"` //user_id查询
|
||||
}
|
||||
|
||||
type OpGetMobilePhoneByUserIdData struct {
|
||||
MobilePhone string `json:"mobile_phone"`
|
||||
}
|
||||
|
||||
type OpGetMobilePhoneByUserIdResp struct {
|
||||
base.BaseResponse
|
||||
Data *OpGetMobilePhoneByUserIdData `json:"data"`
|
||||
}
|
||||
|
||||
// 根据UserId模糊查询(和姓名取交集)
|
||||
type OpListFuzzilyByUserIdReq struct {
|
||||
base.BaseRequest
|
||||
|
|
|
@ -23,6 +23,12 @@ func (p *OpListByUserIdReq) ProvideNotNullValue() (params []*validator.JsonParam
|
|||
return params
|
||||
}
|
||||
|
||||
func (p *OpGetMobilePhoneByUserIdReq) ProvideNotNullValue() (params []*validator.JsonParam) {
|
||||
params = make([]*validator.JsonParam, 1)
|
||||
params[0] = validator.NewInt64PtrParam("查询UserId不可为空!", p.UserId)
|
||||
return params
|
||||
}
|
||||
|
||||
func (p *OpListFuzzilyByUserIdReq) ProvideNotNullValue() (params []*validator.JsonParam) {
|
||||
params = make([]*validator.JsonParam, 1)
|
||||
params[0] = validator.NewInt64PtrParam("查询UserId不可为空!", p.UserId)
|
||||
|
|
|
@ -98,6 +98,23 @@ func OpGetAccountListByUserId(ctx *gin.Context) {
|
|||
ReplyOk(ctx, data)
|
||||
}
|
||||
|
||||
func OpGetMobilePhoneByUserId(ctx *gin.Context) {
|
||||
req := ctx.MustGet("client_req").(*accountproto.OpGetMobilePhoneByUserIdReq)
|
||||
|
||||
mobilePhone, ec := service.DefaultService.OpGetMobilePhoneByUserId(ctx, req)
|
||||
if ec != errcode.ErrCodeAccountSrvOk {
|
||||
logger.Error("OpGetMobilePhoneByUserId fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||
ReplyErrCodeMsg(ctx, ec)
|
||||
return
|
||||
}
|
||||
|
||||
data := &accountproto.OpGetMobilePhoneByUserIdData{
|
||||
MobilePhone: mobilePhone,
|
||||
}
|
||||
|
||||
ReplyOk(ctx, data)
|
||||
}
|
||||
|
||||
func OpGetAccountListFuzzilyByUserId(ctx *gin.Context) {
|
||||
req := ctx.MustGet("client_req").(*accountproto.OpListFuzzilyByUserIdReq)
|
||||
|
||||
|
|
|
@ -252,6 +252,7 @@ func Init(r *gin.Engine) {
|
|||
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("get_mobile_phone_by_user_id", middleware.JSONParamValidator(accountproto.OpGetMobilePhoneByUserIdReq{}), middleware.JwtAuthenticator(), OpGetMobilePhoneByUserId)
|
||||
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)
|
||||
|
|
|
@ -266,6 +266,24 @@ func (s *Service) OpGetAccountListByUserIdBusinessValidate(ctx *gin.Context, req
|
|||
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) OpGetAccountListFuzzilyByUserIdBusinessValidate(ctx *gin.Context, req *accountproto.OpListFuzzilyByUserIdReq) (ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeAccountSrvOk
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"service/api/base"
|
||||
|
@ -820,6 +821,32 @@ func (s *Service) OpGetAccountListByUserId(ctx *gin.Context, req *accountproto.O
|
|||
return
|
||||
}
|
||||
|
||||
func (s *Service) OpGetMobilePhoneByUserId(ctx *gin.Context, req *accountproto.OpGetMobilePhoneByUserIdReq) (mobilePhone string, ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeAccountSrvOk
|
||||
|
||||
// 业务鉴权
|
||||
if ec = s.OpGetMobilePhoneByUserIdBusinessValidate(ctx, req); ec != errcode.ErrCodeAccountSrvOk {
|
||||
return
|
||||
}
|
||||
|
||||
account, err := _DefaultAccount.OpListByUserId(ctx, &accountproto.OpListByUserIdReq{
|
||||
UserId: req.UserId,
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error("OpListByUserId fail, err: %v", err)
|
||||
ec = errcode.ErrCodeAccountSrvFail
|
||||
return
|
||||
}
|
||||
if account != nil {
|
||||
base64DecryptedBytes, _ := base64.StdEncoding.DecodeString(util.DerefString(account.MobilePhone))
|
||||
phoneBytes, _ := mycrypto.CryptoServiceInstance().AES.Decrypt(base64DecryptedBytes)
|
||||
mobilePhone = string(phoneBytes)
|
||||
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Service) OpGetAccountListFuzzilyByUserId(ctx *gin.Context, req *accountproto.OpListFuzzilyByUserIdReq) (volist []*accountproto.OpListVO, ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeAccountSrvOk
|
||||
|
||||
|
|
Loading…
Reference in New Issue