user

package
v0.0.0-...-8d35329 Latest Latest
Warning

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

Go to latest
Published: May 9, 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

This section is empty.

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_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.

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.

func RegisterUserServer

func RegisterUserServer(s grpc.ServiceRegistrar, srv UserServer)

Types

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"`                   // 验证码
	// 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) 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 {
	Account         string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"`                                        // 账户
	Nickname        string `protobuf:"bytes,2,opt,name=nickname,proto3" json:"nickname,omitempty"`                                      // 昵称
	Password        string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"`                                      // 密码
	ConfirmPassword string `protobuf:"bytes,4,opt,name=confirm_password,json=confirmPassword,proto3" json:"confirm_password,omitempty"` // 确认密码
	Mobile          string `protobuf:"bytes,5,opt,name=mobile,proto3" json:"mobile,omitempty"`                                          // 手机号
	MobileCache     string `protobuf:"bytes,6,opt,name=mobile_cache,json=mobileCache,proto3" json:"mobile_cache,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) GetAccount

func (x *RegisterReq) GetAccount() string

func (*RegisterReq) GetConfirmPassword

func (x *RegisterReq) GetConfirmPassword() string

func (*RegisterReq) GetImgCache

func (x *RegisterReq) GetImgCache() string

func (*RegisterReq) GetMobile

func (x *RegisterReq) GetMobile() string

func (*RegisterReq) GetMobileCache

func (x *RegisterReq) GetMobileCache() string

func (*RegisterReq) GetNickname

func (x *RegisterReq) GetNickname() string

func (*RegisterReq) GetPassword

func (x *RegisterReq) GetPassword() 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.

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 {
	Userinfo  *UserInfo  `protobuf:"bytes,1,opt,name=userinfo,proto3" json:"userinfo,omitempty"`                    // 用户登录信息
	TokenInfo *base.Auth `protobuf:"bytes,2,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() *base.Auth

func (*UserAuthRes) GetUserinfo

func (x *UserAuthRes) GetUserinfo() *UserInfo

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.

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

Jump to

Keyboard shortcuts

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