user

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package user is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	UserService_Signup_FullMethodName = "/user.UserService/Signup"
)

Variables

View Source
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.

View Source
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.

View Source
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.

View Source
var (
	UserErr_name = map[int32]string{
		0:    "UserErrPlaceholder",
		1000: "UserErrLogin",
		1001: "UserErrNoActive",
		1002: "UserErrNoAuthority",
		1003: "UserErrLoginTimeout",
		1004: "UserErrInvalidToken",
		1005: "UserErrNoLogin",
	}
	UserErr_value = map[string]int32{
		"UserErrPlaceholder":  0,
		"UserErrLogin":        1000,
		"UserErrNoActive":     1001,
		"UserErrNoAuthority":  1002,
		"UserErrLoginTimeout": 1003,
		"UserErrInvalidToken": 1004,
		"UserErrNoLogin":      1005,
	}
)

Enum value maps for UserErr.

View Source
var File_user_user_proto protoreflect.FileDescriptor
View Source
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 RegisterUserServiceHandler

func RegisterUserServiceHandler(ctx context.Context, mux *gin.Engine, conn *grpc.ClientConn) error

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

用户性别

const (
	GenderPlaceholder Gender = 0
	GenderUnfilled    Gender = 1
	GenderMale        Gender = 2
	GenderFemale      Gender = 3
)

func (Gender) Descriptor

func (Gender) Descriptor() protoreflect.EnumDescriptor

func (Gender) Enum

func (x Gender) Enum() *Gender

func (Gender) EnumDescriptor deprecated

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

Deprecated: Use Gender.Descriptor instead.

func (Gender) MarshalGQL

func (x Gender) MarshalGQL(w io.Writer)

func (Gender) MarshalJSON added in v1.2.1

func (x Gender) MarshalJSON() ([]byte, error)

func (Gender) Number

func (x Gender) Number() protoreflect.EnumNumber

func (Gender) OrigString

func (x Gender) OrigString() string

func (Gender) String

func (x Gender) String() string

func (Gender) Type

func (Gender) Type() protoreflect.EnumType

func (*Gender) UnmarshalGQL

func (x *Gender) UnmarshalGQL(v interface{}) error

func (*Gender) UnmarshalJSON added in v1.2.1

func (x *Gender) UnmarshalJSON(data []byte) error

type Role

type Role int32

用户角色

const (
	PlaceholderRole Role = 0
	RoleNormal      Role = 1
	RoleAdmin       Role = 2
	RoleSuperAdmin  Role = 3
)

func (Role) Descriptor

func (Role) Descriptor() protoreflect.EnumDescriptor

func (Role) Enum

func (x Role) Enum() *Role

func (Role) EnumDescriptor deprecated

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

Deprecated: Use Role.Descriptor instead.

func (Role) MarshalGQL

func (x Role) MarshalGQL(w io.Writer)

func (Role) MarshalJSON added in v1.2.1

func (x Role) MarshalJSON() ([]byte, error)

func (Role) Number

func (x Role) Number() protoreflect.EnumNumber

func (Role) OrigString

func (x Role) OrigString() string

func (Role) String

func (x Role) String() string

func (Role) Type

func (Role) Type() protoreflect.EnumType

func (*Role) UnmarshalGQL

func (x *Role) UnmarshalGQL(v interface{}) error

func (*Role) UnmarshalJSON added in v1.2.1

func (x *Role) UnmarshalJSON(data []byte) error

type SignupReq

type SignupReq struct {

	// 密码
	Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty" validate:"required,gte=6,lte=15" comment:"密码"`
	Name     string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty" validate:"required,gte=3,lte=10" comment:"昵称"`
	Gender   Gender `protobuf:"varint,3,opt,name=gender,proto3,enum=user.Gender" json:"gender,omitempty" validate:"required" comment:"性别"`
	// 邮箱
	Mail string `protobuf:"bytes,6,opt,name=mail,proto3" json:"mail,omitempty" validate:"omitempty,email" comment:"邮箱"`
	// 手机号
	Phone string `protobuf:"bytes,7,opt,name=phone,proto3" json:"phone,omitempty" validate:"omitempty,phone" comment:"手机号"`
	// 验证码
	VCode string `protobuf:"bytes,8,opt,name=vCode,proto3" json:"vCode,omitempty" validate:"required" comment:"验证码"`
	// contains filtered or unexported fields
}

func (*SignupReq) Descriptor deprecated

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

Deprecated: Use SignupReq.ProtoReflect.Descriptor instead.

func (*SignupReq) GetGender

func (x *SignupReq) GetGender() Gender

func (*SignupReq) GetMail

func (x *SignupReq) GetMail() string

func (*SignupReq) GetName

func (x *SignupReq) GetName() string

func (*SignupReq) GetPassword

func (x *SignupReq) GetPassword() string

func (*SignupReq) GetPhone

func (x *SignupReq) GetPhone() string

func (*SignupReq) GetVCode

func (x *SignupReq) GetVCode() string

func (*SignupReq) ProtoMessage

func (*SignupReq) ProtoMessage()

func (*SignupReq) ProtoReflect

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

func (*SignupReq) Reset

func (x *SignupReq) Reset()

func (*SignupReq) String

func (x *SignupReq) String() string

func (*SignupReq) Validate

func (x *SignupReq) Validate() error

type SignupReqInput

type SignupReqInput = SignupReq

type UnimplementedUserServiceServer

type UnimplementedUserServiceServer struct {
}

UnimplementedUserServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedUserServiceServer) Signup

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" comment:"昵称"`
	Password string `protobuf:"bytes,5,opt,name=password,proto3" json:"-" gorm:"size:32;not null" validate:"gte=8,lte=15" comment:"密码"`
	Mail     string `protobuf:"bytes,6,opt,name=mail,proto3" json:"mail,omitempty" gorm:"size:32;default:''" validate:"email" comment:"邮箱"`
	Phone    string `` /* 126-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) Descriptor() ([]byte, []int)

Deprecated: Use User.ProtoReflect.Descriptor instead.

func (*User) GetActivatedAt

func (x *User) GetActivatedAt() string

func (*User) GetCreatedAt

func (x *User) GetCreatedAt() string

func (*User) GetDeletedAt

func (x *User) GetDeletedAt() string

func (*User) GetGender

func (x *User) GetGender() Gender

func (*User) GetId

func (x *User) GetId() uint64

func (*User) GetMail

func (x *User) GetMail() string

func (*User) GetName

func (x *User) GetName() string

func (*User) GetPassword

func (x *User) GetPassword() string

func (*User) GetPhone

func (x *User) GetPhone() string

func (*User) GetRole

func (x *User) GetRole() Role

func (*User) GetStatus

func (x *User) GetStatus() UserStatus

func (*User) ProtoMessage

func (*User) ProtoMessage()

func (*User) ProtoReflect

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

func (*User) Reset

func (x *User) Reset()

func (*User) String

func (x *User) String() string

func (*User) Validate

func (x *User) Validate() error

type UserErr added in v1.2.12

type UserErr int32
const (
	UserErrPlaceholder  UserErr = 0
	UserErrLogin        UserErr = 1000
	UserErrNoActive     UserErr = 1001
	UserErrNoAuthority  UserErr = 1002
	UserErrLoginTimeout UserErr = 1003
	UserErrInvalidToken UserErr = 1004
	UserErrNoLogin      UserErr = 1005
)

func (UserErr) Descriptor added in v1.2.12

func (UserErr) Descriptor() protoreflect.EnumDescriptor

func (UserErr) Enum added in v1.2.12

func (x UserErr) Enum() *UserErr

func (UserErr) EnumDescriptor deprecated added in v1.2.12

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

Deprecated: Use UserErr.Descriptor instead.

func (UserErr) ErrRep added in v1.2.12

func (x UserErr) ErrRep() *errorcode.ErrRep

func (UserErr) Error added in v1.2.12

func (x UserErr) Error() string

func (UserErr) ErrorLog added in v1.2.12

func (x UserErr) ErrorLog(err error) error

func (UserErr) GrpcStatus added in v1.2.12

func (x UserErr) GrpcStatus() *status.Status

func (UserErr) MarshalGQL added in v1.2.12

func (x UserErr) MarshalGQL(w io.Writer)

func (UserErr) MarshalJSON added in v1.2.12

func (x UserErr) MarshalJSON() ([]byte, error)

func (UserErr) Message added in v1.2.12

func (x UserErr) Message(msg string) error

func (UserErr) Number added in v1.2.12

func (x UserErr) Number() protoreflect.EnumNumber

func (UserErr) OrigString added in v1.2.12

func (x UserErr) OrigString() string

func (UserErr) String added in v1.2.12

func (x UserErr) String() string

func (UserErr) Type added in v1.2.12

func (UserErr) Type() protoreflect.EnumType

func (*UserErr) UnmarshalGQL added in v1.2.12

func (x *UserErr) UnmarshalGQL(v interface{}) error

func (*UserErr) UnmarshalJSON added in v1.2.12

func (x *UserErr) UnmarshalJSON(data []byte) error

type UserInput

type UserInput = User

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.

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 (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) MarshalJSON added in v1.2.1

func (x UserStatus) MarshalJSON() ([]byte, error)

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) UnmarshalGQL

func (x *UserStatus) UnmarshalGQL(v interface{}) error

func (*UserStatus) UnmarshalJSON added in v1.2.1

func (x *UserStatus) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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