user

package
v0.0.0-...-57fd995 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

Package user is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	User_Register_FullMethodName = "/user.v1.User/Register"
	User_Login_FullMethodName    = "/user.v1.User/Login"
)

Variables

View Source
var (
	LoginType_name = map[int32]string{
		0: "Detault_Login",
		1: "Mobile_Login",
	}
	LoginType_value = map[string]int32{
		"Detault_Login": 0,
		"Mobile_Login":  1,
	}
)

Enum value maps for LoginType.

View Source
var File_user_token_proto protoreflect.FileDescriptor
View Source
var File_user_user_proto protoreflect.FileDescriptor
View Source
var User_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "user.v1.User",
	HandlerType: (*UserServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Register",
			Handler:    _User_Register_Handler,
		},
		{
			MethodName: "Login",
			Handler:    _User_Login_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "user/user.proto",
}

User_ServiceDesc is the grpc.ServiceDesc for User service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterUserHandler

func RegisterUserHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterUserHandler registers the http handlers for service User to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterUserHandlerClient

func RegisterUserHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UserClient) error

RegisterUserHandlerClient registers the http handlers for service User to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "UserClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "UserClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "UserClient" to call the correct interceptors. This client ignores the HTTP middlewares.

func RegisterUserHandlerFromEndpoint

func RegisterUserHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterUserHandlerFromEndpoint is same as RegisterUserHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterUserHandlerServer

func RegisterUserHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UserServer) error

RegisterUserHandlerServer registers the http handlers for service User to "mux". UnaryRPC :call UserServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterUserHandlerFromEndpoint instead. GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.

func RegisterUserServer

func RegisterUserServer(s grpc.ServiceRegistrar, srv UserServer)

Types

type Auth

type Auth struct {
	Token  string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`    // 认证token
	Expire int64  `protobuf:"varint,2,opt,name=expire,proto3" json:"expire,omitempty"` // 认证过期时间
	// contains filtered or unexported fields
}

token 信息

func (*Auth) Descriptor deprecated

func (*Auth) Descriptor() ([]byte, []int)

Deprecated: Use Auth.ProtoReflect.Descriptor instead.

func (*Auth) GetExpire

func (x *Auth) GetExpire() int64

func (*Auth) GetToken

func (x *Auth) GetToken() string

func (*Auth) ProtoMessage

func (*Auth) ProtoMessage()

func (*Auth) ProtoReflect

func (x *Auth) ProtoReflect() protoreflect.Message

func (*Auth) Reset

func (x *Auth) Reset()

func (*Auth) String

func (x *Auth) String() string

func (*Auth) Validate

func (m *Auth) Validate() error

Validate checks the field values on Auth with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*Auth) ValidateAll

func (m *Auth) ValidateAll() error

ValidateAll checks the field values on Auth with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in AuthMultiError, or nil if none found.

type AuthMultiError

type AuthMultiError []error

AuthMultiError is an error wrapping multiple validation errors returned by Auth.ValidateAll() if the designated constraints aren't met.

func (AuthMultiError) AllErrors

func (m AuthMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (AuthMultiError) Error

func (m AuthMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type AuthValidationError

type AuthValidationError struct {
	// contains filtered or unexported fields
}

AuthValidationError is the validation error returned by Auth.Validate if the designated constraints aren't met.

func (AuthValidationError) Cause

func (e AuthValidationError) Cause() error

Cause function returns cause value.

func (AuthValidationError) Error

func (e AuthValidationError) Error() string

Error satisfies the builtin error interface

func (AuthValidationError) ErrorName

func (e AuthValidationError) ErrorName() string

ErrorName returns error name.

func (AuthValidationError) Field

func (e AuthValidationError) Field() string

Field function returns field value.

func (AuthValidationError) Key

func (e AuthValidationError) Key() bool

Key function returns key value.

func (AuthValidationError) Reason

func (e AuthValidationError) Reason() string

Reason function returns reason value.

type LoginReq

type LoginReq struct {
	Type      LoginType `protobuf:"varint,1,opt,name=type,proto3,enum=user.v1.LoginType" json:"type,omitempty"`    // 登录类型
	Account   string    `protobuf:"bytes,2,opt,name=account,proto3" json:"account,omitempty"`                      // 账号
	Password  string    `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"`                    // 认证密码
	Captcha   string    `protobuf:"bytes,4,opt,name=captcha,proto3" json:"captcha,omitempty"`                      // 验证码
	CaptchaId string    `protobuf:"bytes,5,opt,name=captcha_id,json=captchaId,proto3" json:"captcha_id,omitempty"` // 验证码id
	// contains filtered or unexported fields
}

登录请求

func (*LoginReq) Descriptor deprecated

func (*LoginReq) Descriptor() ([]byte, []int)

Deprecated: Use LoginReq.ProtoReflect.Descriptor instead.

func (*LoginReq) GetAccount

func (x *LoginReq) GetAccount() string

func (*LoginReq) GetCaptcha

func (x *LoginReq) GetCaptcha() string

func (*LoginReq) GetCaptchaId

func (x *LoginReq) GetCaptchaId() string

func (*LoginReq) GetPassword

func (x *LoginReq) GetPassword() string

func (*LoginReq) GetType

func (x *LoginReq) GetType() LoginType

func (*LoginReq) ProtoMessage

func (*LoginReq) ProtoMessage()

func (*LoginReq) ProtoReflect

func (x *LoginReq) ProtoReflect() protoreflect.Message

func (*LoginReq) Reset

func (x *LoginReq) Reset()

func (*LoginReq) String

func (x *LoginReq) String() string

func (*LoginReq) Validate

func (m *LoginReq) Validate() error

Validate checks the field values on LoginReq with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*LoginReq) ValidateAll

func (m *LoginReq) ValidateAll() error

ValidateAll checks the field values on LoginReq with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in LoginReqMultiError, or nil if none found.

type LoginReqMultiError

type LoginReqMultiError []error

LoginReqMultiError is an error wrapping multiple validation errors returned by LoginReq.ValidateAll() if the designated constraints aren't met.

func (LoginReqMultiError) AllErrors

func (m LoginReqMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (LoginReqMultiError) Error

func (m LoginReqMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type LoginReqValidationError

type LoginReqValidationError struct {
	// contains filtered or unexported fields
}

LoginReqValidationError is the validation error returned by LoginReq.Validate if the designated constraints aren't met.

func (LoginReqValidationError) Cause

func (e LoginReqValidationError) Cause() error

Cause function returns cause value.

func (LoginReqValidationError) Error

func (e LoginReqValidationError) Error() string

Error satisfies the builtin error interface

func (LoginReqValidationError) ErrorName

func (e LoginReqValidationError) ErrorName() string

ErrorName returns error name.

func (LoginReqValidationError) Field

func (e LoginReqValidationError) Field() string

Field function returns field value.

func (LoginReqValidationError) Key

func (e LoginReqValidationError) Key() bool

Key function returns key value.

func (LoginReqValidationError) Reason

func (e LoginReqValidationError) Reason() string

Reason function returns reason value.

type LoginType

type LoginType int32

登录类型

const (
	LoginType_Detault_Login LoginType = 0 // 邮箱密码登录
	LoginType_Mobile_Login  LoginType = 1 // 手机验证码登录
)

func (LoginType) Descriptor

func (LoginType) Descriptor() protoreflect.EnumDescriptor

func (LoginType) Enum

func (x LoginType) Enum() *LoginType

func (LoginType) EnumDescriptor deprecated

func (LoginType) EnumDescriptor() ([]byte, []int)

Deprecated: Use LoginType.Descriptor instead.

func (LoginType) Number

func (x LoginType) Number() protoreflect.EnumNumber

func (LoginType) String

func (x LoginType) String() string

func (LoginType) Type

type RegisterReq

type RegisterReq struct {
	Password        string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"`                                      // 密码
	Username        string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`                                      // 用户名
	Email           string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`                                            // 邮箱
	ConfirmPassword string `protobuf:"bytes,4,opt,name=confirm_password,json=confirmPassword,proto3" json:"confirm_password,omitempty"` // 确认密码
	ImgCache        string `protobuf:"bytes,7,opt,name=img_cache,json=imgCache,proto3" json:"img_cache,omitempty"`                      // 图形验证码
	// contains filtered or unexported fields
}

注册请求

func (*RegisterReq) Descriptor deprecated

func (*RegisterReq) Descriptor() ([]byte, []int)

Deprecated: Use RegisterReq.ProtoReflect.Descriptor instead.

func (*RegisterReq) GetConfirmPassword

func (x *RegisterReq) GetConfirmPassword() string

func (*RegisterReq) GetEmail

func (x *RegisterReq) GetEmail() string

func (*RegisterReq) GetImgCache

func (x *RegisterReq) GetImgCache() string

func (*RegisterReq) GetPassword

func (x *RegisterReq) GetPassword() string

func (*RegisterReq) GetUsername

func (x *RegisterReq) GetUsername() string

func (*RegisterReq) ProtoMessage

func (*RegisterReq) ProtoMessage()

func (*RegisterReq) ProtoReflect

func (x *RegisterReq) ProtoReflect() protoreflect.Message

func (*RegisterReq) Reset

func (x *RegisterReq) Reset()

func (*RegisterReq) String

func (x *RegisterReq) String() string

func (*RegisterReq) Validate

func (m *RegisterReq) Validate() error

Validate checks the field values on RegisterReq with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*RegisterReq) ValidateAll

func (m *RegisterReq) ValidateAll() error

ValidateAll checks the field values on RegisterReq with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in RegisterReqMultiError, or nil if none found.

type RegisterReqMultiError

type RegisterReqMultiError []error

RegisterReqMultiError is an error wrapping multiple validation errors returned by RegisterReq.ValidateAll() if the designated constraints aren't met.

func (RegisterReqMultiError) AllErrors

func (m RegisterReqMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (RegisterReqMultiError) Error

func (m RegisterReqMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type RegisterReqValidationError

type RegisterReqValidationError struct {
	// contains filtered or unexported fields
}

RegisterReqValidationError is the validation error returned by RegisterReq.Validate if the designated constraints aren't met.

func (RegisterReqValidationError) Cause

Cause function returns cause value.

func (RegisterReqValidationError) Error

Error satisfies the builtin error interface

func (RegisterReqValidationError) ErrorName

func (e RegisterReqValidationError) ErrorName() string

ErrorName returns error name.

func (RegisterReqValidationError) Field

Field function returns field value.

func (RegisterReqValidationError) Key

Key function returns key value.

func (RegisterReqValidationError) Reason

Reason function returns reason value.

type UnimplementedUserServer

type UnimplementedUserServer struct{}

UnimplementedUserServer should be embedded to have forward compatible implementations.

NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.

func (UnimplementedUserServer) Login

func (UnimplementedUserServer) Register

type UnsafeUserServer

type UnsafeUserServer interface {
	// contains filtered or unexported methods
}

UnsafeUserServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to UserServer will result in compilation errors.

type UserAuthRes

type UserAuthRes struct {
	TokenInfo *Auth `protobuf:"bytes,1,opt,name=token_info,json=tokenInfo,proto3" json:"token_info,omitempty"` // token认证信息
	// contains filtered or unexported fields
}

登录注册返回信息

func (*UserAuthRes) Descriptor deprecated

func (*UserAuthRes) Descriptor() ([]byte, []int)

Deprecated: Use UserAuthRes.ProtoReflect.Descriptor instead.

func (*UserAuthRes) GetTokenInfo

func (x *UserAuthRes) GetTokenInfo() *Auth

func (*UserAuthRes) ProtoMessage

func (*UserAuthRes) ProtoMessage()

func (*UserAuthRes) ProtoReflect

func (x *UserAuthRes) ProtoReflect() protoreflect.Message

func (*UserAuthRes) Reset

func (x *UserAuthRes) Reset()

func (*UserAuthRes) String

func (x *UserAuthRes) String() string

func (*UserAuthRes) Validate

func (m *UserAuthRes) Validate() error

Validate checks the field values on UserAuthRes with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*UserAuthRes) ValidateAll

func (m *UserAuthRes) ValidateAll() error

ValidateAll checks the field values on UserAuthRes with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in UserAuthResMultiError, or nil if none found.

type UserAuthResMultiError

type UserAuthResMultiError []error

UserAuthResMultiError is an error wrapping multiple validation errors returned by UserAuthRes.ValidateAll() if the designated constraints aren't met.

func (UserAuthResMultiError) AllErrors

func (m UserAuthResMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (UserAuthResMultiError) Error

func (m UserAuthResMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type UserAuthResValidationError

type UserAuthResValidationError struct {
	// contains filtered or unexported fields
}

UserAuthResValidationError is the validation error returned by UserAuthRes.Validate if the designated constraints aren't met.

func (UserAuthResValidationError) Cause

Cause function returns cause value.

func (UserAuthResValidationError) Error

Error satisfies the builtin error interface

func (UserAuthResValidationError) ErrorName

func (e UserAuthResValidationError) ErrorName() string

ErrorName returns error name.

func (UserAuthResValidationError) Field

Field function returns field value.

func (UserAuthResValidationError) Key

Key function returns key value.

func (UserAuthResValidationError) Reason

Reason function returns reason value.

type UserClient

type UserClient interface {
	Register(ctx context.Context, in *RegisterReq, opts ...grpc.CallOption) (*UserAuthRes, error)
	// Login 用户登录
	Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*UserAuthRes, error)
}

UserClient is the client API for User service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

User 用户管理

func NewUserClient

func NewUserClient(cc grpc.ClientConnInterface) UserClient

type UserInfo

type UserInfo struct {
	Account  string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"`   // 用户账号
	Nickname string `protobuf:"bytes,2,opt,name=nickname,proto3" json:"nickname,omitempty"` // 用户昵称
	Mobile   string `protobuf:"bytes,3,opt,name=mobile,proto3" json:"mobile,omitempty"`
	// contains filtered or unexported fields
}

用户信息

func (*UserInfo) Descriptor deprecated

func (*UserInfo) Descriptor() ([]byte, []int)

Deprecated: Use UserInfo.ProtoReflect.Descriptor instead.

func (*UserInfo) GetAccount

func (x *UserInfo) GetAccount() string

func (*UserInfo) GetMobile

func (x *UserInfo) GetMobile() string

func (*UserInfo) GetNickname

func (x *UserInfo) GetNickname() string

func (*UserInfo) ProtoMessage

func (*UserInfo) ProtoMessage()

func (*UserInfo) ProtoReflect

func (x *UserInfo) ProtoReflect() protoreflect.Message

func (*UserInfo) Reset

func (x *UserInfo) Reset()

func (*UserInfo) String

func (x *UserInfo) String() string

func (*UserInfo) Validate

func (m *UserInfo) Validate() error

Validate checks the field values on UserInfo with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*UserInfo) ValidateAll

func (m *UserInfo) ValidateAll() error

ValidateAll checks the field values on UserInfo with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in UserInfoMultiError, or nil if none found.

type UserInfoMultiError

type UserInfoMultiError []error

UserInfoMultiError is an error wrapping multiple validation errors returned by UserInfo.ValidateAll() if the designated constraints aren't met.

func (UserInfoMultiError) AllErrors

func (m UserInfoMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (UserInfoMultiError) Error

func (m UserInfoMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type UserInfoValidationError

type UserInfoValidationError struct {
	// contains filtered or unexported fields
}

UserInfoValidationError is the validation error returned by UserInfo.Validate if the designated constraints aren't met.

func (UserInfoValidationError) Cause

func (e UserInfoValidationError) Cause() error

Cause function returns cause value.

func (UserInfoValidationError) Error

func (e UserInfoValidationError) Error() string

Error satisfies the builtin error interface

func (UserInfoValidationError) ErrorName

func (e UserInfoValidationError) ErrorName() string

ErrorName returns error name.

func (UserInfoValidationError) Field

func (e UserInfoValidationError) Field() string

Field function returns field value.

func (UserInfoValidationError) Key

func (e UserInfoValidationError) Key() bool

Key function returns key value.

func (UserInfoValidationError) Reason

func (e UserInfoValidationError) Reason() string

Reason function returns reason value.

type UserServer

type UserServer interface {
	Register(context.Context, *RegisterReq) (*UserAuthRes, error)
	// Login 用户登录
	Login(context.Context, *LoginReq) (*UserAuthRes, error)
}

UserServer is the server API for User service. All implementations should embed UnimplementedUserServer for forward compatibility.

User 用户管理

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL