package user_core_client import ( "context" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/status" "time" ) type GrpcConfig struct { Target string // grpc 目标地址 Timeout time.Duration // 超时时间, 默认为 1秒 } func NewUserCenterApi(platformCode string, grpcConfig *GrpcConfig) (UserCenterApi, func(), error) { grpcConn, err := grpc.NewClient(grpcConfig.Target, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { return nil, nil, err } return &userCenterApi{ platformCode: platformCode, grpcConfig: grpcConfig, grpcConn: grpcConn, }, func() { _ = grpcConn.Close() }, nil } type userCenterApi struct { platformCode string grpcConfig *GrpcConfig grpcConn *grpc.ClientConn } func (u *userCenterApi) Verify(ctx context.Context, token string) (*TokenClaims, error) { //TODO implement me st := status.Convert(nil) st.Code() panic("implement me") } func (u *userCenterApi) GetPhoneTextByToken(ctx context.Context, token string) (string, error) { //TODO implement me panic("implement me") } func (u *userCenterApi) GetPhoneTextByUID(ctx context.Context, uid int64) (string, error) { //TODO implement me panic("implement me") } func (u *userCenterApi) UpdateUserByUID(ctx context.Context, uid int64, user *UpdateUserReq) (*User, error) { //TODO implement me panic("implement me") }