Documentation ¶
Overview ¶
Package user is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Constants
- Variables
- func MarshalGender(x Gender) graphql.Marshaler
- func MarshalRole(x Role) graphql.Marshaler
- func MarshalUserStatus(x UserStatus) graphql.Marshaler
- func RegisterUserServiceHandler(ctx context.Context, mux *gin.Engine, conn *grpc.ClientConn) error
- func RegisterUserServiceHandlerClient(ctx context.Context, mux *gin.Engine, client UserServiceClient) error
- func RegisterUserServiceHandlerFromEndpoint(ctx context.Context, mux *gin.Engine, endpoint string, opts []grpc.DialOption) (err error)
- func RegisterUserServiceHandlerServer(mux *gin.Engine, server UserServiceServer) error
- func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer)
- type Gender
- func (Gender) Descriptor() protoreflect.EnumDescriptor
- func (x Gender) Enum() *Gender
- func (Gender) EnumDescriptor() ([]byte, []int)deprecated
- func (x Gender) MarshalGQL(w io.Writer)
- func (x Gender) Number() protoreflect.EnumNumber
- func (x Gender) OrigString() string
- func (x Gender) String() string
- func (Gender) Type() protoreflect.EnumType
- func (x *Gender) UnmarshalGQL(v interface{}) error
- type Role
- func (Role) Descriptor() protoreflect.EnumDescriptor
- func (x Role) Enum() *Role
- func (Role) EnumDescriptor() ([]byte, []int)deprecated
- func (x Role) MarshalGQL(w io.Writer)
- func (x Role) Number() protoreflect.EnumNumber
- func (x Role) OrigString() string
- func (x Role) String() string
- func (Role) Type() protoreflect.EnumType
- func (x *Role) UnmarshalGQL(v interface{}) error
- type SignupReq
- func (*SignupReq) Descriptor() ([]byte, []int)deprecated
- func (x *SignupReq) GetGender() Gender
- func (x *SignupReq) GetMail() string
- func (x *SignupReq) GetName() string
- func (x *SignupReq) GetPassword() string
- func (x *SignupReq) GetPhone() string
- func (x *SignupReq) GetVCode() string
- func (*SignupReq) ProtoMessage()
- func (x *SignupReq) ProtoReflect() protoreflect.Message
- func (x *SignupReq) Reset()
- func (x *SignupReq) String() string
- func (this *SignupReq) Validate() error
- type SignupReqInput
- type UnimplementedUserServiceServer
- type UnsafeUserServiceServer
- type User
- func (*User) Descriptor() ([]byte, []int)deprecated
- func (x *User) GetActivatedAt() string
- func (x *User) GetCreatedAt() string
- func (x *User) GetDeletedAt() string
- func (x *User) GetGender() Gender
- func (x *User) GetId() uint64
- func (x *User) GetMail() string
- func (x *User) GetName() string
- func (x *User) GetPassword() string
- func (x *User) GetPhone() string
- func (x *User) GetRole() Role
- func (x *User) GetStatus() UserStatus
- func (*User) ProtoMessage()
- func (x *User) ProtoReflect() protoreflect.Message
- func (x *User) Reset()
- func (x *User) String() string
- func (this *User) Validate() error
- type UserInput
- type UserServiceClient
- type UserServiceResolvers
- type UserServiceServer
- type UserStatus
- func (UserStatus) Descriptor() protoreflect.EnumDescriptor
- func (x UserStatus) Enum() *UserStatus
- func (UserStatus) EnumDescriptor() ([]byte, []int)deprecated
- func (x UserStatus) MarshalGQL(w io.Writer)
- func (x UserStatus) Number() protoreflect.EnumNumber
- func (x UserStatus) OrigString() string
- func (x UserStatus) String() string
- func (UserStatus) Type() protoreflect.EnumType
- func (x *UserStatus) UnmarshalGQL(v interface{}) error
Constants ¶
const (
UserService_Signup_FullMethodName = "/user.UserService/Signup"
)
Variables ¶
var ( Gender_name = map[int32]string{ 0: "GenderPlaceholder", 1: "GenderUnfilled", 2: "GenderMale", 3: "GenderFemale", } Gender_value = map[string]int32{ "GenderPlaceholder": 0, "GenderUnfilled": 1, "GenderMale": 2, "GenderFemale": 3, } )
Enum value maps for Gender.
var ( Role_name = map[int32]string{ 0: "PlaceholderRole", 1: "RoleNormal", 2: "RoleAdmin", 3: "RoleSuperAdmin", } Role_value = map[string]int32{ "PlaceholderRole": 0, "RoleNormal": 1, "RoleAdmin": 2, "RoleSuperAdmin": 3, } )
Enum value maps for Role.
var ( UserStatus_name = map[int32]string{ 0: "UserStatusPlaceholder", 1: "UserStatusInActive", 2: "UserStatusActivated", 3: "UserStatusFrozen", 4: "UserStatusDeleted", } UserStatus_value = map[string]int32{ "UserStatusPlaceholder": 0, "UserStatusInActive": 1, "UserStatusActivated": 2, "UserStatusFrozen": 3, "UserStatusDeleted": 4, } )
Enum value maps for UserStatus.
var File_user_user_enum_proto protoreflect.FileDescriptor
var File_user_user_proto protoreflect.FileDescriptor
var UserService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "user.UserService", HandlerType: (*UserServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Signup", Handler: _UserService_Signup_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "user/user.proto", }
UserService_ServiceDesc is the grpc.ServiceDesc for UserService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func MarshalGender ¶
func MarshalRole ¶
func MarshalUserStatus ¶
func MarshalUserStatus(x UserStatus) graphql.Marshaler
func RegisterUserServiceHandler ¶
RegisterUserServiceHandler registers the http handlers for service UserService to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterUserServiceHandlerClient ¶
func RegisterUserServiceHandlerClient(ctx context.Context, mux *gin.Engine, client UserServiceClient) error
RegisterUserServiceHandlerClient registers the http handlers for service UserService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "UserServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "UserServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "UserServiceClient" to call the correct interceptors.
func RegisterUserServiceHandlerFromEndpoint ¶
func RegisterUserServiceHandlerFromEndpoint(ctx context.Context, mux *gin.Engine, endpoint string, opts []grpc.DialOption) (err error)
RegisterUserServiceHandlerFromEndpoint is same as RegisterUserServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterUserServiceHandlerServer ¶
func RegisterUserServiceHandlerServer(mux *gin.Engine, server UserServiceServer) error
RegisterUserServiceHandlerServer registers the http handlers for service UserService to "mux". UnaryRPC :call UserServiceServer 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 RegisterUserServiceHandlerFromEndpoint instead.
func RegisterUserServiceServer ¶
func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer)
Types ¶
type Gender ¶
type Gender int32
用户性别
func UnmarshalGender ¶
func (Gender) Descriptor ¶
func (Gender) Descriptor() protoreflect.EnumDescriptor
func (Gender) EnumDescriptor
deprecated
func (Gender) MarshalGQL ¶
func (Gender) Number ¶
func (x Gender) Number() protoreflect.EnumNumber
func (Gender) OrigString ¶
func (Gender) Type ¶
func (Gender) Type() protoreflect.EnumType
func (*Gender) UnmarshalGQL ¶
type Role ¶
type Role int32
用户角色
func UnmarshalRole ¶
func (Role) Descriptor ¶
func (Role) Descriptor() protoreflect.EnumDescriptor
func (Role) EnumDescriptor
deprecated
func (Role) MarshalGQL ¶
func (Role) Number ¶
func (x Role) Number() protoreflect.EnumNumber
func (Role) OrigString ¶
func (Role) Type ¶
func (Role) Type() protoreflect.EnumType
func (*Role) UnmarshalGQL ¶
type SignupReq ¶
type SignupReq struct { // 密码 Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty" validate:"required,gte=6,lte=15" annotation:"密码"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty" validate:"required,gte=3,lte=10" annotation:"昵称"` Gender Gender `protobuf:"varint,3,opt,name=gender,proto3,enum=user.Gender" json:"gender,omitempty" validate:"required" annotation:"性别"` // 邮箱 Mail string `protobuf:"bytes,6,opt,name=mail,proto3" json:"mail,omitempty" validate:"omitempty,email" annotation:"邮箱"` // 手机号 Phone string `protobuf:"bytes,7,opt,name=phone,proto3" json:"phone,omitempty" validate:"omitempty,phone" annotation:"手机号"` // 验证码 VCode string `protobuf:"bytes,8,opt,name=vCode,proto3" json:"vCode,omitempty" validate:"required" annotation:"验证码"` // contains filtered or unexported fields }
func (*SignupReq) Descriptor
deprecated
func (*SignupReq) GetPassword ¶
func (*SignupReq) ProtoMessage ¶
func (*SignupReq) ProtoMessage()
func (*SignupReq) ProtoReflect ¶
func (x *SignupReq) ProtoReflect() protoreflect.Message
type SignupReqInput ¶
type SignupReqInput = SignupReq
type UnimplementedUserServiceServer ¶
type UnimplementedUserServiceServer struct { }
UnimplementedUserServiceServer must be embedded to have forward compatible implementations.
func (UnimplementedUserServiceServer) Signup ¶
func (UnimplementedUserServiceServer) Signup(context.Context, *SignupReq) (*wrapperspb.StringValue, error)
type UnsafeUserServiceServer ¶
type UnsafeUserServiceServer interface {
// contains filtered or unexported methods
}
UnsafeUserServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to UserServiceServer will result in compilation errors.
type User ¶
type User struct { Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" gorm:"primaryKey;"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" gorm:"size:10;not null" annotation:"昵称"` Password string `protobuf:"bytes,5,opt,name=password,proto3" json:"-" gorm:"size:32;not null" validate:"gte=8,lte=15" annotation:"密码"` Mail string `protobuf:"bytes,6,opt,name=mail,proto3" json:"mail,omitempty" gorm:"size:32;default:''" validate:"email" annotation:"邮箱"` Phone string `` /* 129-byte string literal not displayed */ // 性别,0未填写,1男,2女 Gender Gender `protobuf:"varint,8,opt,name=gender,proto3,enum=user.Gender" json:"gender,omitempty" gorm:"type:int2;default:0"` Role Role `protobuf:"varint,24,opt,name=role,proto3,enum=user.Role" json:"role,omitempty" gorm:"type:int2;default:0"` Status UserStatus `protobuf:"varint,28,opt,name=status,proto3,enum=user.UserStatus" json:"status,omitempty" gorm:"type:int2;default:0"` CreatedAt string `protobuf:"bytes,25,opt,name=createdAt,proto3" json:"createdAt,omitempty" gorm:"type:timestamptz(6);default:now();index"` ActivatedAt string `protobuf:"bytes,3,opt,name=activatedAt,proto3" json:"activatedAt,omitempty" gorm:"<-:false;type:timestamptz(6);index"` DeletedAt string `protobuf:"bytes,27,opt,name=deletedAt,proto3" json:"deletedAt,omitempty" gorm:"<-:false;type:timestamptz(6);index"` // uint32 isDeleted = 29 [(go.field) = {tags:'gorm:"default:0"'}]; // contains filtered or unexported fields }
func (*User) Descriptor
deprecated
func (*User) GetActivatedAt ¶
func (*User) GetCreatedAt ¶
func (*User) GetDeletedAt ¶
func (*User) GetPassword ¶
func (*User) GetStatus ¶
func (x *User) GetStatus() UserStatus
func (*User) ProtoMessage ¶
func (*User) ProtoMessage()
func (*User) ProtoReflect ¶
func (x *User) ProtoReflect() protoreflect.Message
type UserServiceClient ¶
type UserServiceClient interface { // 注册 Signup(ctx context.Context, in *SignupReq, opts ...grpc.CallOption) (*wrapperspb.StringValue, error) }
UserServiceClient is the client API for UserService 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 NewUserServiceClient ¶
func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient
type UserServiceResolvers ¶
type UserServiceResolvers struct{ Service UserServiceServer }
func (*UserServiceResolvers) UserServiceSignup ¶
func (s *UserServiceResolvers) UserServiceSignup(ctx context.Context, in *SignupReq) (*wrapperspb.StringValue, error)
type UserServiceServer ¶
type UserServiceServer interface { // 注册 Signup(context.Context, *SignupReq) (*wrapperspb.StringValue, error) // contains filtered or unexported methods }
UserServiceServer is the server API for UserService service. All implementations must embed UnimplementedUserServiceServer for forward compatibility
type UserStatus ¶
type UserStatus int32
用户角色
const ( UserStatusPlaceholder UserStatus = 0 UserStatusInActive UserStatus = 1 UserStatusActivated UserStatus = 2 UserStatusFrozen UserStatus = 3 UserStatusDeleted UserStatus = 4 )
func UnmarshalUserStatus ¶
func UnmarshalUserStatus(v interface{}) (UserStatus, error)
func (UserStatus) Descriptor ¶
func (UserStatus) Descriptor() protoreflect.EnumDescriptor
func (UserStatus) Enum ¶
func (x UserStatus) Enum() *UserStatus
func (UserStatus) EnumDescriptor
deprecated
func (UserStatus) EnumDescriptor() ([]byte, []int)
Deprecated: Use UserStatus.Descriptor instead.
func (UserStatus) MarshalGQL ¶
func (x UserStatus) MarshalGQL(w io.Writer)
func (UserStatus) Number ¶
func (x UserStatus) Number() protoreflect.EnumNumber
func (UserStatus) OrigString ¶
func (x UserStatus) OrigString() string
func (UserStatus) String ¶
func (x UserStatus) String() string
func (UserStatus) Type ¶
func (UserStatus) Type() protoreflect.EnumType
func (*UserStatus) UnmarshalGQL ¶
func (x *UserStatus) UnmarshalGQL(v interface{}) error