Merge branch 'dev' into x/gorm

pull/351/head
Michael Li 1 year ago
commit ade5e5c229
No known key found for this signature in database

@ -78,19 +78,10 @@ gen-mir:
@go fmt ./auto/api/... @go fmt ./auto/api/...
.PHONY: gen-rpc .PHONY: gen-rpc
gen-rpc: gen-grpc gen-connect gen-rpc:
@rm -rf auto/rpc auto/connect
.PHONY: gen-grpc @buf generate proto
gen-grpc: @go fmt ./auto/rpc/... ./auto/connect/...
@rm -rf auto/rpc
@buf generate --template buf.grpc.gen.yaml proto/grpc
@go fmt ./auto/rpc/...
.PHONY: gen-connect
gen-connect:
@rm -rf auto/connect
@buf generate --template buf.connect.gen.yaml proto/connect
@go fmt ./auto/connect/...
.PHONY: proto-mod .PHONY: proto-mod
proto-mod: proto-mod:

@ -8,7 +8,7 @@ import (
context "context" context "context"
errors "errors" errors "errors"
connect_go "github.com/bufbuild/connect-go" connect_go "github.com/bufbuild/connect-go"
v1 "github.com/rocboss/paopao-ce/auto/connect/core/v1" v1 "github.com/rocboss/paopao-ce/auto/rpc/core/v1"
http "net/http" http "net/http"
strings "strings" strings "strings"
) )
@ -21,8 +21,8 @@ import (
const _ = connect_go.IsAtLeastVersion0_1_0 const _ = connect_go.IsAtLeastVersion0_1_0
const ( const (
// AuthenticateName is the fully-qualified name of the Authenticate service. // AuthenticateServiceName is the fully-qualified name of the AuthenticateService service.
AuthenticateName = "core.v1.Authenticate" AuthenticateServiceName = "core.v1.AuthenticateService"
) )
// These constants are the fully-qualified names of the RPCs defined in this package. They're // These constants are the fully-qualified names of the RPCs defined in this package. They're
@ -33,124 +33,127 @@ const (
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a // reflection-formatted method names, remove the leading slash and convert the remaining slash to a
// period. // period.
const ( const (
// AuthenticatePreLoginProcedure is the fully-qualified name of the Authenticate's preLogin RPC. // AuthenticateServicePreLoginProcedure is the fully-qualified name of the AuthenticateService's
AuthenticatePreLoginProcedure = "/core.v1.Authenticate/preLogin" // preLogin RPC.
// AuthenticateLoginProcedure is the fully-qualified name of the Authenticate's login RPC. AuthenticateServicePreLoginProcedure = "/core.v1.AuthenticateService/preLogin"
AuthenticateLoginProcedure = "/core.v1.Authenticate/login" // AuthenticateServiceLoginProcedure is the fully-qualified name of the AuthenticateService's login
// AuthenticateLogoutProcedure is the fully-qualified name of the Authenticate's logout RPC. // RPC.
AuthenticateLogoutProcedure = "/core.v1.Authenticate/logout" AuthenticateServiceLoginProcedure = "/core.v1.AuthenticateService/login"
// AuthenticateServiceLogoutProcedure is the fully-qualified name of the AuthenticateService's
// logout RPC.
AuthenticateServiceLogoutProcedure = "/core.v1.AuthenticateService/logout"
) )
// AuthenticateClient is a client for the core.v1.Authenticate service. // AuthenticateServiceClient is a client for the core.v1.AuthenticateService service.
type AuthenticateClient interface { type AuthenticateServiceClient interface {
PreLogin(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) PreLogin(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error)
Login(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.LoginReply], error) Login(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.LoginReply], error)
Logout(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) Logout(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error)
} }
// NewAuthenticateClient constructs a client for the core.v1.Authenticate service. By default, it // NewAuthenticateServiceClient constructs a client for the core.v1.AuthenticateService service. By
// uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends // default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses,
// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or // and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the
// connect.WithGRPCWeb() options. // connect.WithGRPC() or connect.WithGRPCWeb() options.
// //
// The URL supplied here should be the base URL for the Connect or gRPC server (for example, // The URL supplied here should be the base URL for the Connect or gRPC server (for example,
// http://api.acme.com or https://acme.com/grpc). // http://api.acme.com or https://acme.com/grpc).
func NewAuthenticateClient(httpClient connect_go.HTTPClient, baseURL string, opts ...connect_go.ClientOption) AuthenticateClient { func NewAuthenticateServiceClient(httpClient connect_go.HTTPClient, baseURL string, opts ...connect_go.ClientOption) AuthenticateServiceClient {
baseURL = strings.TrimRight(baseURL, "/") baseURL = strings.TrimRight(baseURL, "/")
return &authenticateClient{ return &authenticateServiceClient{
preLogin: connect_go.NewClient[v1.User, v1.ActionReply]( preLogin: connect_go.NewClient[v1.User, v1.ActionReply](
httpClient, httpClient,
baseURL+AuthenticatePreLoginProcedure, baseURL+AuthenticateServicePreLoginProcedure,
opts..., opts...,
), ),
login: connect_go.NewClient[v1.User, v1.LoginReply]( login: connect_go.NewClient[v1.User, v1.LoginReply](
httpClient, httpClient,
baseURL+AuthenticateLoginProcedure, baseURL+AuthenticateServiceLoginProcedure,
opts..., opts...,
), ),
logout: connect_go.NewClient[v1.User, v1.ActionReply]( logout: connect_go.NewClient[v1.User, v1.ActionReply](
httpClient, httpClient,
baseURL+AuthenticateLogoutProcedure, baseURL+AuthenticateServiceLogoutProcedure,
opts..., opts...,
), ),
} }
} }
// authenticateClient implements AuthenticateClient. // authenticateServiceClient implements AuthenticateServiceClient.
type authenticateClient struct { type authenticateServiceClient struct {
preLogin *connect_go.Client[v1.User, v1.ActionReply] preLogin *connect_go.Client[v1.User, v1.ActionReply]
login *connect_go.Client[v1.User, v1.LoginReply] login *connect_go.Client[v1.User, v1.LoginReply]
logout *connect_go.Client[v1.User, v1.ActionReply] logout *connect_go.Client[v1.User, v1.ActionReply]
} }
// PreLogin calls core.v1.Authenticate.preLogin. // PreLogin calls core.v1.AuthenticateService.preLogin.
func (c *authenticateClient) PreLogin(ctx context.Context, req *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) { func (c *authenticateServiceClient) PreLogin(ctx context.Context, req *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) {
return c.preLogin.CallUnary(ctx, req) return c.preLogin.CallUnary(ctx, req)
} }
// Login calls core.v1.Authenticate.login. // Login calls core.v1.AuthenticateService.login.
func (c *authenticateClient) Login(ctx context.Context, req *connect_go.Request[v1.User]) (*connect_go.Response[v1.LoginReply], error) { func (c *authenticateServiceClient) Login(ctx context.Context, req *connect_go.Request[v1.User]) (*connect_go.Response[v1.LoginReply], error) {
return c.login.CallUnary(ctx, req) return c.login.CallUnary(ctx, req)
} }
// Logout calls core.v1.Authenticate.logout. // Logout calls core.v1.AuthenticateService.logout.
func (c *authenticateClient) Logout(ctx context.Context, req *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) { func (c *authenticateServiceClient) Logout(ctx context.Context, req *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) {
return c.logout.CallUnary(ctx, req) return c.logout.CallUnary(ctx, req)
} }
// AuthenticateHandler is an implementation of the core.v1.Authenticate service. // AuthenticateServiceHandler is an implementation of the core.v1.AuthenticateService service.
type AuthenticateHandler interface { type AuthenticateServiceHandler interface {
PreLogin(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) PreLogin(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error)
Login(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.LoginReply], error) Login(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.LoginReply], error)
Logout(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) Logout(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error)
} }
// NewAuthenticateHandler builds an HTTP handler from the service implementation. It returns the // NewAuthenticateServiceHandler builds an HTTP handler from the service implementation. It returns
// path on which to mount the handler and the handler itself. // the path on which to mount the handler and the handler itself.
// //
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
// and JSON codecs. They also support gzip compression. // and JSON codecs. They also support gzip compression.
func NewAuthenticateHandler(svc AuthenticateHandler, opts ...connect_go.HandlerOption) (string, http.Handler) { func NewAuthenticateServiceHandler(svc AuthenticateServiceHandler, opts ...connect_go.HandlerOption) (string, http.Handler) {
authenticatePreLoginHandler := connect_go.NewUnaryHandler( authenticateServicePreLoginHandler := connect_go.NewUnaryHandler(
AuthenticatePreLoginProcedure, AuthenticateServicePreLoginProcedure,
svc.PreLogin, svc.PreLogin,
opts..., opts...,
) )
authenticateLoginHandler := connect_go.NewUnaryHandler( authenticateServiceLoginHandler := connect_go.NewUnaryHandler(
AuthenticateLoginProcedure, AuthenticateServiceLoginProcedure,
svc.Login, svc.Login,
opts..., opts...,
) )
authenticateLogoutHandler := connect_go.NewUnaryHandler( authenticateServiceLogoutHandler := connect_go.NewUnaryHandler(
AuthenticateLogoutProcedure, AuthenticateServiceLogoutProcedure,
svc.Logout, svc.Logout,
opts..., opts...,
) )
return "/core.v1.Authenticate/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { return "/core.v1.AuthenticateService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path { switch r.URL.Path {
case AuthenticatePreLoginProcedure: case AuthenticateServicePreLoginProcedure:
authenticatePreLoginHandler.ServeHTTP(w, r) authenticateServicePreLoginHandler.ServeHTTP(w, r)
case AuthenticateLoginProcedure: case AuthenticateServiceLoginProcedure:
authenticateLoginHandler.ServeHTTP(w, r) authenticateServiceLoginHandler.ServeHTTP(w, r)
case AuthenticateLogoutProcedure: case AuthenticateServiceLogoutProcedure:
authenticateLogoutHandler.ServeHTTP(w, r) authenticateServiceLogoutHandler.ServeHTTP(w, r)
default: default:
http.NotFound(w, r) http.NotFound(w, r)
} }
}) })
} }
// UnimplementedAuthenticateHandler returns CodeUnimplemented from all methods. // UnimplementedAuthenticateServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedAuthenticateHandler struct{} type UnimplementedAuthenticateServiceHandler struct{}
func (UnimplementedAuthenticateHandler) PreLogin(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) { func (UnimplementedAuthenticateServiceHandler) PreLogin(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) {
return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("core.v1.Authenticate.preLogin is not implemented")) return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("core.v1.AuthenticateService.preLogin is not implemented"))
} }
func (UnimplementedAuthenticateHandler) Login(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.LoginReply], error) { func (UnimplementedAuthenticateServiceHandler) Login(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.LoginReply], error) {
return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("core.v1.Authenticate.login is not implemented")) return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("core.v1.AuthenticateService.login is not implemented"))
} }
func (UnimplementedAuthenticateHandler) Logout(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) { func (UnimplementedAuthenticateServiceHandler) Logout(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) {
return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("core.v1.Authenticate.logout is not implemented")) return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("core.v1.AuthenticateService.logout is not implemented"))
} }

@ -0,0 +1,104 @@
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: greet/v1/greet.proto
package greetv1connect
import (
context "context"
errors "errors"
connect_go "github.com/bufbuild/connect-go"
v1 "github.com/rocboss/paopao-ce/auto/rpc/greet/v1"
http "net/http"
strings "strings"
)
// This is a compile-time assertion to ensure that this generated file and the connect package are
// compatible. If you get a compiler error that this constant is not defined, this code was
// generated with a version of connect newer than the one compiled into your binary. You can fix the
// problem by either regenerating this code with an older version of connect or updating the connect
// version compiled into your binary.
const _ = connect_go.IsAtLeastVersion0_1_0
const (
// GreetServiceName is the fully-qualified name of the GreetService service.
GreetServiceName = "greet.v1.GreetService"
)
// These constants are the fully-qualified names of the RPCs defined in this package. They're
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
//
// Note that these are different from the fully-qualified method names used by
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
// period.
const (
// GreetServiceGreetProcedure is the fully-qualified name of the GreetService's Greet RPC.
GreetServiceGreetProcedure = "/greet.v1.GreetService/Greet"
)
// GreetServiceClient is a client for the greet.v1.GreetService service.
type GreetServiceClient interface {
Greet(context.Context, *connect_go.Request[v1.GreetRequest]) (*connect_go.Response[v1.GreetResponse], error)
}
// NewGreetServiceClient constructs a client for the greet.v1.GreetService service. By default, it
// uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
// connect.WithGRPCWeb() options.
//
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
// http://api.acme.com or https://acme.com/grpc).
func NewGreetServiceClient(httpClient connect_go.HTTPClient, baseURL string, opts ...connect_go.ClientOption) GreetServiceClient {
baseURL = strings.TrimRight(baseURL, "/")
return &greetServiceClient{
greet: connect_go.NewClient[v1.GreetRequest, v1.GreetResponse](
httpClient,
baseURL+GreetServiceGreetProcedure,
opts...,
),
}
}
// greetServiceClient implements GreetServiceClient.
type greetServiceClient struct {
greet *connect_go.Client[v1.GreetRequest, v1.GreetResponse]
}
// Greet calls greet.v1.GreetService.Greet.
func (c *greetServiceClient) Greet(ctx context.Context, req *connect_go.Request[v1.GreetRequest]) (*connect_go.Response[v1.GreetResponse], error) {
return c.greet.CallUnary(ctx, req)
}
// GreetServiceHandler is an implementation of the greet.v1.GreetService service.
type GreetServiceHandler interface {
Greet(context.Context, *connect_go.Request[v1.GreetRequest]) (*connect_go.Response[v1.GreetResponse], error)
}
// NewGreetServiceHandler builds an HTTP handler from the service implementation. It returns the
// path on which to mount the handler and the handler itself.
//
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
// and JSON codecs. They also support gzip compression.
func NewGreetServiceHandler(svc GreetServiceHandler, opts ...connect_go.HandlerOption) (string, http.Handler) {
greetServiceGreetHandler := connect_go.NewUnaryHandler(
GreetServiceGreetProcedure,
svc.Greet,
opts...,
)
return "/greet.v1.GreetService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case GreetServiceGreetProcedure:
greetServiceGreetHandler.ServeHTTP(w, r)
default:
http.NotFound(w, r)
}
})
}
// UnimplementedGreetServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedGreetServiceHandler struct{}
func (UnimplementedGreetServiceHandler) Greet(context.Context, *connect_go.Request[v1.GreetRequest]) (*connect_go.Response[v1.GreetResponse], error) {
return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("greet.v1.GreetService.Greet is not implemented"))
}

@ -25,7 +25,7 @@ type User struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
PhoneNum string `protobuf:"bytes,1,opt,name=phoneNum,proto3" json:"phoneNum,omitempty"` PhoneNum string `protobuf:"bytes,1,opt,name=phone_num,json=phoneNum,proto3" json:"phone_num,omitempty"`
} }
func (x *User) Reset() { func (x *User) Reset() {
@ -72,8 +72,8 @@ type UserVerify struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
PhoneNum string `protobuf:"bytes,1,opt,name=phoneNum,proto3" json:"phoneNum,omitempty"` PhoneNum string `protobuf:"bytes,1,opt,name=phone_num,json=phoneNum,proto3" json:"phone_num,omitempty"`
VerificationCode string `protobuf:"bytes,2,opt,name=VerificationCode,proto3" json:"VerificationCode,omitempty"` VerificationCode string `protobuf:"bytes,2,opt,name=verification_code,json=verificationCode,proto3" json:"verification_code,omitempty"`
} }
func (x *UserVerify) Reset() { func (x *UserVerify) Reset() {
@ -127,8 +127,8 @@ type LoginReply struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
StatuCode int32 `protobuf:"varint,1,opt,name=statuCode,proto3" json:"statuCode,omitempty"` StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"`
Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"` Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"`
} }
func (x *LoginReply) Reset() { func (x *LoginReply) Reset() {
@ -163,9 +163,9 @@ func (*LoginReply) Descriptor() ([]byte, []int) {
return file_core_v1_auth_proto_rawDescGZIP(), []int{2} return file_core_v1_auth_proto_rawDescGZIP(), []int{2}
} }
func (x *LoginReply) GetStatuCode() int32 { func (x *LoginReply) GetStatusCode() int32 {
if x != nil { if x != nil {
return x.StatuCode return x.StatusCode
} }
return 0 return 0
} }
@ -182,7 +182,7 @@ type ActionReply struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
StatusCode int32 `protobuf:"varint,1,opt,name=statusCode,proto3" json:"statusCode,omitempty"` StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"`
} }
func (x *ActionReply) Reset() { func (x *ActionReply) Reset() {
@ -228,41 +228,42 @@ var File_core_v1_auth_proto protoreflect.FileDescriptor
var file_core_v1_auth_proto_rawDesc = []byte{ var file_core_v1_auth_proto_rawDesc = []byte{
0x0a, 0x12, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x70, 0x0a, 0x12, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x22, 0x22, 0x0a, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x22, 0x23, 0x0a,
0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x5f, 0x6e,
0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e,
0x6d, 0x22, 0x54, 0x0a, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x12, 0x75, 0x6d, 0x22, 0x56, 0x0a, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79,
0x1a, 0x0a, 0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x18, 0x01, 0x20,
0x09, 0x52, 0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x2a, 0x0a, 0x10, 0x56, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x2b, 0x0a,
0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x11, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x6f,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69,
0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x40, 0x0a, 0x0a, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x43, 0x0a, 0x0a, 0x4c, 0x6f,
0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x43, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74,
0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x43, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73,
0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b,
0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x2d, 0x0a, 0x0b, 0x41, 0x63, 0x74, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22,
0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x2e, 0x0a, 0x0b, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1f,
0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20,
0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x32, 0x9b, 0x01, 0x0a, 0x0c, 0x41, 0x75, 0x74, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x32,
0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x2f, 0x0a, 0x08, 0x70, 0x72, 0x65, 0xa2, 0x01, 0x0a, 0x13, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65,
0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x0d, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x2f, 0x0a, 0x08, 0x70, 0x72, 0x65, 0x4c, 0x6f,
0x55, 0x73, 0x65, 0x72, 0x1a, 0x14, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x2b, 0x0a, 0x05, 0x6c, 0x6f,
0x67, 0x69, 0x6e, 0x12, 0x0d, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x67, 0x69, 0x6e, 0x12, 0x0d, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73,
0x65, 0x72, 0x1a, 0x13, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x67, 0x65, 0x72, 0x1a, 0x14, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x74,
0x69, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x2d, 0x0a, 0x06, 0x6c, 0x6f, 0x67, 0x6f, 0x75, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x2b, 0x0a, 0x05, 0x6c, 0x6f, 0x67, 0x69,
0x74, 0x12, 0x0d, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x6e, 0x12, 0x0d, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72,
0x1a, 0x14, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x1a, 0x13, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e,
0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x8f, 0x01, 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x2d, 0x0a, 0x06, 0x6c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x12,
0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x09, 0x41, 0x75, 0x74, 0x68, 0x50, 0x72, 0x6f, 0x74, 0x0d, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x1a, 0x14,
0x6f, 0x50, 0x01, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52,
0x72, 0x6f, 0x63, 0x62, 0x6f, 0x73, 0x73, 0x2f, 0x70, 0x61, 0x6f, 0x70, 0x61, 0x6f, 0x2d, 0x63, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x8b, 0x01, 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x72,
0x65, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x2f, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x09, 0x41, 0x75, 0x74, 0x68, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50,
0x6f, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x72, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x6f,
0x43, 0x58, 0x58, 0xaa, 0x02, 0x07, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x07, 0x63, 0x62, 0x6f, 0x73, 0x73, 0x2f, 0x70, 0x61, 0x6f, 0x70, 0x61, 0x6f, 0x2d, 0x63, 0x65, 0x2f,
0x43, 0x6f, 0x72, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x13, 0x43, 0x6f, 0x72, 0x65, 0x5c, 0x56, 0x61, 0x75, 0x74, 0x6f, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x31,
0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x08, 0x3b, 0x63, 0x6f, 0x72, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x58, 0x58, 0xaa, 0x02, 0x07,
0x43, 0x6f, 0x72, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x07, 0x43, 0x6f, 0x72, 0x65, 0x5c, 0x56,
0x31, 0xe2, 0x02, 0x13, 0x43, 0x6f, 0x72, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d,
0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x08, 0x43, 0x6f, 0x72, 0x65, 0x3a, 0x3a,
0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -285,12 +286,12 @@ var file_core_v1_auth_proto_goTypes = []interface{}{
(*ActionReply)(nil), // 3: core.v1.ActionReply (*ActionReply)(nil), // 3: core.v1.ActionReply
} }
var file_core_v1_auth_proto_depIdxs = []int32{ var file_core_v1_auth_proto_depIdxs = []int32{
0, // 0: core.v1.Authenticate.preLogin:input_type -> core.v1.User 0, // 0: core.v1.AuthenticateService.preLogin:input_type -> core.v1.User
0, // 1: core.v1.Authenticate.login:input_type -> core.v1.User 0, // 1: core.v1.AuthenticateService.login:input_type -> core.v1.User
0, // 2: core.v1.Authenticate.logout:input_type -> core.v1.User 0, // 2: core.v1.AuthenticateService.logout:input_type -> core.v1.User
3, // 3: core.v1.Authenticate.preLogin:output_type -> core.v1.ActionReply 3, // 3: core.v1.AuthenticateService.preLogin:output_type -> core.v1.ActionReply
2, // 4: core.v1.Authenticate.login:output_type -> core.v1.LoginReply 2, // 4: core.v1.AuthenticateService.login:output_type -> core.v1.LoginReply
3, // 5: core.v1.Authenticate.logout:output_type -> core.v1.ActionReply 3, // 5: core.v1.AuthenticateService.logout:output_type -> core.v1.ActionReply
3, // [3:6] is the sub-list for method output_type 3, // [3:6] is the sub-list for method output_type
0, // [0:3] is the sub-list for method input_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 type_name

@ -0,0 +1,183 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc (unknown)
// source: core/v1/auth.proto
package corev1
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
const (
AuthenticateService_PreLogin_FullMethodName = "/core.v1.AuthenticateService/preLogin"
AuthenticateService_Login_FullMethodName = "/core.v1.AuthenticateService/login"
AuthenticateService_Logout_FullMethodName = "/core.v1.AuthenticateService/logout"
)
// AuthenticateServiceClient is the client API for AuthenticateService 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 AuthenticateServiceClient 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 authenticateServiceClient struct {
cc grpc.ClientConnInterface
}
func NewAuthenticateServiceClient(cc grpc.ClientConnInterface) AuthenticateServiceClient {
return &authenticateServiceClient{cc}
}
func (c *authenticateServiceClient) PreLogin(ctx context.Context, in *User, opts ...grpc.CallOption) (*ActionReply, error) {
out := new(ActionReply)
err := c.cc.Invoke(ctx, AuthenticateService_PreLogin_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *authenticateServiceClient) Login(ctx context.Context, in *User, opts ...grpc.CallOption) (*LoginReply, error) {
out := new(LoginReply)
err := c.cc.Invoke(ctx, AuthenticateService_Login_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *authenticateServiceClient) Logout(ctx context.Context, in *User, opts ...grpc.CallOption) (*ActionReply, error) {
out := new(ActionReply)
err := c.cc.Invoke(ctx, AuthenticateService_Logout_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// AuthenticateServiceServer is the server API for AuthenticateService service.
// All implementations must embed UnimplementedAuthenticateServiceServer
// for forward compatibility
type AuthenticateServiceServer interface {
PreLogin(context.Context, *User) (*ActionReply, error)
Login(context.Context, *User) (*LoginReply, error)
Logout(context.Context, *User) (*ActionReply, error)
mustEmbedUnimplementedAuthenticateServiceServer()
}
// UnimplementedAuthenticateServiceServer must be embedded to have forward compatible implementations.
type UnimplementedAuthenticateServiceServer struct {
}
func (UnimplementedAuthenticateServiceServer) PreLogin(context.Context, *User) (*ActionReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method PreLogin not implemented")
}
func (UnimplementedAuthenticateServiceServer) Login(context.Context, *User) (*LoginReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Login not implemented")
}
func (UnimplementedAuthenticateServiceServer) Logout(context.Context, *User) (*ActionReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Logout not implemented")
}
func (UnimplementedAuthenticateServiceServer) mustEmbedUnimplementedAuthenticateServiceServer() {}
// UnsafeAuthenticateServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to AuthenticateServiceServer will
// result in compilation errors.
type UnsafeAuthenticateServiceServer interface {
mustEmbedUnimplementedAuthenticateServiceServer()
}
func RegisterAuthenticateServiceServer(s grpc.ServiceRegistrar, srv AuthenticateServiceServer) {
s.RegisterService(&AuthenticateService_ServiceDesc, srv)
}
func _AuthenticateService_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.(AuthenticateServiceServer).PreLogin(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AuthenticateService_PreLogin_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthenticateServiceServer).PreLogin(ctx, req.(*User))
}
return interceptor(ctx, in, info, handler)
}
func _AuthenticateService_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.(AuthenticateServiceServer).Login(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AuthenticateService_Login_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthenticateServiceServer).Login(ctx, req.(*User))
}
return interceptor(ctx, in, info, handler)
}
func _AuthenticateService_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.(AuthenticateServiceServer).Logout(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AuthenticateService_Logout_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthenticateServiceServer).Logout(ctx, req.(*User))
}
return interceptor(ctx, in, info, handler)
}
// AuthenticateService_ServiceDesc is the grpc.ServiceDesc for AuthenticateService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var AuthenticateService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "core.v1.AuthenticateService",
HandlerType: (*AuthenticateServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "preLogin",
Handler: _AuthenticateService_PreLogin_Handler,
},
{
MethodName: "login",
Handler: _AuthenticateService_Login_Handler,
},
{
MethodName: "logout",
Handler: _AuthenticateService_Logout_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "core/v1/auth.proto",
}

@ -1,15 +0,0 @@
version: v1
managed:
enabled: true
go_package_prefix:
default: github.com/rocboss/paopao-ce/auto/connect
except:
- buf.build/googleapis/googleapis
plugins:
- plugin: go
out: auto/connect
opt: paths=source_relative
- plugin: connect-go
out: auto/connect
opt:
- paths=source_relative

@ -14,3 +14,6 @@ plugins:
opt: opt:
- paths=source_relative - paths=source_relative
- require_unimplemented_servers=true - require_unimplemented_servers=true
- plugin: connect-go
out: auto/connect
opt: paths=source_relative

@ -1,4 +1,3 @@
version: v1 version: v1
directories: directories:
- proto/connect - proto
- proto/grpc

@ -9,9 +9,9 @@ import (
) )
var ( var (
_ api.AuthenticateHandler = (*authenticateHandler)(nil) _ api.AuthenticateServiceHandler = (*authenticateSrv)(nil)
) )
type authenticateHandler struct { type authenticateSrv struct {
api.UnimplementedAuthenticateHandler api.UnimplementedAuthenticateServiceHandler
} }

@ -12,5 +12,5 @@ import (
) )
func RegisterAuthenticateHandler(h func(string, http.Handler), opts ...connect.HandlerOption) { func RegisterAuthenticateHandler(h func(string, http.Handler), opts ...connect.HandlerOption) {
h(api.NewAuthenticateHandler(&authenticateHandler{}, opts...)) h(api.NewAuthenticateServiceHandler(&authenticateSrv{}, opts...))
} }

@ -16,8 +16,8 @@ type baseConnectService struct {
server *connectServer server *connectServer
} }
func (s *baseConnectService) registerServer(srv Service, h func(func(string, http.Handler), ...connect.HandlerOption)) { func (s *baseConnectService) registerServer(srv Service, h func(func(string, http.Handler), ...connect.HandlerOption), opts ...connect.HandlerOption) {
h(s.server.register, s.server.handlerOpts...) h(s.server.register, append(opts, s.server.handlerOpts...)...)
s.server.addService(srv) s.server.addService(srv)
} }

@ -5,24 +5,24 @@ package core.v1;
option go_package = "github.com/rocboss/paopao-ce/auto/connect/core/v1;corev1"; option go_package = "github.com/rocboss/paopao-ce/auto/connect/core/v1;corev1";
message User { message User {
string phoneNum = 1; string phone_num = 1;
} }
message UserVerify { message UserVerify {
string phoneNum = 1; string phone_num = 1;
string VerificationCode = 2; string verification_code = 2;
} }
message LoginReply { message LoginReply {
int32 statuCode = 1; int32 status_code = 1;
string token = 2; string token = 2;
} }
message ActionReply { message ActionReply {
int32 statusCode = 1; int32 status_code = 1;
} }
service Authenticate { service AuthenticateService {
rpc preLogin(User) returns (ActionReply); rpc preLogin(User) returns (ActionReply);
rpc login(User) returns (LoginReply); rpc login(User) returns (LoginReply);
rpc logout(User) returns (ActionReply); rpc logout(User) returns (ActionReply);

@ -1,7 +0,0 @@
version: v1
breaking:
use:
- FILE
lint:
use:
- DEFAULT
Loading…
Cancel
Save