custom data

master
Han Joker 8 months ago
parent daaeb28463
commit f6b87c0f65

@ -0,0 +1,30 @@
package server
import (
"context"
"github.com/go-kratos/kratos/v2/middleware"
"github.com/go-kratos/kratos/v2/transport"
"github.com/go-kratos/kratos/v2/transport/http"
)
// 跨域资源共享的中间件
func MWCors() middleware.Middleware {
return func(handler middleware.Handler) middleware.Handler {
return func(ctx context.Context, req interface{}) (reply interface{}, err error) {
if tr, ok := transport.FromServerContext(ctx); ok {
// Do something on entering
// 在响应中增加特定的头信息
ht := tr.(http.Transporter)
ht.ReplyHeader().Set("Access-Control-Allow-Origin", "*")
ht.ReplyHeader().Set("Access-Control-Allow-Methods", "GET,POST,OPTIONS,PUT,PATCH,DELETE")
ht.ReplyHeader().Set("Access-Control-Allow-Credentials", "true")
ht.ReplyHeader().Set("Access-Control-Allow-Headers", "Content-Type,User-Agent,Content-Length,Authorization,Accept,Referer,Host")
defer func() {
// Do something on exiting
}()
}
return handler(ctx, req)
}
}
}

@ -3,6 +3,7 @@ package server
import (
"context"
"customer/internal/service"
"fmt"
"github.com/go-kratos/kratos/v2/errors"
"github.com/go-kratos/kratos/v2/middleware"
"github.com/go-kratos/kratos/v2/middleware/auth/jwt"
@ -17,6 +18,7 @@ func customerJWT(customerService *service.CustomerService) middleware.Middleware
return func(ctx context.Context, req interface{}) (interface{}, error) {
// 一获取存储在jwt中的用户顾客id
claims, ok := jwt.FromContext(ctx)
fmt.Println(claims, ok)
if !ok {
// 没有获取到 claims
return nil, errors.Unauthorized("UNAUTHORIZED", "claims not found")

@ -15,12 +15,17 @@ import (
jwtv4 "github.com/golang-jwt/jwt/v4"
)
// NewHTTPServer new a HTTP server.
// NewHTTPServer new an HTTP server.
func NewHTTPServer(c *conf.Server, customerService *service.CustomerService, greeter *service.GreeterService, logger log.Logger) *http.Server {
var opts = []http.ServerOption{
http.Middleware(
recovery.Recovery(),
// 自己设置的中间件
// CORS全部的请求响应都使用该中间件
selector.Server(MWCors()).Match(func(ctx context.Context, operation string) bool {
return true
}).Build(),
// JWT除了特定几个其他请求响应都是用该中间件
selector.Server(
jwt.Server(func(token *jwtv4.Token) (interface{}, error) {
return []byte(biz.CustomerSecret), nil

@ -21,6 +21,125 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// 校验身份证号码消息
type IDNoCheckReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Idno string `protobuf:"bytes,2,opt,name=idno,proto3" json:"idno,omitempty"`
}
func (x *IDNoCheckReq) Reset() {
*x = IDNoCheckReq{}
if protoimpl.UnsafeEnabled {
mi := &file_api_driver_driver_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *IDNoCheckReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*IDNoCheckReq) ProtoMessage() {}
func (x *IDNoCheckReq) ProtoReflect() protoreflect.Message {
mi := &file_api_driver_driver_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 IDNoCheckReq.ProtoReflect.Descriptor instead.
func (*IDNoCheckReq) Descriptor() ([]byte, []int) {
return file_api_driver_driver_proto_rawDescGZIP(), []int{0}
}
func (x *IDNoCheckReq) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *IDNoCheckReq) GetIdno() string {
if x != nil {
return x.Idno
}
return ""
}
type IDNoCheckResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
Status string `protobuf:"bytes,3,opt,name=status,proto3" json:"status,omitempty"`
}
func (x *IDNoCheckResp) Reset() {
*x = IDNoCheckResp{}
if protoimpl.UnsafeEnabled {
mi := &file_api_driver_driver_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *IDNoCheckResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*IDNoCheckResp) ProtoMessage() {}
func (x *IDNoCheckResp) ProtoReflect() protoreflect.Message {
mi := &file_api_driver_driver_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 IDNoCheckResp.ProtoReflect.Descriptor instead.
func (*IDNoCheckResp) Descriptor() ([]byte, []int) {
return file_api_driver_driver_proto_rawDescGZIP(), []int{1}
}
func (x *IDNoCheckResp) GetCode() int64 {
if x != nil {
return x.Code
}
return 0
}
func (x *IDNoCheckResp) GetMessage() string {
if x != nil {
return x.Message
}
return ""
}
func (x *IDNoCheckResp) GetStatus() string {
if x != nil {
return x.Status
}
return ""
}
// 获取验证码的消息
type GetVerifyCodeReq struct {
state protoimpl.MessageState
@ -33,7 +152,7 @@ type GetVerifyCodeReq struct {
func (x *GetVerifyCodeReq) Reset() {
*x = GetVerifyCodeReq{}
if protoimpl.UnsafeEnabled {
mi := &file_api_driver_driver_proto_msgTypes[0]
mi := &file_api_driver_driver_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -46,7 +165,7 @@ func (x *GetVerifyCodeReq) String() string {
func (*GetVerifyCodeReq) ProtoMessage() {}
func (x *GetVerifyCodeReq) ProtoReflect() protoreflect.Message {
mi := &file_api_driver_driver_proto_msgTypes[0]
mi := &file_api_driver_driver_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -59,7 +178,7 @@ func (x *GetVerifyCodeReq) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetVerifyCodeReq.ProtoReflect.Descriptor instead.
func (*GetVerifyCodeReq) Descriptor() ([]byte, []int) {
return file_api_driver_driver_proto_rawDescGZIP(), []int{0}
return file_api_driver_driver_proto_rawDescGZIP(), []int{2}
}
func (x *GetVerifyCodeReq) GetTelephone() string {
@ -87,7 +206,7 @@ type GetVerifyCodeResp struct {
func (x *GetVerifyCodeResp) Reset() {
*x = GetVerifyCodeResp{}
if protoimpl.UnsafeEnabled {
mi := &file_api_driver_driver_proto_msgTypes[1]
mi := &file_api_driver_driver_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -100,7 +219,7 @@ func (x *GetVerifyCodeResp) String() string {
func (*GetVerifyCodeResp) ProtoMessage() {}
func (x *GetVerifyCodeResp) ProtoReflect() protoreflect.Message {
mi := &file_api_driver_driver_proto_msgTypes[1]
mi := &file_api_driver_driver_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -113,7 +232,7 @@ func (x *GetVerifyCodeResp) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetVerifyCodeResp.ProtoReflect.Descriptor instead.
func (*GetVerifyCodeResp) Descriptor() ([]byte, []int) {
return file_api_driver_driver_proto_rawDescGZIP(), []int{1}
return file_api_driver_driver_proto_rawDescGZIP(), []int{3}
}
func (x *GetVerifyCodeResp) GetCode() int64 {
@ -157,14 +276,13 @@ type SubmitPhoneReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Telephone string `protobuf:"bytes,1,opt,name=telephone,proto3" json:"telephone,omitempty"`
VerifyCode string `protobuf:"bytes,2,opt,name=verify_code,json=verifyCode,proto3" json:"verify_code,omitempty"`
Telephone string `protobuf:"bytes,1,opt,name=telephone,proto3" json:"telephone,omitempty"`
}
func (x *SubmitPhoneReq) Reset() {
*x = SubmitPhoneReq{}
if protoimpl.UnsafeEnabled {
mi := &file_api_driver_driver_proto_msgTypes[2]
mi := &file_api_driver_driver_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -177,7 +295,7 @@ func (x *SubmitPhoneReq) String() string {
func (*SubmitPhoneReq) ProtoMessage() {}
func (x *SubmitPhoneReq) ProtoReflect() protoreflect.Message {
mi := &file_api_driver_driver_proto_msgTypes[2]
mi := &file_api_driver_driver_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -190,7 +308,7 @@ func (x *SubmitPhoneReq) ProtoReflect() protoreflect.Message {
// Deprecated: Use SubmitPhoneReq.ProtoReflect.Descriptor instead.
func (*SubmitPhoneReq) Descriptor() ([]byte, []int) {
return file_api_driver_driver_proto_rawDescGZIP(), []int{2}
return file_api_driver_driver_proto_rawDescGZIP(), []int{4}
}
func (x *SubmitPhoneReq) GetTelephone() string {
@ -200,13 +318,6 @@ func (x *SubmitPhoneReq) GetTelephone() string {
return ""
}
func (x *SubmitPhoneReq) GetVerifyCode() string {
if x != nil {
return x.VerifyCode
}
return ""
}
type SubmitPhoneResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -220,7 +331,7 @@ type SubmitPhoneResp struct {
func (x *SubmitPhoneResp) Reset() {
*x = SubmitPhoneResp{}
if protoimpl.UnsafeEnabled {
mi := &file_api_driver_driver_proto_msgTypes[3]
mi := &file_api_driver_driver_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -233,7 +344,7 @@ func (x *SubmitPhoneResp) String() string {
func (*SubmitPhoneResp) ProtoMessage() {}
func (x *SubmitPhoneResp) ProtoReflect() protoreflect.Message {
mi := &file_api_driver_driver_proto_msgTypes[3]
mi := &file_api_driver_driver_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -246,7 +357,7 @@ func (x *SubmitPhoneResp) ProtoReflect() protoreflect.Message {
// Deprecated: Use SubmitPhoneResp.ProtoReflect.Descriptor instead.
func (*SubmitPhoneResp) Descriptor() ([]byte, []int) {
return file_api_driver_driver_proto_rawDescGZIP(), []int{3}
return file_api_driver_driver_proto_rawDescGZIP(), []int{5}
}
func (x *SubmitPhoneResp) GetCode() int64 {
@ -283,7 +394,7 @@ type LoginReq struct {
func (x *LoginReq) Reset() {
*x = LoginReq{}
if protoimpl.UnsafeEnabled {
mi := &file_api_driver_driver_proto_msgTypes[4]
mi := &file_api_driver_driver_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -296,7 +407,7 @@ func (x *LoginReq) String() string {
func (*LoginReq) ProtoMessage() {}
func (x *LoginReq) ProtoReflect() protoreflect.Message {
mi := &file_api_driver_driver_proto_msgTypes[4]
mi := &file_api_driver_driver_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -309,7 +420,7 @@ func (x *LoginReq) ProtoReflect() protoreflect.Message {
// Deprecated: Use LoginReq.ProtoReflect.Descriptor instead.
func (*LoginReq) Descriptor() ([]byte, []int) {
return file_api_driver_driver_proto_rawDescGZIP(), []int{4}
return file_api_driver_driver_proto_rawDescGZIP(), []int{6}
}
func (x *LoginReq) GetTelephone() string {
@ -344,7 +455,7 @@ type LoginResp struct {
func (x *LoginResp) Reset() {
*x = LoginResp{}
if protoimpl.UnsafeEnabled {
mi := &file_api_driver_driver_proto_msgTypes[5]
mi := &file_api_driver_driver_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -357,7 +468,7 @@ func (x *LoginResp) String() string {
func (*LoginResp) ProtoMessage() {}
func (x *LoginResp) ProtoReflect() protoreflect.Message {
mi := &file_api_driver_driver_proto_msgTypes[5]
mi := &file_api_driver_driver_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -370,7 +481,7 @@ func (x *LoginResp) ProtoReflect() protoreflect.Message {
// Deprecated: Use LoginResp.ProtoReflect.Descriptor instead.
func (*LoginResp) Descriptor() ([]byte, []int) {
return file_api_driver_driver_proto_rawDescGZIP(), []int{5}
return file_api_driver_driver_proto_rawDescGZIP(), []int{7}
}
func (x *LoginResp) GetCode() int64 {
@ -417,7 +528,7 @@ type LogoutReq struct {
func (x *LogoutReq) Reset() {
*x = LogoutReq{}
if protoimpl.UnsafeEnabled {
mi := &file_api_driver_driver_proto_msgTypes[6]
mi := &file_api_driver_driver_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -430,7 +541,7 @@ func (x *LogoutReq) String() string {
func (*LogoutReq) ProtoMessage() {}
func (x *LogoutReq) ProtoReflect() protoreflect.Message {
mi := &file_api_driver_driver_proto_msgTypes[6]
mi := &file_api_driver_driver_proto_msgTypes[8]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -443,7 +554,7 @@ func (x *LogoutReq) ProtoReflect() protoreflect.Message {
// Deprecated: Use LogoutReq.ProtoReflect.Descriptor instead.
func (*LogoutReq) Descriptor() ([]byte, []int) {
return file_api_driver_driver_proto_rawDescGZIP(), []int{6}
return file_api_driver_driver_proto_rawDescGZIP(), []int{8}
}
type LogoutResp struct {
@ -458,7 +569,7 @@ type LogoutResp struct {
func (x *LogoutResp) Reset() {
*x = LogoutResp{}
if protoimpl.UnsafeEnabled {
mi := &file_api_driver_driver_proto_msgTypes[7]
mi := &file_api_driver_driver_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -471,7 +582,7 @@ func (x *LogoutResp) String() string {
func (*LogoutResp) ProtoMessage() {}
func (x *LogoutResp) ProtoReflect() protoreflect.Message {
mi := &file_api_driver_driver_proto_msgTypes[7]
mi := &file_api_driver_driver_proto_msgTypes[9]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -484,7 +595,7 @@ func (x *LogoutResp) ProtoReflect() protoreflect.Message {
// Deprecated: Use LogoutResp.ProtoReflect.Descriptor instead.
func (*LogoutResp) Descriptor() ([]byte, []int) {
return file_api_driver_driver_proto_rawDescGZIP(), []int{7}
return file_api_driver_driver_proto_rawDescGZIP(), []int{9}
}
func (x *LogoutResp) GetCode() int64 {
@ -508,78 +619,91 @@ var file_api_driver_driver_proto_rawDesc = []byte{
0x76, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x61, 0x70, 0x69, 0x2e, 0x64,
0x72, 0x69, 0x76, 0x65, 0x72, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70,
0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x22, 0x30, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79,
0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x65, 0x6c, 0x65, 0x70,
0x68, 0x6f, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x65, 0x6c, 0x65,
0x70, 0x68, 0x6f, 0x6e, 0x65, 0x22, 0xb6, 0x01, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x56, 0x65, 0x72,
0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x63,
0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12,
0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x76, 0x65, 0x72,
0x69, 0x66, 0x79, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a,
0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x28, 0x0a, 0x10, 0x76, 0x65,
0x72, 0x69, 0x66, 0x79, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04,
0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65,
0x54, 0x69, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x10, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x5f, 0x63,
0x6f, 0x64, 0x65, 0x5f, 0x6c, 0x69, 0x66, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e,
0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x4c, 0x69, 0x66, 0x65, 0x22, 0x4f,
0x0a, 0x0e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x52, 0x65, 0x71,
0x12, 0x1c, 0x0a, 0x09, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x1f,
0x0a, 0x0b, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x0a, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x22,
0x57, 0x0a, 0x0f, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x52, 0x65,
0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09,
0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x49, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69,
0x6e, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x68, 0x6f, 0x6e,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x68, 0x6f,
0x6e, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x5f, 0x63, 0x6f, 0x64,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43,
0x6f, 0x64, 0x65, 0x22, 0x96, 0x01, 0x0a, 0x09, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73,
0x70, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12,
0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05,
0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x26, 0x0a, 0x0f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x63,
0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d,
0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x74, 0x12, 0x1d, 0x0a,
0x0a, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x6c, 0x69, 0x66, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28,
0x05, 0x52, 0x09, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x4c, 0x69, 0x66, 0x65, 0x22, 0x0b, 0x0a, 0x09,
0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x52, 0x65, 0x71, 0x22, 0x3a, 0x0a, 0x0a, 0x4c, 0x6f, 0x67,
0x6f, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18,
0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d,
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65,
0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x8d, 0x03, 0x0a, 0x06, 0x44, 0x72, 0x69, 0x76, 0x65, 0x72,
0x12, 0x79, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64,
0x65, 0x12, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x2e, 0x47,
0x65, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x1a,
0x1d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74,
0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x22, 0x2b,
0x82, 0xd3, 0xe4, 0x93, 0x02, 0x25, 0x12, 0x23, 0x2f, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x2f,
0x67, 0x65, 0x74, 0x2d, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x2d, 0x63, 0x6f, 0x64, 0x65, 0x2f,
0x7b, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x7d, 0x12, 0x67, 0x0a, 0x0b, 0x53,
0x75, 0x62, 0x6d, 0x69, 0x74, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x1a, 0x2e, 0x61, 0x70, 0x69,
0x2e, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x50, 0x68,
0x6f, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x64, 0x72, 0x69,
0x76, 0x65, 0x72, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x52,
0x65, 0x73, 0x70, 0x22, 0x1f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x22, 0x14, 0x2f, 0x64, 0x72,
0x69, 0x76, 0x65, 0x72, 0x2f, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x2d, 0x70, 0x68, 0x6f, 0x6e,
0x65, 0x3a, 0x01, 0x2a, 0x12, 0x4e, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x14, 0x2e,
0x61, 0x70, 0x69, 0x2e, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e,
0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72,
0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93,
0x02, 0x12, 0x22, 0x0d, 0x2f, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x2f, 0x6c, 0x6f, 0x67, 0x69,
0x6e, 0x3a, 0x01, 0x2a, 0x12, 0x4f, 0x0a, 0x06, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x12, 0x15,
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x6f,
0x75, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x64, 0x72, 0x69, 0x76,
0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x16, 0x82,
0xd3, 0xe4, 0x93, 0x02, 0x10, 0x2a, 0x0e, 0x2f, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x2f, 0x6c,
0x6f, 0x67, 0x6f, 0x75, 0x74, 0x42, 0x1a, 0x5a, 0x18, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x2f,
0x61, 0x70, 0x69, 0x2f, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x3b, 0x64, 0x72, 0x69, 0x76, 0x65,
0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x6f, 0x74, 0x6f, 0x22, 0x36, 0x0a, 0x0c, 0x49, 0x44, 0x4e, 0x6f, 0x43, 0x68, 0x65, 0x63, 0x6b,
0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x64, 0x6e, 0x6f, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x69, 0x64, 0x6e, 0x6f, 0x22, 0x55, 0x0a, 0x0d, 0x49,
0x44, 0x4e, 0x6f, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04,
0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65,
0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74,
0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74,
0x75, 0x73, 0x22, 0x30, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43,
0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x68,
0x6f, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x65, 0x6c, 0x65, 0x70,
0x68, 0x6f, 0x6e, 0x65, 0x22, 0xb6, 0x01, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x69,
0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f,
0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18,
0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x76, 0x65, 0x72, 0x69,
0x66, 0x79, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x76,
0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x28, 0x0a, 0x10, 0x76, 0x65, 0x72,
0x69, 0x66, 0x79, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20,
0x01, 0x28, 0x03, 0x52, 0x0e, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x54,
0x69, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x10, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x5f, 0x63, 0x6f,
0x64, 0x65, 0x5f, 0x6c, 0x69, 0x66, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x76,
0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x4c, 0x69, 0x66, 0x65, 0x22, 0x2e, 0x0a,
0x0e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x12,
0x1c, 0x0a, 0x09, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x09, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x22, 0x57, 0x0a,
0x0f, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70,
0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04,
0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x16,
0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06,
0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x49, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52,
0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x68, 0x6f, 0x6e, 0x65,
0x12, 0x1f, 0x0a, 0x0b, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64,
0x65, 0x22, 0x96, 0x01, 0x0a, 0x09, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12,
0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x63,
0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a,
0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f,
0x6b, 0x65, 0x6e, 0x12, 0x26, 0x0a, 0x0f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x63, 0x72, 0x65,
0x61, 0x74, 0x65, 0x5f, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x74, 0x6f,
0x6b, 0x65, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x74,
0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x6c, 0x69, 0x66, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52,
0x09, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x4c, 0x69, 0x66, 0x65, 0x22, 0x0b, 0x0a, 0x09, 0x4c, 0x6f,
0x67, 0x6f, 0x75, 0x74, 0x52, 0x65, 0x71, 0x22, 0x3a, 0x0a, 0x0a, 0x4c, 0x6f, 0x67, 0x6f, 0x75,
0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20,
0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73,
0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73,
0x61, 0x67, 0x65, 0x32, 0xee, 0x03, 0x0a, 0x06, 0x44, 0x72, 0x69, 0x76, 0x65, 0x72, 0x12, 0x5f,
0x0a, 0x09, 0x49, 0x44, 0x4e, 0x6f, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x18, 0x2e, 0x61, 0x70,
0x69, 0x2e, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x2e, 0x49, 0x44, 0x4e, 0x6f, 0x43, 0x68, 0x65,
0x63, 0x6b, 0x52, 0x65, 0x71, 0x1a, 0x19, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x64, 0x72, 0x69, 0x76,
0x65, 0x72, 0x2e, 0x49, 0x44, 0x4e, 0x6f, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70,
0x22, 0x1d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x17, 0x22, 0x12, 0x2f, 0x64, 0x72, 0x69, 0x76, 0x65,
0x72, 0x2f, 0x69, 0x64, 0x6e, 0x6f, 0x2d, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x3a, 0x01, 0x2a, 0x12,
0x79, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65,
0x12, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x2e, 0x47, 0x65,
0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x1d,
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x56,
0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x22, 0x2b, 0x82,
0xd3, 0xe4, 0x93, 0x02, 0x25, 0x12, 0x23, 0x2f, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x2f, 0x67,
0x65, 0x74, 0x2d, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x2d, 0x63, 0x6f, 0x64, 0x65, 0x2f, 0x7b,
0x74, 0x65, 0x6c, 0x65, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x7d, 0x12, 0x67, 0x0a, 0x0b, 0x53, 0x75,
0x62, 0x6d, 0x69, 0x74, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x1a, 0x2e, 0x61, 0x70, 0x69, 0x2e,
0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x50, 0x68, 0x6f,
0x6e, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x64, 0x72, 0x69, 0x76,
0x65, 0x72, 0x2e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x52, 0x65,
0x73, 0x70, 0x22, 0x1f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x22, 0x14, 0x2f, 0x64, 0x72, 0x69,
0x76, 0x65, 0x72, 0x2f, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x2d, 0x70, 0x68, 0x6f, 0x6e, 0x65,
0x3a, 0x01, 0x2a, 0x12, 0x4e, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x14, 0x2e, 0x61,
0x70, 0x69, 0x2e, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52,
0x65, 0x71, 0x1a, 0x15, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x2e,
0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02,
0x12, 0x22, 0x0d, 0x2f, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x2f, 0x6c, 0x6f, 0x67, 0x69, 0x6e,
0x3a, 0x01, 0x2a, 0x12, 0x4f, 0x0a, 0x06, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x12, 0x15, 0x2e,
0x61, 0x70, 0x69, 0x2e, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x6f, 0x75,
0x74, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x64, 0x72, 0x69, 0x76, 0x65,
0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x16, 0x82, 0xd3,
0xe4, 0x93, 0x02, 0x10, 0x2a, 0x0e, 0x2f, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x2f, 0x6c, 0x6f,
0x67, 0x6f, 0x75, 0x74, 0x42, 0x1a, 0x5a, 0x18, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x2f, 0x61,
0x70, 0x69, 0x2f, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x3b, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -594,28 +718,32 @@ func file_api_driver_driver_proto_rawDescGZIP() []byte {
return file_api_driver_driver_proto_rawDescData
}
var file_api_driver_driver_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_api_driver_driver_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_api_driver_driver_proto_goTypes = []interface{}{
(*GetVerifyCodeReq)(nil), // 0: api.driver.GetVerifyCodeReq
(*GetVerifyCodeResp)(nil), // 1: api.driver.GetVerifyCodeResp
(*SubmitPhoneReq)(nil), // 2: api.driver.SubmitPhoneReq
(*SubmitPhoneResp)(nil), // 3: api.driver.SubmitPhoneResp
(*LoginReq)(nil), // 4: api.driver.LoginReq
(*LoginResp)(nil), // 5: api.driver.LoginResp
(*LogoutReq)(nil), // 6: api.driver.LogoutReq
(*LogoutResp)(nil), // 7: api.driver.LogoutResp
(*IDNoCheckReq)(nil), // 0: api.driver.IDNoCheckReq
(*IDNoCheckResp)(nil), // 1: api.driver.IDNoCheckResp
(*GetVerifyCodeReq)(nil), // 2: api.driver.GetVerifyCodeReq
(*GetVerifyCodeResp)(nil), // 3: api.driver.GetVerifyCodeResp
(*SubmitPhoneReq)(nil), // 4: api.driver.SubmitPhoneReq
(*SubmitPhoneResp)(nil), // 5: api.driver.SubmitPhoneResp
(*LoginReq)(nil), // 6: api.driver.LoginReq
(*LoginResp)(nil), // 7: api.driver.LoginResp
(*LogoutReq)(nil), // 8: api.driver.LogoutReq
(*LogoutResp)(nil), // 9: api.driver.LogoutResp
}
var file_api_driver_driver_proto_depIdxs = []int32{
0, // 0: api.driver.Driver.GetVerifyCode:input_type -> api.driver.GetVerifyCodeReq
2, // 1: api.driver.Driver.SubmitPhone:input_type -> api.driver.SubmitPhoneReq
4, // 2: api.driver.Driver.Login:input_type -> api.driver.LoginReq
6, // 3: api.driver.Driver.Logout:input_type -> api.driver.LogoutReq
1, // 4: api.driver.Driver.GetVerifyCode:output_type -> api.driver.GetVerifyCodeResp
3, // 5: api.driver.Driver.SubmitPhone:output_type -> api.driver.SubmitPhoneResp
5, // 6: api.driver.Driver.Login:output_type -> api.driver.LoginResp
7, // 7: api.driver.Driver.Logout:output_type -> api.driver.LogoutResp
4, // [4:8] is the sub-list for method output_type
0, // [0:4] is the sub-list for method input_type
0, // 0: api.driver.Driver.IDNoCheck:input_type -> api.driver.IDNoCheckReq
2, // 1: api.driver.Driver.GetVerifyCode:input_type -> api.driver.GetVerifyCodeReq
4, // 2: api.driver.Driver.SubmitPhone:input_type -> api.driver.SubmitPhoneReq
6, // 3: api.driver.Driver.Login:input_type -> api.driver.LoginReq
8, // 4: api.driver.Driver.Logout:input_type -> api.driver.LogoutReq
1, // 5: api.driver.Driver.IDNoCheck:output_type -> api.driver.IDNoCheckResp
3, // 6: api.driver.Driver.GetVerifyCode:output_type -> api.driver.GetVerifyCodeResp
5, // 7: api.driver.Driver.SubmitPhone:output_type -> api.driver.SubmitPhoneResp
7, // 8: api.driver.Driver.Login:output_type -> api.driver.LoginResp
9, // 9: api.driver.Driver.Logout:output_type -> api.driver.LogoutResp
5, // [5:10] is the sub-list for method output_type
0, // [0:5] 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
@ -628,7 +756,7 @@ func file_api_driver_driver_proto_init() {
}
if !protoimpl.UnsafeEnabled {
file_api_driver_driver_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetVerifyCodeReq); i {
switch v := v.(*IDNoCheckReq); i {
case 0:
return &v.state
case 1:
@ -640,7 +768,7 @@ func file_api_driver_driver_proto_init() {
}
}
file_api_driver_driver_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetVerifyCodeResp); i {
switch v := v.(*IDNoCheckResp); i {
case 0:
return &v.state
case 1:
@ -652,7 +780,7 @@ func file_api_driver_driver_proto_init() {
}
}
file_api_driver_driver_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SubmitPhoneReq); i {
switch v := v.(*GetVerifyCodeReq); i {
case 0:
return &v.state
case 1:
@ -664,7 +792,7 @@ func file_api_driver_driver_proto_init() {
}
}
file_api_driver_driver_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SubmitPhoneResp); i {
switch v := v.(*GetVerifyCodeResp); i {
case 0:
return &v.state
case 1:
@ -676,7 +804,7 @@ func file_api_driver_driver_proto_init() {
}
}
file_api_driver_driver_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LoginReq); i {
switch v := v.(*SubmitPhoneReq); i {
case 0:
return &v.state
case 1:
@ -688,7 +816,7 @@ func file_api_driver_driver_proto_init() {
}
}
file_api_driver_driver_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LoginResp); i {
switch v := v.(*SubmitPhoneResp); i {
case 0:
return &v.state
case 1:
@ -700,7 +828,7 @@ func file_api_driver_driver_proto_init() {
}
}
file_api_driver_driver_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LogoutReq); i {
switch v := v.(*LoginReq); i {
case 0:
return &v.state
case 1:
@ -712,6 +840,30 @@ func file_api_driver_driver_proto_init() {
}
}
file_api_driver_driver_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LoginResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_api_driver_driver_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LogoutReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_api_driver_driver_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LogoutResp); i {
case 0:
return &v.state
@ -730,7 +882,7 @@ func file_api_driver_driver_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_api_driver_driver_proto_rawDesc,
NumEnums: 0,
NumMessages: 8,
NumMessages: 10,
NumExtensions: 0,
NumServices: 1,
},

@ -9,6 +9,14 @@ option go_package = "driver/api/driver;driver";
service Driver {
//
rpc IDNoCheck (IDNoCheckReq) returns (IDNoCheckResp) {
option (google.api.http) = {
post: "/driver/idno-check",
body: "*",
};
}
//
rpc GetVerifyCode (GetVerifyCodeReq) returns (GetVerifyCodeResp) {
option (google.api.http) = {
@ -40,6 +48,17 @@ service Driver {
}
}
//
message IDNoCheckReq {
string name = 1;
string idno = 2;
};
message IDNoCheckResp {
int64 code = 1;
string message = 2;
string status = 3;
};
//
message GetVerifyCodeReq {
string telephone = 1;
@ -59,7 +78,6 @@ message GetVerifyCodeResp {
//
message SubmitPhoneReq {
string telephone = 1;
string verify_code = 2;
};
message SubmitPhoneResp {
int64 code = 1;

@ -22,6 +22,8 @@ const _ = grpc.SupportPackageIsVersion7
//
// 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 DriverClient interface {
// 校验身份证号码
IDNoCheck(ctx context.Context, in *IDNoCheckReq, opts ...grpc.CallOption) (*IDNoCheckResp, error)
// 获取验证码
GetVerifyCode(ctx context.Context, in *GetVerifyCodeReq, opts ...grpc.CallOption) (*GetVerifyCodeResp, error)
// 提交电话号码
@ -40,6 +42,15 @@ func NewDriverClient(cc grpc.ClientConnInterface) DriverClient {
return &driverClient{cc}
}
func (c *driverClient) IDNoCheck(ctx context.Context, in *IDNoCheckReq, opts ...grpc.CallOption) (*IDNoCheckResp, error) {
out := new(IDNoCheckResp)
err := c.cc.Invoke(ctx, "/api.driver.Driver/IDNoCheck", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *driverClient) GetVerifyCode(ctx context.Context, in *GetVerifyCodeReq, opts ...grpc.CallOption) (*GetVerifyCodeResp, error) {
out := new(GetVerifyCodeResp)
err := c.cc.Invoke(ctx, "/api.driver.Driver/GetVerifyCode", in, out, opts...)
@ -80,6 +91,8 @@ func (c *driverClient) Logout(ctx context.Context, in *LogoutReq, opts ...grpc.C
// All implementations must embed UnimplementedDriverServer
// for forward compatibility
type DriverServer interface {
// 校验身份证号码
IDNoCheck(context.Context, *IDNoCheckReq) (*IDNoCheckResp, error)
// 获取验证码
GetVerifyCode(context.Context, *GetVerifyCodeReq) (*GetVerifyCodeResp, error)
// 提交电话号码
@ -95,6 +108,9 @@ type DriverServer interface {
type UnimplementedDriverServer struct {
}
func (UnimplementedDriverServer) IDNoCheck(context.Context, *IDNoCheckReq) (*IDNoCheckResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method IDNoCheck not implemented")
}
func (UnimplementedDriverServer) GetVerifyCode(context.Context, *GetVerifyCodeReq) (*GetVerifyCodeResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetVerifyCode not implemented")
}
@ -120,6 +136,24 @@ func RegisterDriverServer(s grpc.ServiceRegistrar, srv DriverServer) {
s.RegisterService(&Driver_ServiceDesc, srv)
}
func _Driver_IDNoCheck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(IDNoCheckReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DriverServer).IDNoCheck(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/api.driver.Driver/IDNoCheck",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DriverServer).IDNoCheck(ctx, req.(*IDNoCheckReq))
}
return interceptor(ctx, in, info, handler)
}
func _Driver_GetVerifyCode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetVerifyCodeReq)
if err := dec(in); err != nil {
@ -199,6 +233,10 @@ var Driver_ServiceDesc = grpc.ServiceDesc{
ServiceName: "api.driver.Driver",
HandlerType: (*DriverServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "IDNoCheck",
Handler: _Driver_IDNoCheck_Handler,
},
{
MethodName: "GetVerifyCode",
Handler: _Driver_GetVerifyCode_Handler,

@ -20,12 +20,14 @@ var _ = binding.EncodeURL
const _ = http.SupportPackageIsVersion1
const OperationDriverGetVerifyCode = "/api.driver.Driver/GetVerifyCode"
const OperationDriverIDNoCheck = "/api.driver.Driver/IDNoCheck"
const OperationDriverLogin = "/api.driver.Driver/Login"
const OperationDriverLogout = "/api.driver.Driver/Logout"
const OperationDriverSubmitPhone = "/api.driver.Driver/SubmitPhone"
type DriverHTTPServer interface {
GetVerifyCode(context.Context, *GetVerifyCodeReq) (*GetVerifyCodeResp, error)
IDNoCheck(context.Context, *IDNoCheckReq) (*IDNoCheckResp, error)
Login(context.Context, *LoginReq) (*LoginResp, error)
Logout(context.Context, *LogoutReq) (*LogoutResp, error)
SubmitPhone(context.Context, *SubmitPhoneReq) (*SubmitPhoneResp, error)
@ -33,12 +35,32 @@ type DriverHTTPServer interface {
func RegisterDriverHTTPServer(s *http.Server, srv DriverHTTPServer) {
r := s.Route("/")
r.POST("/driver/idno-check", _Driver_IDNoCheck0_HTTP_Handler(srv))
r.GET("/driver/get-verify-code/{telephone}", _Driver_GetVerifyCode0_HTTP_Handler(srv))
r.POST("/driver/submit-phone", _Driver_SubmitPhone0_HTTP_Handler(srv))
r.POST("/driver/login", _Driver_Login0_HTTP_Handler(srv))
r.DELETE("/driver/logout", _Driver_Logout0_HTTP_Handler(srv))
}
func _Driver_IDNoCheck0_HTTP_Handler(srv DriverHTTPServer) func(ctx http.Context) error {
return func(ctx http.Context) error {
var in IDNoCheckReq
if err := ctx.Bind(&in); err != nil {
return err
}
http.SetOperation(ctx, OperationDriverIDNoCheck)
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.IDNoCheck(ctx, req.(*IDNoCheckReq))
})
out, err := h(ctx, &in)
if err != nil {
return err
}
reply := out.(*IDNoCheckResp)
return ctx.Result(200, reply)
}
}
func _Driver_GetVerifyCode0_HTTP_Handler(srv DriverHTTPServer) func(ctx http.Context) error {
return func(ctx http.Context) error {
var in GetVerifyCodeReq
@ -120,6 +142,7 @@ func _Driver_Logout0_HTTP_Handler(srv DriverHTTPServer) func(ctx http.Context) e
type DriverHTTPClient interface {
GetVerifyCode(ctx context.Context, req *GetVerifyCodeReq, opts ...http.CallOption) (rsp *GetVerifyCodeResp, err error)
IDNoCheck(ctx context.Context, req *IDNoCheckReq, opts ...http.CallOption) (rsp *IDNoCheckResp, err error)
Login(ctx context.Context, req *LoginReq, opts ...http.CallOption) (rsp *LoginResp, err error)
Logout(ctx context.Context, req *LogoutReq, opts ...http.CallOption) (rsp *LogoutResp, err error)
SubmitPhone(ctx context.Context, req *SubmitPhoneReq, opts ...http.CallOption) (rsp *SubmitPhoneResp, err error)
@ -146,6 +169,19 @@ func (c *DriverHTTPClientImpl) GetVerifyCode(ctx context.Context, in *GetVerifyC
return &out, err
}
func (c *DriverHTTPClientImpl) IDNoCheck(ctx context.Context, in *IDNoCheckReq, opts ...http.CallOption) (*IDNoCheckResp, error) {
var out IDNoCheckResp
pattern := "/driver/idno-check"
path := binding.EncodeURL(pattern, in, false)
opts = append(opts, http.Operation(OperationDriverIDNoCheck))
opts = append(opts, http.PathTemplate(pattern))
err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...)
if err != nil {
return nil, err
}
return &out, err
}
func (c *DriverHTTPClientImpl) Login(ctx context.Context, in *LoginReq, opts ...http.CallOption) (*LoginResp, error) {
var out LoginResp
pattern := "/driver/login"

@ -6,6 +6,7 @@ require (
github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20221130041748-2cf82fa4a75c
github.com/go-kratos/kratos/v2 v2.5.3
github.com/go-redis/redis/v9 v9.0.0-rc.2
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/google/uuid v1.3.0
github.com/google/wire v0.5.0
github.com/hashicorp/consul/api v1.18.0
@ -31,7 +32,6 @@ require (
github.com/go-playground/form/v4 v4.2.0 // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/subcommands v1.0.1 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
github.com/hashicorp/go-hclog v0.14.1 // indirect
@ -46,13 +46,10 @@ require (
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.opentelemetry.io/otel/trace v1.11.2 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.2.0 // indirect
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
golang.org/x/sys v0.2.0 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/tools v0.1.12 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

@ -75,6 +75,8 @@ github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang-jwt/jwt/v4 v4.4.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@ -105,7 +107,6 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/subcommands v1.0.1 h1:/eqq+otEXm5vhfBrbREPCSVQbvofip6kIz+mX5TUH7k=
github.com/google/subcommands v1.0.1/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
@ -281,8 +282,6 @@ golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@ -309,7 +308,6 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 h1:w8s32wxx3sY+OjLlv9qltkLU5yvJzxjjgiHWLjdIcw4=
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -358,8 +356,6 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3
golang.org/x/tools v0.0.0-20190422233926-fe54fb35175b/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

@ -4,14 +4,18 @@ import (
"context"
"database/sql"
"github.com/go-kratos/kratos/v2/errors"
"github.com/golang-jwt/jwt/v4"
"gorm.io/gorm"
"regexp"
"strings"
"time"
)
const SecretKey = "driver secret key"
// 司机业务逻辑
type DriverBiz struct {
di DriverInterface
DI DriverInterface
}
// 司机表模型
@ -27,8 +31,8 @@ type Driver struct {
type DriverWork struct {
Telephone string `gorm:"type:varchar(16);uniqueIndex;" json:"telephone"`
Token sql.NullString `gorm:"type:varchar(2047);" json:"token"`
Name sql.NullString `gorm:"type:varchar(255);index;" json:"name"`
Status sql.NullString `gorm:"type:enum('out', 'in', 'listen', 'stop');" json:"status"`
Name sql.NullString `gorm:"type:varchar(255);index;" json:"name"`
IdNumber sql.NullString `gorm:"type:char(18);uniqueIndex;" json:"id_number"`
IdImageA sql.NullString `gorm:"type:varchar(255);" json:"id_image_a"`
LicenseImageA sql.NullString `gorm:"type:varchar(255);" json:"license_image_a"`
@ -43,20 +47,89 @@ const DriverStatusOut = "out"
const DriverStatusIn = "in"
const DriverStatusListen = "listen"
const DriverStatusStop = "stop"
const DriverTokenLife = 1 * 30 * 24 * 3600
// 司机相关的资源操作接口
type DriverInterface interface {
GetVerifyCode(context.Context, string) (string, error)
FetchVerifyCode(context.Context, string) (string, error)
FetchInfoByTel(context.Context, string) (*Driver, error)
CreateDriver(context.Context, *Driver) (*Driver, error)
InitDriverInfo(context.Context, string) (*Driver, error)
GetSavedVerifyCode(context.Context, string) (string, error)
SaveToken(context.Context, string, string) error
GetToken(context.Context, string) (string, error)
}
// DriverBiz 构造器
func NewDriverBiz(di DriverInterface) *DriverBiz {
return &DriverBiz{
di: di,
DI: di,
}
}
// 验证登录信息方法
func (db *DriverBiz) CheckLogin(ctx context.Context, tel, verifyCode string) (string, error) {
// 验证验证码是否正确
code, err := db.DI.GetSavedVerifyCode(ctx, tel)
if err != nil {
return "", err
}
if verifyCode != code {
return "", errors.New(1, "verify code error", "'")
}
// 生成token
token, err := generateJWT(tel)
if err != nil {
return "", err
}
// 存储到driver表中
if err := db.DI.SaveToken(ctx, tel, token); err != nil {
return "", err
}
// 返回token
return token, nil
}
// 生成JWT
func generateJWT(tel string) (string, error) {
// 构建token类型
claims := jwt.RegisteredClaims{
Issuer: "LaomaDJ",
Subject: "driver authentication",
Audience: []string{"driver"},
ExpiresAt: jwt.NewNumericDate(time.Now().Add(DriverTokenLife * time.Second)),
NotBefore: nil,
IssuedAt: jwt.NewNumericDate(time.Now()),
ID: tel,
}
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
// 签名
// 生成token字符串
tokenString, err := token.SignedString([]byte(SecretKey))
if err != nil {
return "", err
}
return tokenString, nil
}
// 比对验证码是否一致
// 将司机信息入库
func (db *DriverBiz) InitDriverInfo(ctx context.Context, tel string) (*Driver, error) {
// 校验验证码(略)
// 司机是否已经注册的校验(略)?
// 司机是否在黑名单中校验(略)?
//
if tel == "" {
return nil, errors.New(1, "telephone is empty", "")
}
return db.DI.InitDriverInfo(ctx, tel)
}
// 实现获取验证码的业务逻辑
@ -68,7 +141,7 @@ func (db *DriverBiz) GetVerifyCode(ctx context.Context, tel string) (string, err
return "", errors.New(200, "DRIVER", "driver telephone error")
}
// 二调用data/获取验证码
return db.di.GetVerifyCode(ctx, tel)
return db.DI.GetVerifyCode(ctx, tel)
}
func (db *DriverBiz) CheckVerifyCode(ctx context.Context, tel, code string) bool {
@ -84,7 +157,7 @@ func (db *DriverBiz) CheckVerifyCode(ctx context.Context, tel, code string) bool
return false
}
verifyCode, err := db.di.FetchVerifyCode(ctx, tel)
verifyCode, err := db.DI.FetchVerifyCode(ctx, tel)
if err != nil {
return false
}
@ -96,23 +169,9 @@ func (db *DriverBiz) CheckVerifyCode(ctx context.Context, tel, code string) bool
}
func (db *DriverBiz) GetInfoByTel(ctx context.Context, tel string) (*Driver, error) {
driver, err := db.di.FetchInfoByTel(ctx, tel)
driver, err := db.DI.FetchInfoByTel(ctx, tel)
if err != nil {
return nil, err
}
return driver, nil
}
func (db *DriverBiz) LoadOrCreateByTel(ctx context.Context, tel string) (*Driver, error) {
driver, err := db.di.FetchInfoByTel(ctx, tel)
if err == nil {
return driver, nil
}
driver = &Driver{}
driver.Telephone = tel
driver, err := db.di.CreateDriver(ctx, driver)
if err != nil {
return nil
}
return driver
}

@ -14,6 +14,9 @@ func NewDriverService() *DriverService {
return &DriverService{}
}
func (s *DriverService) IDNoCheck(ctx context.Context, req *pb.IDNoCheckReq) (*pb.IDNoCheckResp, error) {
return &pb.IDNoCheckResp{}, nil
}
func (s *DriverService) GetVerifyCode(ctx context.Context, req *pb.GetVerifyCodeReq) (*pb.GetVerifyCodeResp, error) {
return &pb.GetVerifyCodeResp{}, nil
}

@ -1,14 +1,18 @@
package server
import (
"context"
"driver/api/driver"
v1 "driver/api/helloworld/v1"
"driver/internal/biz"
"driver/internal/conf"
"driver/internal/service"
"github.com/go-kratos/kratos/v2/log"
"github.com/go-kratos/kratos/v2/middleware/auth/jwt"
"github.com/go-kratos/kratos/v2/middleware/recovery"
"github.com/go-kratos/kratos/v2/middleware/selector"
"github.com/go-kratos/kratos/v2/transport/http"
jwtv4 "github.com/golang-jwt/jwt/v4"
)
// NewHTTPServer new a HTTP server.
@ -16,6 +20,23 @@ func NewHTTPServer(c *conf.Server, greeter *service.GreeterService, driverServic
var opts = []http.ServerOption{
http.Middleware(
recovery.Recovery(),
// JWT 中间件
selector.Server(
jwt.Server(func(token *jwtv4.Token) (interface{}, error) {
return []byte(biz.SecretKey), nil
}),
DriverToken(driverService)).Match(func(ctx context.Context, operation string) bool {
// 记录不需要的校验的
noJWT := map[string]struct{}{
"/api.driver.Driver/Login": {},
"/api.driver.Driver/GetVerifyCode": {},
"/api.driver.Driver/SubmitPhone": {},
}
if _, exists := noJWT[operation]; exists {
return false
}
return true
}).Build(),
),
}
if c.Http.Network != "" {
@ -29,7 +50,7 @@ func NewHTTPServer(c *conf.Server, greeter *service.GreeterService, driverServic
}
srv := http.NewServer(opts...)
v1.RegisterGreeterHTTPServer(srv, greeter)
driver.RegisterDriverHTTPServer(srv, driverService)
return srv
}

@ -0,0 +1,53 @@
package server
import (
"context"
"driver/internal/service"
"github.com/go-kratos/kratos/v2/errors"
"github.com/go-kratos/kratos/v2/middleware"
"github.com/go-kratos/kratos/v2/middleware/auth/jwt"
"github.com/go-kratos/kratos/v2/transport"
jwtv4 "github.com/golang-jwt/jwt/v4"
"strings"
)
// 返回中间件的函数
func DriverToken(service *service.DriverService) middleware.Middleware {
return func(handler middleware.Handler) middleware.Handler {
return func(ctx context.Context, req interface{}) (interface{}, error) {
// 1.校验JWT获取其中的司机标识tel
claims, ok := jwt.FromContext(ctx)
if !ok {
return nil, errors.Unauthorized("Unauthorized", "claims not found")
}
claimsMap := claims.(jwtv4.MapClaims)
tel := claimsMap["jti"]
// 2.利用tel获取存储在司机表缓存中的token
token, err := service.Bz.DI.GetToken(ctx, tel.(string))
if err != nil {
return nil, errors.Unauthorized("Unauthorized", "driver token not found")
}
// 3.比对两个token(和请求头中的)
header, _ := transport.FromServerContext(ctx)
auths := strings.SplitN(header.RequestHeader().Get("Authorization"), " ", 2)
reqToken := auths[1]
if token != reqToken {
return nil, errors.Unauthorized("Unauthorized", "token was updated")
}
// 4.记录登录司机信息
driver, err := service.Bz.DI.FetchInfoByTel(ctx, tel.(string))
if err != nil {
return nil, errors.Unauthorized("Unauthorized", "driver was found")
}
// 基于当前的ctx构建新的带有值的ctx
ctxWithDriver := context.WithValue(ctx, "driver", driver)
//ctxWithDriver.Value("driver")
// 5.jwt校验通过
return handler(ctxWithDriver, req)
}
}
}

@ -3,6 +3,7 @@ package service
import (
"context"
"driver/internal/biz"
"log"
"time"
pb "driver/api/driver"
@ -10,18 +11,23 @@ import (
type DriverService struct {
pb.UnimplementedDriverServer
bz *biz.DriverBiz
Bz *biz.DriverBiz
}
func NewDriverService(bz *biz.DriverBiz) *DriverService {
return &DriverService{
bz: bz,
Bz: bz,
}
}
// IDNoCheck 校验身份证号码
func (s *DriverService) IDNoCheck(ctx context.Context, req *pb.IDNoCheckReq) (*pb.IDNoCheckResp, error) {
return &pb.IDNoCheckResp{}, nil
}
func (s *DriverService) GetVerifyCode(ctx context.Context, req *pb.GetVerifyCodeReq) (*pb.GetVerifyCodeResp, error) {
// 获取验证码
code, err := s.bz.GetVerifyCode(ctx, req.Telephone)
code, err := s.Bz.GetVerifyCode(ctx, req.Telephone)
if err != nil {
return &pb.GetVerifyCodeResp{
Code: 1,
@ -39,24 +45,38 @@ func (s *DriverService) GetVerifyCode(ctx context.Context, req *pb.GetVerifyCode
}
func (s *DriverService) SubmitPhone(ctx context.Context, req *pb.SubmitPhoneReq) (*pb.SubmitPhoneResp, error) {
//
checkResult := s.bz.CheckVerifyCode(ctx, req.Telephone, req.VerifyCode)
if !checkResult {
// 将司机信息入库并设置状态未stop暂时停用(核心逻辑)
driver, err := s.Bz.InitDriverInfo(ctx, req.Telephone)
if err != nil {
return &pb.SubmitPhoneResp{
Code: 1,
Message: "verify code check failed",
Message: "司机号码提交失败",
}, nil
}
// 校验是否已经注册
// 校验是否处于黑名单
return &pb.SubmitPhoneResp{}, nil
return &pb.SubmitPhoneResp{
Code: 0,
Message: "司机号码提交成功",
Status: driver.Status.String,
}, nil
}
// 登录 service
func (s *DriverService) Login(ctx context.Context, req *pb.LoginReq) (*pb.LoginResp, error) {
return &pb.LoginResp{}, nil
}
func (s *DriverService) Logout(ctx context.Context, req *pb.LogoutReq) (*pb.LogoutResp, error) {
return &pb.LogoutResp{}, nil
// 由 biz 层完成业务逻辑处理
token, err := s.Bz.CheckLogin(ctx, req.Telephone, req.VerifyCode)
if err != nil {
log.Println(err)
return &pb.LoginResp{
Code: 1,
Message: "司机登录失败",
}, nil
}
return &pb.LoginResp{
Code: 0,
Message: "司机登录成功",
Token: token,
TokenCreateAt: time.Now().Unix(),
TokenLife: biz.DriverTokenLife,
}, nil
}

@ -31,6 +31,31 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Status'
/driver/idno-check:
post:
tags:
- Driver
description: 校验身份证号码
operationId: Driver_IDNoCheck
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/IDNoCheckReq'
required: true
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/IDNoCheckResp'
default:
description: Default error response
content:
application/json:
schema:
$ref: '#/components/schemas/Status'
/driver/login:
post:
tags:
@ -129,6 +154,24 @@ components:
description: The type of the serialized message.
additionalProperties: true
description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message.
IDNoCheckReq:
type: object
properties:
name:
type: string
idno:
type: string
description: 校验身份证号码消息
IDNoCheckResp:
type: object
properties:
code:
type: integer
format: int64
message:
type: string
status:
type: string
LoginReq:
type: object
properties:
@ -185,8 +228,6 @@ components:
properties:
telephone:
type: string
verifyCode:
type: string
description: 提交电话号码请求消息
SubmitPhoneResp:
type: object

Loading…
Cancel
Save