feat:完善项目
This commit is contained in:
39
rpc/client/handle/account.go
Normal file
39
rpc/client/handle/account.go
Normal file
@ -0,0 +1,39 @@
|
||||
package handle
|
||||
|
||||
import (
|
||||
"SciencesServer/rpc/client"
|
||||
"SciencesServer/rpc/client/proto"
|
||||
"context"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type Account struct{}
|
||||
|
||||
// RegisterHandle register handle
|
||||
type RegisterHandle func(tenant, uid string) (*proto.RegisterResponse, error)
|
||||
|
||||
// Register 注册
|
||||
func (this *Account) Register() RegisterHandle {
|
||||
return func(tenant, uid string) (*proto.RegisterResponse, error) {
|
||||
resp := new(proto.RegisterResponse)
|
||||
|
||||
err := client.MQTTServerClient.Handle(func(conn *grpc.ClientConn) error {
|
||||
var err error
|
||||
// 初始化客户端
|
||||
cc := proto.NewAccountHandleClient(conn)
|
||||
|
||||
req := &proto.RegisterRequest{
|
||||
Tenant: tenant, Uid: uid,
|
||||
}
|
||||
resp, err = cc.RegisterHandle(context.Background(), req)
|
||||
|
||||
return err
|
||||
}, &client.Auth{Value: "bearer grpc.auth.token"})
|
||||
return resp, err
|
||||
}
|
||||
}
|
||||
|
||||
func NewAccountClient() *Account {
|
||||
return &Account{}
|
||||
}
|
Reference in New Issue
Block a user