init get_verifycode

main
Wbbbbjikjgo 9 months ago
parent c95f55f1c0
commit 59230d6e39

@ -67,10 +67,11 @@ func (x *GetVerifyCodeReq) GetTelephone() string {
type GetVerifyCodeResp struct {
state protoimpl.MessageState `protogen:"open.v1"`
Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
VerifyCode string `protobuf:"bytes,3,opt,name=verify_code,json=verifyCode,proto3" json:"verify_code,omitempty"`
VerifyGenerateTime int32 `protobuf:"varint,4,opt,name=verify_generate_time,json=verifyGenerateTime,proto3" json:"verify_generate_time,omitempty"`
VerifyGenerateTime int64 `protobuf:"varint,4,opt,name=verify_generate_time,json=verifyGenerateTime,proto3" json:"verify_generate_time,omitempty"`
VerifyCodeLife int64 `protobuf:"varint,5,opt,name=verify_code_life,json=verifyCodeLife,proto3" json:"verify_code_life,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@ -105,7 +106,7 @@ func (*GetVerifyCodeResp) Descriptor() ([]byte, []int) {
return file_api_customer_customer_proto_rawDescGZIP(), []int{1}
}
func (x *GetVerifyCodeResp) GetCode() int32 {
func (x *GetVerifyCodeResp) GetCode() int64 {
if x != nil {
return x.Code
}
@ -126,13 +127,20 @@ func (x *GetVerifyCodeResp) GetVerifyCode() string {
return ""
}
func (x *GetVerifyCodeResp) GetVerifyGenerateTime() int32 {
func (x *GetVerifyCodeResp) GetVerifyGenerateTime() int64 {
if x != nil {
return x.VerifyGenerateTime
}
return 0
}
func (x *GetVerifyCodeResp) GetVerifyCodeLife() int64 {
if x != nil {
return x.VerifyCodeLife
}
return 0
}
var File_api_customer_customer_proto protoreflect.FileDescriptor
var file_api_customer_customer_proto_rawDesc = []byte{
@ -143,28 +151,31 @@ var file_api_customer_customer_proto_rawDesc = []byte{
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, 0x94, 0x01, 0x0a, 0x11,
0x52, 0x09, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x22, 0xbe, 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, 0x05, 0x52,
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, 0x30, 0x0a, 0x14, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x5f, 0x67, 0x65, 0x6e, 0x65, 0x72,
0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x12,
0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x12,
0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x54, 0x69,
0x6d, 0x65, 0x32, 0x8b, 0x01, 0x0a, 0x08, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x12,
0x7f, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65,
0x12, 0x1e, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x2e,
0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71,
0x1a, 0x1f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x2e,
0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73,
0x70, 0x22, 0x2d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x27, 0x12, 0x25, 0x2f, 0x63, 0x75, 0x73, 0x74,
0x6f, 0x6d, 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,
0x42, 0x20, 0x5a, 0x1e, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69,
0x2f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x3b, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d,
0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
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, 0x03, 0x52, 0x0e, 0x76, 0x65,
0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x4c, 0x69, 0x66, 0x65, 0x32, 0x8b, 0x01, 0x0a,
0x08, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x12, 0x7f, 0x0a, 0x0d, 0x47, 0x65, 0x74,
0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1e, 0x2e, 0x61, 0x70, 0x69,
0x2e, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x56, 0x65, 0x72,
0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x1f, 0x2e, 0x61, 0x70, 0x69,
0x2e, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x56, 0x65, 0x72,
0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x22, 0x2d, 0x82, 0xd3, 0xe4,
0x93, 0x02, 0x27, 0x12, 0x25, 0x2f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 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, 0x42, 0x20, 0x5a, 0x1e, 0x63, 0x75,
0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x75, 0x73, 0x74, 0x6f,
0x6d, 0x65, 0x72, 0x3b, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
}
var (

@ -17,8 +17,9 @@ message GetVerifyCodeReq{
string telephone =1;
}
message GetVerifyCodeResp {
int32 code =1;
int64 code =1;
string message =2;
string verify_code =3;
int32 verify_generate_time=4;
int64 verify_generate_time=4;
int64 verify_code_life=5;
}

@ -0,0 +1,262 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.1
// protoc v5.29.2
// source: api/verifyCode/verifyCode.proto
package verifyCode
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// 类型常量
type TYPE int32
const (
TYPE_DEFAULT TYPE = 0
TYPE_DIGIT TYPE = 1
TYPE_LETTER TYPE = 2
TYPE_MIXED TYPE = 3
)
// Enum value maps for TYPE.
var (
TYPE_name = map[int32]string{
0: "DEFAULT",
1: "DIGIT",
2: "LETTER",
3: "MIXED",
}
TYPE_value = map[string]int32{
"DEFAULT": 0,
"DIGIT": 1,
"LETTER": 2,
"MIXED": 3,
}
)
func (x TYPE) Enum() *TYPE {
p := new(TYPE)
*p = x
return p
}
func (x TYPE) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (TYPE) Descriptor() protoreflect.EnumDescriptor {
return file_api_verifyCode_verifyCode_proto_enumTypes[0].Descriptor()
}
func (TYPE) Type() protoreflect.EnumType {
return &file_api_verifyCode_verifyCode_proto_enumTypes[0]
}
func (x TYPE) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use TYPE.Descriptor instead.
func (TYPE) EnumDescriptor() ([]byte, []int) {
return file_api_verifyCode_verifyCode_proto_rawDescGZIP(), []int{0}
}
// 定义 GetVerifyCodeRequest 消息
type GetVerifyCodeRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
// 验证码长度
Length uint32 `protobuf:"varint,1,opt,name=length,proto3" json:"length,omitempty"`
// 验证码类型
Type TYPE `protobuf:"varint,2,opt,name=type,proto3,enum=api.verifyCode.TYPE" json:"type,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetVerifyCodeRequest) Reset() {
*x = GetVerifyCodeRequest{}
mi := &file_api_verifyCode_verifyCode_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetVerifyCodeRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetVerifyCodeRequest) ProtoMessage() {}
func (x *GetVerifyCodeRequest) ProtoReflect() protoreflect.Message {
mi := &file_api_verifyCode_verifyCode_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetVerifyCodeRequest.ProtoReflect.Descriptor instead.
func (*GetVerifyCodeRequest) Descriptor() ([]byte, []int) {
return file_api_verifyCode_verifyCode_proto_rawDescGZIP(), []int{0}
}
func (x *GetVerifyCodeRequest) GetLength() uint32 {
if x != nil {
return x.Length
}
return 0
}
func (x *GetVerifyCodeRequest) GetType() TYPE {
if x != nil {
return x.Type
}
return TYPE_DEFAULT
}
// 定义 GetVerifyCodeReply 消息
type GetVerifyCodeReply struct {
state protoimpl.MessageState `protogen:"open.v1"`
// 生成的验证码
Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetVerifyCodeReply) Reset() {
*x = GetVerifyCodeReply{}
mi := &file_api_verifyCode_verifyCode_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetVerifyCodeReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetVerifyCodeReply) ProtoMessage() {}
func (x *GetVerifyCodeReply) ProtoReflect() protoreflect.Message {
mi := &file_api_verifyCode_verifyCode_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetVerifyCodeReply.ProtoReflect.Descriptor instead.
func (*GetVerifyCodeReply) Descriptor() ([]byte, []int) {
return file_api_verifyCode_verifyCode_proto_rawDescGZIP(), []int{1}
}
func (x *GetVerifyCodeReply) GetCode() string {
if x != nil {
return x.Code
}
return ""
}
var File_api_verifyCode_verifyCode_proto protoreflect.FileDescriptor
var file_api_verifyCode_verifyCode_proto_rawDesc = []byte{
0x0a, 0x1f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65,
0x2f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x12, 0x0e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64,
0x65, 0x22, 0x58, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f,
0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x6e,
0x67, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74,
0x68, 0x12, 0x28, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32,
0x14, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65,
0x2e, 0x54, 0x59, 0x50, 0x45, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x28, 0x0a, 0x12, 0x47,
0x65, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x70, 0x6c,
0x79, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x04, 0x63, 0x6f, 0x64, 0x65, 0x2a, 0x35, 0x0a, 0x04, 0x54, 0x59, 0x50, 0x45, 0x12, 0x0b, 0x0a,
0x07, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x44, 0x49,
0x47, 0x49, 0x54, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x45, 0x54, 0x54, 0x45, 0x52, 0x10,
0x02, 0x12, 0x09, 0x0a, 0x05, 0x4d, 0x49, 0x58, 0x45, 0x44, 0x10, 0x03, 0x32, 0x67, 0x0a, 0x0a,
0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x59, 0x0a, 0x0d, 0x47, 0x65,
0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x24, 0x2e, 0x61, 0x70,
0x69, 0x2e, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x2e, 0x47, 0x65, 0x74,
0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f,
0x64, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65,
0x52, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x38, 0x0a, 0x0e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x65, 0x72,
0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x50, 0x01, 0x5a, 0x24, 0x76, 0x65, 0x72, 0x69, 0x66,
0x79, 0x43, 0x6f, 0x64, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79,
0x43, 0x6f, 0x64, 0x65, 0x3b, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_api_verifyCode_verifyCode_proto_rawDescOnce sync.Once
file_api_verifyCode_verifyCode_proto_rawDescData = file_api_verifyCode_verifyCode_proto_rawDesc
)
func file_api_verifyCode_verifyCode_proto_rawDescGZIP() []byte {
file_api_verifyCode_verifyCode_proto_rawDescOnce.Do(func() {
file_api_verifyCode_verifyCode_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_verifyCode_verifyCode_proto_rawDescData)
})
return file_api_verifyCode_verifyCode_proto_rawDescData
}
var file_api_verifyCode_verifyCode_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_api_verifyCode_verifyCode_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_api_verifyCode_verifyCode_proto_goTypes = []any{
(TYPE)(0), // 0: api.verifyCode.TYPE
(*GetVerifyCodeRequest)(nil), // 1: api.verifyCode.GetVerifyCodeRequest
(*GetVerifyCodeReply)(nil), // 2: api.verifyCode.GetVerifyCodeReply
}
var file_api_verifyCode_verifyCode_proto_depIdxs = []int32{
0, // 0: api.verifyCode.GetVerifyCodeRequest.type:type_name -> api.verifyCode.TYPE
1, // 1: api.verifyCode.VerifyCode.GetVerifyCode:input_type -> api.verifyCode.GetVerifyCodeRequest
2, // 2: api.verifyCode.VerifyCode.GetVerifyCode:output_type -> api.verifyCode.GetVerifyCodeReply
2, // [2:3] is the sub-list for method output_type
1, // [1:2] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_api_verifyCode_verifyCode_proto_init() }
func file_api_verifyCode_verifyCode_proto_init() {
if File_api_verifyCode_verifyCode_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_api_verifyCode_verifyCode_proto_rawDesc,
NumEnums: 1,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_api_verifyCode_verifyCode_proto_goTypes,
DependencyIndexes: file_api_verifyCode_verifyCode_proto_depIdxs,
EnumInfos: file_api_verifyCode_verifyCode_proto_enumTypes,
MessageInfos: file_api_verifyCode_verifyCode_proto_msgTypes,
}.Build()
File_api_verifyCode_verifyCode_proto = out.File
file_api_verifyCode_verifyCode_proto_rawDesc = nil
file_api_verifyCode_verifyCode_proto_goTypes = nil
file_api_verifyCode_verifyCode_proto_depIdxs = nil
}

@ -0,0 +1,33 @@
syntax = "proto3";
package api.verifyCode;
option go_package = "verifyCode/api/verifyCode;verifyCode";
option java_multiple_files = true;
option java_package = "api.verifyCode";
service VerifyCode {
rpc GetVerifyCode (GetVerifyCodeRequest) returns (GetVerifyCodeReply);
}
//
enum TYPE {
DEFAULT = 0;
DIGIT = 1;
LETTER = 2;
MIXED = 3;
};
// GetVerifyCodeRequest
message GetVerifyCodeRequest {
//
uint32 length = 1;
//
TYPE type = 2;
}
// GetVerifyCodeReply
message GetVerifyCodeReply {
//
string code = 1;
}

@ -0,0 +1,121 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v5.29.2
// source: api/verifyCode/verifyCode.proto
package verifyCode
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.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
VerifyCode_GetVerifyCode_FullMethodName = "/api.verifyCode.VerifyCode/GetVerifyCode"
)
// VerifyCodeClient is the client API for VerifyCode 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 VerifyCodeClient interface {
GetVerifyCode(ctx context.Context, in *GetVerifyCodeRequest, opts ...grpc.CallOption) (*GetVerifyCodeReply, error)
}
type verifyCodeClient struct {
cc grpc.ClientConnInterface
}
func NewVerifyCodeClient(cc grpc.ClientConnInterface) VerifyCodeClient {
return &verifyCodeClient{cc}
}
func (c *verifyCodeClient) GetVerifyCode(ctx context.Context, in *GetVerifyCodeRequest, opts ...grpc.CallOption) (*GetVerifyCodeReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetVerifyCodeReply)
err := c.cc.Invoke(ctx, VerifyCode_GetVerifyCode_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// VerifyCodeServer is the server API for VerifyCode service.
// All implementations must embed UnimplementedVerifyCodeServer
// for forward compatibility.
type VerifyCodeServer interface {
GetVerifyCode(context.Context, *GetVerifyCodeRequest) (*GetVerifyCodeReply, error)
mustEmbedUnimplementedVerifyCodeServer()
}
// UnimplementedVerifyCodeServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedVerifyCodeServer struct{}
func (UnimplementedVerifyCodeServer) GetVerifyCode(context.Context, *GetVerifyCodeRequest) (*GetVerifyCodeReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetVerifyCode not implemented")
}
func (UnimplementedVerifyCodeServer) mustEmbedUnimplementedVerifyCodeServer() {}
func (UnimplementedVerifyCodeServer) testEmbeddedByValue() {}
// UnsafeVerifyCodeServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to VerifyCodeServer will
// result in compilation errors.
type UnsafeVerifyCodeServer interface {
mustEmbedUnimplementedVerifyCodeServer()
}
func RegisterVerifyCodeServer(s grpc.ServiceRegistrar, srv VerifyCodeServer) {
// If the following call pancis, it indicates UnimplementedVerifyCodeServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&VerifyCode_ServiceDesc, srv)
}
func _VerifyCode_GetVerifyCode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetVerifyCodeRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(VerifyCodeServer).GetVerifyCode(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: VerifyCode_GetVerifyCode_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(VerifyCodeServer).GetVerifyCode(ctx, req.(*GetVerifyCodeRequest))
}
return interceptor(ctx, in, info, handler)
}
// VerifyCode_ServiceDesc is the grpc.ServiceDesc for VerifyCode service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var VerifyCode_ServiceDesc = grpc.ServiceDesc{
ServiceName: "api.verifyCode.VerifyCode",
HandlerType: (*VerifyCodeServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetVerifyCode",
Handler: _VerifyCode_GetVerifyCode_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "api/verifyCode/verifyCode.proto",
}

@ -13,6 +13,8 @@ require (
require (
dario.cat/mergo v1.0.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-kratos/aegis v0.2.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
@ -21,6 +23,7 @@ require (
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/redis/go-redis/v9 v9.7.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect

@ -4,11 +4,15 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
github.com/census-instrumentation/opencensus-proto v0.4.1 h1:iKLQ0xPNFxR/2hzXZMrBo8f1j86j5WHzznCCQxV/b8g=
github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b h1:ga8SEFjZ60pxLcmhnThWgvH2wg8376yUJmPhEH4H3kw=
github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/envoyproxy/go-control-plane v0.12.0 h1:4X+VP1GHd1Mhj6IB5mMeGbLCleqxjletLK6K0rbxyZI=
github.com/envoyproxy/go-control-plane v0.12.0/go.mod h1:ZBTaoJ23lqITozF0M6G4/IragXCQKCnYbmlmtHvwRG0=
github.com/envoyproxy/protoc-gen-validate v1.0.4 h1:gVPz/FMfvh57HdSJQyvBtF00j8JU4zdyUgIUNhlgg0A=
@ -48,6 +52,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E=
github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=

@ -2,7 +2,11 @@ package service
import (
"context"
"customer/api/verifyCode"
"github.com/go-kratos/kratos/v2/transport/grpc"
"github.com/redis/go-redis/v9"
"regexp"
"time"
pb "customer/api/customer"
)
@ -25,5 +29,62 @@ func (s *CustomerService) GetVerifyCode(ctx context.Context, req *pb.GetVerifyCo
Message: "电话号码格式错误",
}, nil
}
return &pb.GetVerifyCodeResp{}, nil
//连接目标grpc服务
conn, err := grpc.DialInsecure(
context.Background(),
grpc.WithEndpoint("localhost:9000"), //验证码服务的地址
)
if err != nil {
return &pb.GetVerifyCodeResp{
Code: 1,
Message: "验证码服务不可用",
}, nil
}
//关闭连接
defer func() {
_ = conn.Close()
}()
//发送获取验证码请求
client := verifyCode.NewVerifyCodeClient(conn)
reply, err := client.GetVerifyCode(context.Background(),
&verifyCode.GetVerifyCodeRequest{
Length: 6,
Type: 1,
})
if err != nil {
return &pb.GetVerifyCodeResp{
Code: 1,
Message: "验证码获取错误",
}, nil
}
//连接redis
options, err := redis.ParseURL("redis://192.168.233.10:6379/1?dial_timeout=1")
if err != nil {
return &pb.GetVerifyCodeResp{
Code: 1,
Message: "验证码连接错误redis",
}, nil
}
rdb := redis.NewClient(options)
//设置keycustomer-verify-code
const life = 60
status := rdb.Set(context.Background(), "CVC"+req.Telephone, reply.Code, life*time.Second)
if _, err := status.Result(); err != nil {
return &pb.GetVerifyCodeResp{
Code: 1,
Message: "验证码存储错误",
}, nil
}
//生成响应
return &pb.GetVerifyCodeResp{
Code: 0,
VerifyCode: reply.Code,
VerifyGenerateTime: time.Now().Unix(),
VerifyCodeLife: life,
}, nil
}

@ -36,15 +36,15 @@ components:
type: object
properties:
code:
type: integer
format: int32
type: string
message:
type: string
verifyCode:
type: string
verifyGenerateTime:
type: integer
format: int32
type: string
verifyCodeLife:
type: string
GoogleProtobufAny:
type: object
properties:

@ -0,0 +1,8 @@
services:
redis:
container_name: laomaDJRedis
image: redis
ports:
- "6379:6379"
volumes:
- ./data/redis:/data
Loading…
Cancel
Save