user

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2019 License: MIT Imports: 14 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 UserSex_name = map[int32]string{
	0: "DEFAULT",
	1: "MEN",
	2: "WOMEN",
}
View Source
var UserSex_value = map[string]int32{
	"DEFAULT": 0,
	"MEN":     1,
	"WOMEN":   2,
}

Functions

func RegisterUserServiceHandler

func RegisterUserServiceHandler(ctx context.Context, mux *runtime.ServeMux, 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 *runtime.ServeMux, 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 *runtime.ServeMux, 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(ctx context.Context, mux *runtime.ServeMux, 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.

func RegisterUserServiceServer

func RegisterUserServiceServer(s *grpc.Server, srv UserServiceServer)

Types

type Null

type Null struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

空消息

func (*Null) Descriptor

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

func (*Null) ProtoMessage

func (*Null) ProtoMessage()

func (*Null) Reset

func (m *Null) Reset()

func (*Null) String

func (m *Null) String() string

func (*Null) XXX_DiscardUnknown

func (m *Null) XXX_DiscardUnknown()

func (*Null) XXX_Marshal

func (m *Null) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Null) XXX_Merge

func (m *Null) XXX_Merge(src proto.Message)

func (*Null) XXX_Size

func (m *Null) XXX_Size() int

func (*Null) XXX_Unmarshal

func (m *Null) XXX_Unmarshal(b []byte) error

type Page

type Page struct {
	//  页
	PageIndex int64 `protobuf:"varint,1,opt,name=page_index,json=pageIndex,proto3" json:"page_index,omitempty"`
	//  每页大小
	PageSize int64 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"`
	//  总页数
	PageTotal int64 `protobuf:"varint,3,opt,name=page_total,json=pageTotal,proto3" json:"page_total,omitempty"`
	//  条数
	Count int64 `protobuf:"varint,4,opt,name=count,proto3" json:"count,omitempty"`
	//  总条数
	Total                int64    `protobuf:"varint,5,opt,name=total,proto3" json:"total,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

分页

func (*Page) Descriptor

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

func (*Page) GetCount

func (m *Page) GetCount() int64

func (*Page) GetPageIndex

func (m *Page) GetPageIndex() int64

func (*Page) GetPageSize

func (m *Page) GetPageSize() int64

func (*Page) GetPageTotal

func (m *Page) GetPageTotal() int64

func (*Page) GetTotal

func (m *Page) GetTotal() int64

func (*Page) ProtoMessage

func (*Page) ProtoMessage()

func (*Page) Reset

func (m *Page) Reset()

func (*Page) String

func (m *Page) String() string

func (*Page) XXX_DiscardUnknown

func (m *Page) XXX_DiscardUnknown()

func (*Page) XXX_Marshal

func (m *Page) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Page) XXX_Merge

func (m *Page) XXX_Merge(src proto.Message)

func (*Page) XXX_Size

func (m *Page) XXX_Size() int

func (*Page) XXX_Unmarshal

func (m *Page) XXX_Unmarshal(b []byte) error

type UnimplementedUserServiceServer

type UnimplementedUserServiceServer struct {
}

UnimplementedUserServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedUserServiceServer) UserAdd

func (*UnimplementedUserServiceServer) UserDelete

func (*UnimplementedUserServiceServer) UserDelete(ctx context.Context, req *UserID) (*UserID, error)

func (*UnimplementedUserServiceServer) UserQueryAll

func (*UnimplementedUserServiceServer) UserQueryOne

func (*UnimplementedUserServiceServer) UserQueryOne(ctx context.Context, req *UserID) (*UserBase, error)

func (*UnimplementedUserServiceServer) UserUpdate

type UserAll

type UserAll struct {
	//  用户信息
	All []*UserBase `protobuf:"bytes,1,rep,name=all,proto3" json:"all,omitempty"`
	//  页数
	Page                 *Page    `protobuf:"bytes,2,opt,name=page,proto3" json:"page,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

用户全部

func (*UserAll) Descriptor

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

func (*UserAll) GetAll

func (m *UserAll) GetAll() []*UserBase

func (*UserAll) GetPage

func (m *UserAll) GetPage() *Page

func (*UserAll) ProtoMessage

func (*UserAll) ProtoMessage()

func (*UserAll) Reset

func (m *UserAll) Reset()

func (*UserAll) String

func (m *UserAll) String() string

func (*UserAll) XXX_DiscardUnknown

func (m *UserAll) XXX_DiscardUnknown()

func (*UserAll) XXX_Marshal

func (m *UserAll) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UserAll) XXX_Merge

func (m *UserAll) XXX_Merge(src proto.Message)

func (*UserAll) XXX_Size

func (m *UserAll) XXX_Size() int

func (*UserAll) XXX_Unmarshal

func (m *UserAll) XXX_Unmarshal(b []byte) error

type UserAllOption

type UserAllOption struct {
	//  用户性别
	Sex UserSex `protobuf:"varint,1,opt,name=sex,proto3,enum=user.UserSex" json:"sex,omitempty"`
	//  页数
	Page *Page `protobuf:"bytes,2,opt,name=page,proto3" json:"page,omitempty"`
	//  用户名称
	UserName             string   `protobuf:"bytes,3,opt,name=user_name,json=userName,proto3" json:"user_name,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

用户全部选项

func (*UserAllOption) Descriptor

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

func (*UserAllOption) GetPage

func (m *UserAllOption) GetPage() *Page

func (*UserAllOption) GetSex

func (m *UserAllOption) GetSex() UserSex

func (*UserAllOption) GetUserName

func (m *UserAllOption) GetUserName() string

func (*UserAllOption) ProtoMessage

func (*UserAllOption) ProtoMessage()

func (*UserAllOption) Reset

func (m *UserAllOption) Reset()

func (*UserAllOption) String

func (m *UserAllOption) String() string

func (*UserAllOption) XXX_DiscardUnknown

func (m *UserAllOption) XXX_DiscardUnknown()

func (*UserAllOption) XXX_Marshal

func (m *UserAllOption) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UserAllOption) XXX_Merge

func (m *UserAllOption) XXX_Merge(src proto.Message)

func (*UserAllOption) XXX_Size

func (m *UserAllOption) XXX_Size() int

func (*UserAllOption) XXX_Unmarshal

func (m *UserAllOption) XXX_Unmarshal(b []byte) error

type UserBase

type UserBase struct {
	//  @inject_tag: db:"id"
	Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" db:"id"`
	//  @inject_tag: db:"user_name" valid:"required~用户名称必须存在"
	UserName string `` /* 142-byte string literal not displayed */
	//  @inject_tag: db:"iphone" valid:"required~手机号必须存在"
	Iphone string `protobuf:"bytes,3,opt,name=iphone,proto3" json:"iphone,omitempty" db:"iphone" valid:"required~手机号必须存在"`
	//  @inject_tag: db:"password"
	Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty" db:"password"`
	//  @inject_tag: db:"sex"
	Sex                  UserSex  `protobuf:"varint,5,opt,name=sex,proto3,enum=user.UserSex" json:"sex,omitempty" db:"sex"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

注入标签: https://github.com/favadi/protoc-go-inject-tag 用户基本信息

func (*UserBase) Descriptor

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

func (*UserBase) GetId

func (m *UserBase) GetId() int64

func (*UserBase) GetIphone

func (m *UserBase) GetIphone() string

func (*UserBase) GetPassword

func (m *UserBase) GetPassword() string

func (*UserBase) GetSex

func (m *UserBase) GetSex() UserSex

func (*UserBase) GetUserName

func (m *UserBase) GetUserName() string

func (*UserBase) ProtoMessage

func (*UserBase) ProtoMessage()

func (*UserBase) Reset

func (m *UserBase) Reset()

func (*UserBase) String

func (m *UserBase) String() string

func (*UserBase) XXX_DiscardUnknown

func (m *UserBase) XXX_DiscardUnknown()

func (*UserBase) XXX_Marshal

func (m *UserBase) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UserBase) XXX_Merge

func (m *UserBase) XXX_Merge(src proto.Message)

func (*UserBase) XXX_Size

func (m *UserBase) XXX_Size() int

func (*UserBase) XXX_Unmarshal

func (m *UserBase) XXX_Unmarshal(b []byte) error

type UserID

type UserID struct {
	//  用户id
	Id                   int64    `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*UserID) Descriptor

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

func (*UserID) GetId

func (m *UserID) GetId() int64

func (*UserID) ProtoMessage

func (*UserID) ProtoMessage()

func (*UserID) Reset

func (m *UserID) Reset()

func (*UserID) String

func (m *UserID) String() string

func (*UserID) XXX_DiscardUnknown

func (m *UserID) XXX_DiscardUnknown()

func (*UserID) XXX_Marshal

func (m *UserID) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UserID) XXX_Merge

func (m *UserID) XXX_Merge(src proto.Message)

func (*UserID) XXX_Size

func (m *UserID) XXX_Size() int

func (*UserID) XXX_Unmarshal

func (m *UserID) XXX_Unmarshal(b []byte) error

type UserServiceClient

type UserServiceClient interface {
	//  用户添加
	UserAdd(ctx context.Context, in *UserBase, opts ...grpc.CallOption) (*UserBase, error)
	//  用户更新
	UserUpdate(ctx context.Context, in *UserBase, opts ...grpc.CallOption) (*UserBase, error)
	//  用户删除
	UserDelete(ctx context.Context, in *UserID, opts ...grpc.CallOption) (*UserID, error)
	//  用户查询一个
	UserQueryOne(ctx context.Context, in *UserID, opts ...grpc.CallOption) (*UserBase, error)
	//  用户查询全部
	UserQueryAll(ctx context.Context, in *UserAllOption, opts ...grpc.CallOption) (*UserAll, error)
}

UserServiceClient is the client API for UserService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewUserServiceClient

func NewUserServiceClient(cc *grpc.ClientConn) UserServiceClient

type UserServiceServer

type UserServiceServer interface {
	//  用户添加
	UserAdd(context.Context, *UserBase) (*UserBase, error)
	//  用户更新
	UserUpdate(context.Context, *UserBase) (*UserBase, error)
	//  用户删除
	UserDelete(context.Context, *UserID) (*UserID, error)
	//  用户查询一个
	UserQueryOne(context.Context, *UserID) (*UserBase, error)
	//  用户查询全部
	UserQueryAll(context.Context, *UserAllOption) (*UserAll, error)
}

UserServiceServer is the server API for UserService service.

type UserSex

type UserSex int32

用户性别

const (
	UserSex_DEFAULT UserSex = 0
	UserSex_MEN     UserSex = 1
	UserSex_WOMEN   UserSex = 2
)

func (UserSex) EnumDescriptor

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

func (UserSex) String

func (x UserSex) String() string

Directories

Path Synopsis
protoc-gen-swagger

Jump to

Keyboard shortcuts

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