mirror of https://github.com/rocboss/paopao-ce
parent
da633590a1
commit
f287c825a6
@ -0,0 +1,371 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc (unknown)
|
||||
// source: v1/auth.proto
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type User struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
PhoneNum string `protobuf:"bytes,1,opt,name=phoneNum,proto3" json:"phoneNum,omitempty"`
|
||||
}
|
||||
|
||||
func (x *User) Reset() {
|
||||
*x = User{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_v1_auth_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *User) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*User) ProtoMessage() {}
|
||||
|
||||
func (x *User) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_v1_auth_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use User.ProtoReflect.Descriptor instead.
|
||||
func (*User) Descriptor() ([]byte, []int) {
|
||||
return file_v1_auth_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *User) GetPhoneNum() string {
|
||||
if x != nil {
|
||||
return x.PhoneNum
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type UserVerify struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
PhoneNum string `protobuf:"bytes,1,opt,name=phoneNum,proto3" json:"phoneNum,omitempty"`
|
||||
VerificationCode string `protobuf:"bytes,2,opt,name=VerificationCode,proto3" json:"VerificationCode,omitempty"`
|
||||
}
|
||||
|
||||
func (x *UserVerify) Reset() {
|
||||
*x = UserVerify{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_v1_auth_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *UserVerify) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UserVerify) ProtoMessage() {}
|
||||
|
||||
func (x *UserVerify) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_v1_auth_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UserVerify.ProtoReflect.Descriptor instead.
|
||||
func (*UserVerify) Descriptor() ([]byte, []int) {
|
||||
return file_v1_auth_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *UserVerify) GetPhoneNum() string {
|
||||
if x != nil {
|
||||
return x.PhoneNum
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UserVerify) GetVerificationCode() string {
|
||||
if x != nil {
|
||||
return x.VerificationCode
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type LoginReply struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
StatuCode int32 `protobuf:"varint,1,opt,name=statuCode,proto3" json:"statuCode,omitempty"`
|
||||
Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"`
|
||||
}
|
||||
|
||||
func (x *LoginReply) Reset() {
|
||||
*x = LoginReply{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_v1_auth_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *LoginReply) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*LoginReply) ProtoMessage() {}
|
||||
|
||||
func (x *LoginReply) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_v1_auth_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use LoginReply.ProtoReflect.Descriptor instead.
|
||||
func (*LoginReply) Descriptor() ([]byte, []int) {
|
||||
return file_v1_auth_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *LoginReply) GetStatuCode() int32 {
|
||||
if x != nil {
|
||||
return x.StatuCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *LoginReply) GetToken() string {
|
||||
if x != nil {
|
||||
return x.Token
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type ActionReply struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
StatusCode int32 `protobuf:"varint,1,opt,name=statusCode,proto3" json:"statusCode,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ActionReply) Reset() {
|
||||
*x = ActionReply{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_v1_auth_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ActionReply) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ActionReply) ProtoMessage() {}
|
||||
|
||||
func (x *ActionReply) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_v1_auth_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ActionReply.ProtoReflect.Descriptor instead.
|
||||
func (*ActionReply) Descriptor() ([]byte, []int) {
|
||||
return file_v1_auth_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *ActionReply) GetStatusCode() int32 {
|
||||
if x != nil {
|
||||
return x.StatusCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_v1_auth_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_v1_auth_proto_rawDesc = []byte{
|
||||
0x0a, 0x0d, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
|
||||
0x04, 0x61, 0x75, 0x74, 0x68, 0x22, 0x22, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1a, 0x0a,
|
||||
0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x22, 0x54, 0x0a, 0x0a, 0x55, 0x73, 0x65,
|
||||
0x72, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65,
|
||||
0x4e, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65,
|
||||
0x4e, 0x75, 0x6d, 0x12, 0x2a, 0x0a, 0x10, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x56,
|
||||
0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x22,
|
||||
0x40, 0x0a, 0x0a, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1c, 0x0a,
|
||||
0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
|
||||
0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74,
|
||||
0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65,
|
||||
0x6e, 0x22, 0x2d, 0x0a, 0x0b, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79,
|
||||
0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65,
|
||||
0x32, 0x89, 0x01, 0x0a, 0x0c, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74,
|
||||
0x65, 0x12, 0x29, 0x0a, 0x08, 0x70, 0x72, 0x65, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x0a, 0x2e,
|
||||
0x61, 0x75, 0x74, 0x68, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x1a, 0x11, 0x2e, 0x61, 0x75, 0x74, 0x68,
|
||||
0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x25, 0x0a, 0x05,
|
||||
0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x0a, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x55, 0x73, 0x65,
|
||||
0x72, 0x1a, 0x10, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65,
|
||||
0x70, 0x6c, 0x79, 0x12, 0x27, 0x0a, 0x06, 0x6c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x12, 0x0a, 0x2e,
|
||||
0x61, 0x75, 0x74, 0x68, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x1a, 0x11, 0x2e, 0x61, 0x75, 0x74, 0x68,
|
||||
0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x6f, 0x0a, 0x08,
|
||||
0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x42, 0x09, 0x41, 0x75, 0x74, 0x68, 0x50, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
|
||||
0x6d, 0x2f, 0x72, 0x6f, 0x63, 0x62, 0x6f, 0x73, 0x73, 0x2f, 0x70, 0x61, 0x6f, 0x70, 0x61, 0x6f,
|
||||
0x2d, 0x63, 0x65, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, 0xa2,
|
||||
0x02, 0x03, 0x41, 0x58, 0x58, 0xaa, 0x02, 0x04, 0x41, 0x75, 0x74, 0x68, 0xca, 0x02, 0x04, 0x41,
|
||||
0x75, 0x74, 0x68, 0xe2, 0x02, 0x10, 0x41, 0x75, 0x74, 0x68, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65,
|
||||
0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x04, 0x41, 0x75, 0x74, 0x68, 0x62, 0x06, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_v1_auth_proto_rawDescOnce sync.Once
|
||||
file_v1_auth_proto_rawDescData = file_v1_auth_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_v1_auth_proto_rawDescGZIP() []byte {
|
||||
file_v1_auth_proto_rawDescOnce.Do(func() {
|
||||
file_v1_auth_proto_rawDescData = protoimpl.X.CompressGZIP(file_v1_auth_proto_rawDescData)
|
||||
})
|
||||
return file_v1_auth_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_v1_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_v1_auth_proto_goTypes = []interface{}{
|
||||
(*User)(nil), // 0: auth.User
|
||||
(*UserVerify)(nil), // 1: auth.UserVerify
|
||||
(*LoginReply)(nil), // 2: auth.LoginReply
|
||||
(*ActionReply)(nil), // 3: auth.ActionReply
|
||||
}
|
||||
var file_v1_auth_proto_depIdxs = []int32{
|
||||
0, // 0: auth.Authenticate.preLogin:input_type -> auth.User
|
||||
0, // 1: auth.Authenticate.login:input_type -> auth.User
|
||||
0, // 2: auth.Authenticate.logout:input_type -> auth.User
|
||||
3, // 3: auth.Authenticate.preLogin:output_type -> auth.ActionReply
|
||||
2, // 4: auth.Authenticate.login:output_type -> auth.LoginReply
|
||||
3, // 5: auth.Authenticate.logout:output_type -> auth.ActionReply
|
||||
3, // [3:6] is the sub-list for method output_type
|
||||
0, // [0:3] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_v1_auth_proto_init() }
|
||||
func file_v1_auth_proto_init() {
|
||||
if File_v1_auth_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_v1_auth_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*User); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_v1_auth_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*UserVerify); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_v1_auth_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*LoginReply); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_v1_auth_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ActionReply); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_v1_auth_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 4,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_v1_auth_proto_goTypes,
|
||||
DependencyIndexes: file_v1_auth_proto_depIdxs,
|
||||
MessageInfos: file_v1_auth_proto_msgTypes,
|
||||
}.Build()
|
||||
File_v1_auth_proto = out.File
|
||||
file_v1_auth_proto_rawDesc = nil
|
||||
file_v1_auth_proto_goTypes = nil
|
||||
file_v1_auth_proto_depIdxs = nil
|
||||
}
|
@ -0,0 +1,177 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc (unknown)
|
||||
// source: v1/auth.proto
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// AuthenticateClient is the client API for Authenticate 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 AuthenticateClient interface {
|
||||
PreLogin(ctx context.Context, in *User, opts ...grpc.CallOption) (*ActionReply, error)
|
||||
Login(ctx context.Context, in *User, opts ...grpc.CallOption) (*LoginReply, error)
|
||||
Logout(ctx context.Context, in *User, opts ...grpc.CallOption) (*ActionReply, error)
|
||||
}
|
||||
|
||||
type authenticateClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewAuthenticateClient(cc grpc.ClientConnInterface) AuthenticateClient {
|
||||
return &authenticateClient{cc}
|
||||
}
|
||||
|
||||
func (c *authenticateClient) PreLogin(ctx context.Context, in *User, opts ...grpc.CallOption) (*ActionReply, error) {
|
||||
out := new(ActionReply)
|
||||
err := c.cc.Invoke(ctx, "/auth.Authenticate/preLogin", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *authenticateClient) Login(ctx context.Context, in *User, opts ...grpc.CallOption) (*LoginReply, error) {
|
||||
out := new(LoginReply)
|
||||
err := c.cc.Invoke(ctx, "/auth.Authenticate/login", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *authenticateClient) Logout(ctx context.Context, in *User, opts ...grpc.CallOption) (*ActionReply, error) {
|
||||
out := new(ActionReply)
|
||||
err := c.cc.Invoke(ctx, "/auth.Authenticate/logout", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// AuthenticateServer is the server API for Authenticate service.
|
||||
// All implementations must embed UnimplementedAuthenticateServer
|
||||
// for forward compatibility
|
||||
type AuthenticateServer interface {
|
||||
PreLogin(context.Context, *User) (*ActionReply, error)
|
||||
Login(context.Context, *User) (*LoginReply, error)
|
||||
Logout(context.Context, *User) (*ActionReply, error)
|
||||
mustEmbedUnimplementedAuthenticateServer()
|
||||
}
|
||||
|
||||
// UnimplementedAuthenticateServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedAuthenticateServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedAuthenticateServer) PreLogin(context.Context, *User) (*ActionReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method PreLogin not implemented")
|
||||
}
|
||||
func (UnimplementedAuthenticateServer) Login(context.Context, *User) (*LoginReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Login not implemented")
|
||||
}
|
||||
func (UnimplementedAuthenticateServer) Logout(context.Context, *User) (*ActionReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Logout not implemented")
|
||||
}
|
||||
func (UnimplementedAuthenticateServer) mustEmbedUnimplementedAuthenticateServer() {}
|
||||
|
||||
// UnsafeAuthenticateServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to AuthenticateServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeAuthenticateServer interface {
|
||||
mustEmbedUnimplementedAuthenticateServer()
|
||||
}
|
||||
|
||||
func RegisterAuthenticateServer(s grpc.ServiceRegistrar, srv AuthenticateServer) {
|
||||
s.RegisterService(&Authenticate_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Authenticate_PreLogin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(User)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AuthenticateServer).PreLogin(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/auth.Authenticate/preLogin",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthenticateServer).PreLogin(ctx, req.(*User))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Authenticate_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(User)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AuthenticateServer).Login(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/auth.Authenticate/login",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthenticateServer).Login(ctx, req.(*User))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Authenticate_Logout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(User)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AuthenticateServer).Logout(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/auth.Authenticate/logout",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthenticateServer).Logout(ctx, req.(*User))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Authenticate_ServiceDesc is the grpc.ServiceDesc for Authenticate service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Authenticate_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "auth.Authenticate",
|
||||
HandlerType: (*AuthenticateServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "preLogin",
|
||||
Handler: _Authenticate_PreLogin_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "login",
|
||||
Handler: _Authenticate_Login_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "logout",
|
||||
Handler: _Authenticate_Logout_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "v1/auth.proto",
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
version: v1
|
||||
managed:
|
||||
enabled: true
|
||||
go_package_prefix:
|
||||
default: github.com/rocboss/paopao-ce/auto/rpc
|
||||
except:
|
||||
- buf.build/googleapis/googleapis
|
||||
plugins:
|
||||
- plugin: go
|
||||
out: auto/rpc
|
||||
opt: paths=source_relative
|
||||
- plugin: go-grpc
|
||||
out: auto/rpc
|
||||
opt:
|
||||
- paths=source_relative
|
||||
- require_unimplemented_servers=true
|
@ -0,0 +1,3 @@
|
||||
version: v1
|
||||
directories:
|
||||
- proto
|
@ -0,0 +1,2 @@
|
||||
### OBS(Object Blob Storage System)
|
||||
简单对象存储模块,目前还没实现,先占个位置~
|
@ -0,0 +1,5 @@
|
||||
// Copyright 2022 ROC. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package obs
|
@ -1,10 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package paopao;
|
||||
|
||||
option go_package = "proto";
|
||||
|
||||
message Tag {
|
||||
string name = 1;
|
||||
int32 type = 2;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package mobile
|
||||
|
||||
import (
|
||||
api "github.com/rocboss/paopao-ce/auto/rpc/v1"
|
||||
)
|
||||
|
||||
var (
|
||||
_ api.AuthenticateServer = (*authenticateServant)(nil)
|
||||
)
|
||||
|
||||
type authenticateServant struct {
|
||||
api.UnimplementedAuthenticateServer
|
||||
}
|
||||
|
||||
func newAuthenticateServer() *authenticateServant {
|
||||
return &authenticateServant{}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package mobile
|
||||
|
||||
import (
|
||||
api "github.com/rocboss/paopao-ce/auto/rpc/v1"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
func RegisterServants(s *grpc.Server) {
|
||||
api.RegisterAuthenticateServer(s, newAuthenticateServer())
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
// Copyright 2022 ROC. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package service
|
||||
|
||||
import (
|
||||
"net"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// grpcServer wraper for grpc.Server
|
||||
type grpcServer struct {
|
||||
sync.RWMutex
|
||||
|
||||
listener net.Listener
|
||||
server *grpc.Server
|
||||
serverStatus uint8
|
||||
}
|
||||
|
||||
func (s *grpcServer) status() uint8 {
|
||||
s.RLock()
|
||||
defer s.RUnlock()
|
||||
|
||||
return s.serverStatus
|
||||
}
|
||||
|
||||
func (s *grpcServer) start() error {
|
||||
s.Lock()
|
||||
if s.serverStatus == _statusServerStarted || s.serverStatus == _statusServerStoped {
|
||||
return nil
|
||||
}
|
||||
oldStatus := s.serverStatus
|
||||
s.serverStatus = _statusServerStarted
|
||||
s.Unlock()
|
||||
|
||||
if err := s.server.Serve(s.listener); err != nil {
|
||||
s.Lock()
|
||||
s.serverStatus = oldStatus
|
||||
s.Unlock()
|
||||
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *grpcServer) stop() error {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
|
||||
if s.serverStatus == _statusServerStoped || s.serverStatus == _statusServerInitilized {
|
||||
return nil
|
||||
}
|
||||
s.server.Stop()
|
||||
s.serverStatus = _statusServerStoped
|
||||
return nil
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
// Copyright 2022 ROC. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package service
|
||||
|
||||
import (
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type baseGRPCService struct {
|
||||
baseService
|
||||
|
||||
server *grpcServer
|
||||
}
|
||||
|
||||
func (s *baseGRPCService) registerServer(h func(s *grpc.Server)) {
|
||||
if s.server.status() != _statusServerStarted {
|
||||
h(s.server.server)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *baseGRPCService) OnStart() error {
|
||||
if err := s.server.start(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *baseGRPCService) OnStop() error {
|
||||
return s.server.stop()
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
// Copyright 2022 ROC. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
|
||||
"github.com/Masterminds/semver/v3"
|
||||
"github.com/fatih/color"
|
||||
"github.com/rocboss/paopao-ce/internal/conf"
|
||||
"github.com/rocboss/paopao-ce/internal/servants"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
var (
|
||||
_ Service = (*mobileService)(nil)
|
||||
)
|
||||
|
||||
type mobileService struct {
|
||||
*baseGRPCService
|
||||
}
|
||||
|
||||
func (s *mobileService) Name() string {
|
||||
return "MobileService"
|
||||
}
|
||||
|
||||
func (s *mobileService) Version() *semver.Version {
|
||||
return semver.MustParse("v0.1.0")
|
||||
}
|
||||
|
||||
func (s *mobileService) OnInit() error {
|
||||
s.registerServer(servants.RegisterMobileServants)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *mobileService) String() string {
|
||||
return fmt.Sprintf("listen on %s\n", color.GreenString("http://%s:%s", conf.MobileServerSetting.Host, conf.MobileServerSetting.Port))
|
||||
}
|
||||
|
||||
func newMobileService() Service {
|
||||
addr := conf.MobileServerSetting.Host + ":" + conf.MobileServerSetting.Port
|
||||
server := grpcServerFrom(addr, func() *grpcServer {
|
||||
l, err := net.Listen("tcp", addr)
|
||||
if err != nil {
|
||||
// TODO: optimize error process
|
||||
log.Fatal(fmt.Errorf("failed to listen: %w", err))
|
||||
}
|
||||
|
||||
// TODO: init grpc.Server
|
||||
s := grpc.NewServer()
|
||||
|
||||
return &grpcServer{
|
||||
listener: l,
|
||||
server: s,
|
||||
}
|
||||
})
|
||||
return &mobileService{
|
||||
baseGRPCService: &baseGRPCService{
|
||||
server: server,
|
||||
},
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
// Copyright 2022 ROC. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package service
|
||||
|
||||
var (
|
||||
httpServers = make(map[string]*httpServer)
|
||||
grpcServers = make(map[string]*grpcServer)
|
||||
)
|
||||
|
||||
const (
|
||||
_statusServerInitilized uint8 = iota + 1
|
||||
_statusServerStarted
|
||||
_statusServerStoped
|
||||
)
|
||||
|
||||
func httpServerFrom(addr string, newServer func() *httpServer) *httpServer {
|
||||
s, exist := httpServers[addr]
|
||||
if exist {
|
||||
return s
|
||||
}
|
||||
s = newServer()
|
||||
s.serverStatus = _statusServerInitilized
|
||||
httpServers[addr] = s
|
||||
return s
|
||||
}
|
||||
|
||||
func grpcServerFrom(addr string, newServer func() *grpcServer) *grpcServer {
|
||||
s, exist := grpcServers[addr]
|
||||
if exist {
|
||||
return s
|
||||
}
|
||||
s = newServer()
|
||||
s.serverStatus = _statusServerInitilized
|
||||
grpcServers[addr] = s
|
||||
return s
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
# Generated by buf. DO NOT EDIT.
|
||||
version: v1
|
||||
deps:
|
||||
- remote: buf.build
|
||||
owner: googleapis
|
||||
repository: googleapis
|
||||
commit: 75b4300737fb4efca0831636be94e517
|
@ -0,0 +1,10 @@
|
||||
version: v1
|
||||
lint:
|
||||
use:
|
||||
- DEFAULT
|
||||
breaking:
|
||||
use:
|
||||
- FILE
|
||||
|
||||
deps:
|
||||
- buf.build/googleapis/googleapis
|
@ -0,0 +1,29 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package auth;
|
||||
|
||||
option go_package = "github.com/rocboss/paopao-ce/auto/rpc";
|
||||
|
||||
message User {
|
||||
string phoneNum = 1;
|
||||
}
|
||||
|
||||
message UserVerify {
|
||||
string phoneNum = 1;
|
||||
string VerificationCode = 2;
|
||||
}
|
||||
|
||||
message LoginReply {
|
||||
int32 statuCode = 1;
|
||||
string token = 2;
|
||||
}
|
||||
|
||||
message ActionReply {
|
||||
int32 statusCode = 1;
|
||||
}
|
||||
|
||||
service Authenticate {
|
||||
rpc preLogin(User) returns (ActionReply);
|
||||
rpc login(User) returns (LoginReply);
|
||||
rpc logout(User) returns (ActionReply);
|
||||
}
|
Loading…
Reference in new issue