fix: internal user
CI / changes (push) Successful in 40s
CI / ad (push) Successful in 0s
CI / admin (push) Successful in 0s
CI / bff (push) Successful in 24s
CI / chore (push) Successful in 23s
CI / equipment (push) Successful in 1s
CI / express (push) Successful in 0s
CI / factory (push) Successful in 0s
CI / payment (push) Successful in 1s
CI / product (push) Successful in 0s
CI / record (push) Successful in 0s
CI / sale (push) Successful in 23s
CI / task (push) Successful in 0s
CI / user (push) Successful in 24s
CI / wecom (push) Successful in 0s
CI / changes (push) Successful in 40s
CI / ad (push) Successful in 0s
CI / admin (push) Successful in 0s
CI / bff (push) Successful in 24s
CI / chore (push) Successful in 23s
CI / equipment (push) Successful in 1s
CI / express (push) Successful in 0s
CI / factory (push) Successful in 0s
CI / payment (push) Successful in 1s
CI / product (push) Successful in 0s
CI / record (push) Successful in 0s
CI / sale (push) Successful in 23s
CI / task (push) Successful in 0s
CI / user (push) Successful in 24s
CI / wecom (push) Successful in 0s
This commit is contained in:
@@ -7,12 +7,30 @@ import (
|
||||
"lone-services/pkg/utils"
|
||||
userpb "lone-services/rpc/user/pb"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
const saleClientCode = "sale_beauty"
|
||||
|
||||
func ensureSaleIdentity(ctx context.Context, userSvcName, mobile, password string) (*userpb.InternalCreateData, error) {
|
||||
func checkSaleIdentityCreatable(ctx context.Context, userSvcName, mobile string) error {
|
||||
cli, err := rpcclient.Get(userSvcName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res, err := userpb.NewUserClient(cli.Conn()).InternalCheckCreate(ctx, &userpb.InternalCheckCreateReq{
|
||||
Mobile: mobile,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if res == nil || !res.GetResult() {
|
||||
return status.Error(codes.AlreadyExists, utils.ErrorDataIsExist.Msg)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ensureSaleIdentity(ctx context.Context, userSvcName, mobile, password string, bizId int64) (*userpb.InternalCreateData, error) {
|
||||
cli, err := rpcclient.Get(userSvcName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -22,6 +40,7 @@ func ensureSaleIdentity(ctx context.Context, userSvcName, mobile, password strin
|
||||
ClientCode: []string{saleClientCode},
|
||||
CredentialType: []string{"password"},
|
||||
Secret: password,
|
||||
BizId: bizId,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -48,7 +67,7 @@ func revokeSaleUserClient(ctx context.Context, userSvcName string, userId int64)
|
||||
}
|
||||
|
||||
func reopenSaleUserClient(ctx context.Context, userSvcName, mobile string) (*userpb.InternalCreateData, error) {
|
||||
return ensureSaleIdentity(ctx, userSvcName, mobile, utils.StringEmpty)
|
||||
return ensureSaleIdentity(ctx, userSvcName, mobile, utils.StringEmpty, utils.NumberZero)
|
||||
}
|
||||
|
||||
func userRPCError(err error) (string, bool) {
|
||||
|
||||
Reference in New Issue
Block a user