diff --git a/cmd/app.go b/cmd/app.go index 4f8e968..073bf00 100644 --- a/cmd/app.go +++ b/cmd/app.go @@ -1,10 +1,14 @@ package main import ( + "dubbo.apache.org/dubbo-go/v3/config" _ "dubbo.apache.org/dubbo-go/v3/filter/tps/strategy" _ "dubbo.apache.org/dubbo-go/v3/imports" + exhibitionConfig "exhibition-register/config" + "exhibition-register/internal/controller" _ "exhibition-register/internal/handler" "exhibition-register/pkg/app" + common "exhibition-register/pkg/init" "exhibition-register/pkg/tracing" "github.com/bwmarrin/snowflake" "go.uber.org/zap" @@ -20,29 +24,29 @@ func NewApp(Lg *zap.Logger, JaegerTracer *tracing.JaegerProvider, SfNode *snowfl } } -//func main() { -// var err error -// exhibitionConfig.GetOptions() -// app.ModuleClients, err = InitApp() -// if err != nil { -// panic(err) -// } -// -// //l, err := net.Listen("tcp", ":8883") -// //if err != nil { -// // fmt.Printf("failed to listen: %v", err) -// // return -// //} -// // -// //s := grpc.NewServer() // 创建gRPC服务器 -// //dci.RegisterDciServer(s, &controller.DciProvider{}) // 在gRPC服务端注册服务 -// // 启动服务 -// //err = s.Serve(l) -// //注册服务 -// config.SetProviderService(&controller.ExamProvider{}) -// common.Init() -// if err = config.Load(); err != nil { -// panic(err) -// } -// select {} -//} +func main() { + var err error + exhibitionConfig.GetOptions() + app.ModuleClients, err = InitApp() + if err != nil { + panic(err) + } + + //l, err := net.Listen("tcp", ":8883") + //if err != nil { + // fmt.Printf("failed to listen: %v", err) + // return + //} + // + //s := grpc.NewServer() // 创建gRPC服务器 + //dci.RegisterDciServer(s, &controller.DciProvider{}) // 在gRPC服务端注册服务 + // 启动服务 + //err = s.Serve(l) + //注册服务 + config.SetProviderService(&controller.ExhibitionProvider{}) + common.Init() + if err = config.Load(); err != nil { + panic(err) + } + select {} +} diff --git a/cmd/wire_gen.go b/cmd/wire_gen.go new file mode 100644 index 0000000..7d5ca1e --- /dev/null +++ b/cmd/wire_gen.go @@ -0,0 +1,32 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate go run github.com/google/wire/cmd/wire +//go:build !wireinject +// +build !wireinject + +package main + +import ( + "exhibition-register/pkg/app" + "exhibition-register/pkg/db" + "exhibition-register/pkg/logger" + "exhibition-register/pkg/snowf" + "exhibition-register/pkg/tracing" +) + +import ( + _ "dubbo.apache.org/dubbo-go/v3/filter/tps/strategy" + _ "dubbo.apache.org/dubbo-go/v3/imports" + _ "exhibition-register/internal/handler" +) + +// Injectors from wire.go: + +func InitApp() (*app.App, error) { + zapLogger := logger.ZapInit() + jaegerProvider := tracing.NewTracing() + node := snowf.NewSf() + gormDB := db.NewDB() + appApp := NewApp(zapLogger, jaegerProvider, node, gormDB) + return appApp, nil +} diff --git a/go.mod b/go.mod index c310fea..541a0a3 100644 --- a/go.mod +++ b/go.mod @@ -5,9 +5,13 @@ go 1.18 require ( dubbo.apache.org/dubbo-go/v3 v3.0.5 github.com/bwmarrin/snowflake v0.3.0 + github.com/dubbogo/grpc-go v1.42.10 + github.com/dubbogo/triple v1.2.2-rc2 github.com/gin-gonic/gin v1.9.1 github.com/go-redis/redis v6.15.9+incompatible + github.com/golang/protobuf v1.5.3 github.com/google/wire v0.5.0 + github.com/mwitkow/go-proto-validators v0.3.2 github.com/nacos-group/nacos-sdk-go v1.1.4 github.com/natefinch/lumberjack v2.0.0+incompatible github.com/opentracing/opentracing-go v1.2.0 @@ -15,6 +19,7 @@ require ( github.com/streadway/amqp v1.1.0 github.com/uber/jaeger-client-go v2.30.0+incompatible go.uber.org/zap v1.26.0 + google.golang.org/protobuf v1.31.0 gorm.io/driver/mysql v1.5.2 gorm.io/gorm v1.25.5 ) @@ -46,8 +51,6 @@ require ( github.com/dlclark/regexp2 v1.7.0 // indirect github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5 // indirect github.com/dubbogo/gost v1.13.2 // indirect - github.com/dubbogo/grpc-go v1.42.10 // indirect - github.com/dubbogo/triple v1.2.2-rc2 // indirect github.com/emicklei/go-restful/v3 v3.10.1 // indirect github.com/envoyproxy/go-control-plane v0.11.1 // indirect github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect @@ -70,7 +73,6 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect - github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/uuid v1.3.0 // indirect github.com/gorilla/websocket v1.4.2 // indirect @@ -149,7 +151,6 @@ require ( google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect google.golang.org/grpc v1.58.2 // indirect - google.golang.org/protobuf v1.31.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 9ffbe9c..9463b50 100644 --- a/go.sum +++ b/go.sum @@ -313,6 +313,7 @@ github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFG github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= @@ -640,6 +641,8 @@ github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM= github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-proto-validators v0.3.2 h1:qRlmpTzm2pstMKKzTdvwPCF5QfBNURSlAgN/R+qbKos= +github.com/mwitkow/go-proto-validators v0.3.2/go.mod h1:ej0Qp0qMgHN/KtDyUt+Q1/tA7a5VarXUOUxD+oeD30w= github.com/nacos-group/nacos-sdk-go v1.0.8/go.mod h1:hlAPn3UdzlxIlSILAyOXKxjFSvDJ9oLzTJ9hLAK1KzA= github.com/nacos-group/nacos-sdk-go v1.1.3/go.mod h1:cBv9wy5iObs7khOqov1ERFQrCuTR4ILpgaiaVMxEmGI= github.com/nacos-group/nacos-sdk-go v1.1.4 h1:qyrZ7HTWM4aeymFfqnbgNRERh7TWuER10pCB7ddRcTY= diff --git a/internal/controller/common.go b/internal/controller/common.go new file mode 100644 index 0000000..096aa03 --- /dev/null +++ b/internal/controller/common.go @@ -0,0 +1,11 @@ +package controller + +import ( + "exhibition-register/internal/logic" + "exhibition-register/pb/exhibition" +) + +type ExhibitionProvider struct { + exhibition.UnsafeExhibitionServer + registerLogic logic.Register +} diff --git a/internal/logic/register.go b/internal/logic/register.go deleted file mode 100644 index 4c79103..0000000 --- a/internal/logic/register.go +++ /dev/null @@ -1 +0,0 @@ -package logic diff --git a/internal/logic/register_logic.go b/internal/logic/register_logic.go new file mode 100644 index 0000000..a02b532 --- /dev/null +++ b/internal/logic/register_logic.go @@ -0,0 +1,7 @@ +package logic + +type IRegister interface { +} + +type Register struct { +} diff --git a/internal/model/register.go b/internal/model/register.go index 8b53790..434316f 100644 --- a/internal/model/register.go +++ b/internal/model/register.go @@ -1 +1,16 @@ package model + +import "gorm.io/gorm" + +type RegisterRecord struct { + gorm.Model + + UUID string `json:"uuid" gorm:"primaryKey;column:uuid;type:varchar(255);not null;comment:报名记录Uid"` + ArtistName string `json:"artist_name" gorm:"column:artist_name;type:varchar(255);not null;comment:画家姓名"` + Gender int32 `json:"gender" gorm:"column:gender;type:int;comment:性别1男2女"` + PhoneNum string `json:"phone_num" gorm:"column:phone_num;type:varchar(255);not null;comment:手机号"` + IdCard string `json:"id_card" gorm:"column:id_card;type:varchar(255);not null;comment:身份证号"` + Address string `json:"address" gorm:"column:address;type:varchar(2000);not null;comment:通讯地址"` + IdCardPhoto string `json:"id_card_photo" gorm:"column:id_card_photo;type:varchar(2000);not null;comment:身份证照片"` + ArtistPhoto string `json:"artist_photo" gorm:"column:artist_photo;type:varchar(2000);not null;comment:画家本人近照"` +} diff --git a/pb/exhibition.proto b/pb/exhibition.proto index 05f23f2..641e0b3 100644 --- a/pb/exhibition.proto +++ b/pb/exhibition.proto @@ -1,11 +1,39 @@ syntax = "proto3"; package exhibition; -option go_package = "./exhibition"; +option go_package = "./pb/exhibition"; -import "pb/descriptor.proto"; import "pb/validator.proto"; +import "pb/descriptor.proto"; service Exhibition { + rpc CheckPhone(RegisterInfo) returns (CheckPhoneResp); + rpc SaveRegisterRecord(RegisterInfo) returns (SaveRegisterRecordResp); +} + +message RegisterInfo{ + int32 id = 1; + string uuid = 2; + string artistName = 3; + int32 gender = 4; + string phoneNum = 5; + string idCard = 6; + string address = 7; + string idCardPhoto = 8; + string artistPhoto = 9; + string createdAt = 10; + string updatedAt = 11; + +} + +message SaveRegisterRecordResp{ + string msg = 1; + +} + +message CheckPhoneResp { + bool isExist = 1; + string msg = 2; + RegisterInfo data = 3; } \ No newline at end of file diff --git a/pb/exhibition/exhibition.pb.go b/pb/exhibition/exhibition.pb.go new file mode 100644 index 0000000..81a27aa --- /dev/null +++ b/pb/exhibition/exhibition.pb.go @@ -0,0 +1,405 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.21.1 +// source: pb/exhibition.proto + +package exhibition + +import ( + _ "github.com/mwitkow/go-proto-validators" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + _ "google.golang.org/protobuf/types/descriptorpb" + 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 RegisterInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Uuid string `protobuf:"bytes,2,opt,name=uuid,proto3" json:"uuid,omitempty"` + ArtistName string `protobuf:"bytes,3,opt,name=artistName,proto3" json:"artistName,omitempty"` + Gender int32 `protobuf:"varint,4,opt,name=gender,proto3" json:"gender,omitempty"` + PhoneNum string `protobuf:"bytes,5,opt,name=phoneNum,proto3" json:"phoneNum,omitempty"` + IdCard string `protobuf:"bytes,6,opt,name=idCard,proto3" json:"idCard,omitempty"` + Address string `protobuf:"bytes,7,opt,name=address,proto3" json:"address,omitempty"` + IdCardPhoto string `protobuf:"bytes,8,opt,name=idCardPhoto,proto3" json:"idCardPhoto,omitempty"` + ArtistPhoto string `protobuf:"bytes,9,opt,name=artistPhoto,proto3" json:"artistPhoto,omitempty"` + CreatedAt string `protobuf:"bytes,10,opt,name=createdAt,proto3" json:"createdAt,omitempty"` + UpdatedAt string `protobuf:"bytes,11,opt,name=updatedAt,proto3" json:"updatedAt,omitempty"` +} + +func (x *RegisterInfo) Reset() { + *x = RegisterInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_exhibition_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RegisterInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterInfo) ProtoMessage() {} + +func (x *RegisterInfo) ProtoReflect() protoreflect.Message { + mi := &file_pb_exhibition_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 RegisterInfo.ProtoReflect.Descriptor instead. +func (*RegisterInfo) Descriptor() ([]byte, []int) { + return file_pb_exhibition_proto_rawDescGZIP(), []int{0} +} + +func (x *RegisterInfo) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *RegisterInfo) GetUuid() string { + if x != nil { + return x.Uuid + } + return "" +} + +func (x *RegisterInfo) GetArtistName() string { + if x != nil { + return x.ArtistName + } + return "" +} + +func (x *RegisterInfo) GetGender() int32 { + if x != nil { + return x.Gender + } + return 0 +} + +func (x *RegisterInfo) GetPhoneNum() string { + if x != nil { + return x.PhoneNum + } + return "" +} + +func (x *RegisterInfo) GetIdCard() string { + if x != nil { + return x.IdCard + } + return "" +} + +func (x *RegisterInfo) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + +func (x *RegisterInfo) GetIdCardPhoto() string { + if x != nil { + return x.IdCardPhoto + } + return "" +} + +func (x *RegisterInfo) GetArtistPhoto() string { + if x != nil { + return x.ArtistPhoto + } + return "" +} + +func (x *RegisterInfo) GetCreatedAt() string { + if x != nil { + return x.CreatedAt + } + return "" +} + +func (x *RegisterInfo) GetUpdatedAt() string { + if x != nil { + return x.UpdatedAt + } + return "" +} + +type SaveRegisterRecordResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"` +} + +func (x *SaveRegisterRecordResp) Reset() { + *x = SaveRegisterRecordResp{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_exhibition_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SaveRegisterRecordResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SaveRegisterRecordResp) ProtoMessage() {} + +func (x *SaveRegisterRecordResp) ProtoReflect() protoreflect.Message { + mi := &file_pb_exhibition_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 SaveRegisterRecordResp.ProtoReflect.Descriptor instead. +func (*SaveRegisterRecordResp) Descriptor() ([]byte, []int) { + return file_pb_exhibition_proto_rawDescGZIP(), []int{1} +} + +func (x *SaveRegisterRecordResp) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +type CheckPhoneResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + IsExist bool `protobuf:"varint,1,opt,name=isExist,proto3" json:"isExist,omitempty"` + Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` + Data *RegisterInfo `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` +} + +func (x *CheckPhoneResp) Reset() { + *x = CheckPhoneResp{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_exhibition_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CheckPhoneResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CheckPhoneResp) ProtoMessage() {} + +func (x *CheckPhoneResp) ProtoReflect() protoreflect.Message { + mi := &file_pb_exhibition_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CheckPhoneResp.ProtoReflect.Descriptor instead. +func (*CheckPhoneResp) Descriptor() ([]byte, []int) { + return file_pb_exhibition_proto_rawDescGZIP(), []int{2} +} + +func (x *CheckPhoneResp) GetIsExist() bool { + if x != nil { + return x.IsExist + } + return false +} + +func (x *CheckPhoneResp) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +func (x *CheckPhoneResp) GetData() *RegisterInfo { + if x != nil { + return x.Data + } + return nil +} + +var File_pb_exhibition_proto protoreflect.FileDescriptor + +var file_pb_exhibition_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x70, 0x62, 0x2f, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x1a, 0x12, 0x70, 0x62, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x13, 0x70, 0x62, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb8, 0x02, 0x0a, 0x0c, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x75, + 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, + 0x1e, 0x0a, 0x0a, 0x61, 0x72, 0x74, 0x69, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x72, 0x74, 0x69, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, + 0x16, 0x0a, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65, + 0x4e, 0x75, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65, + 0x4e, 0x75, 0x6d, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x64, 0x43, 0x61, 0x72, 0x64, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x69, 0x64, 0x43, 0x61, 0x72, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x61, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x69, 0x64, 0x43, 0x61, 0x72, 0x64, 0x50, + 0x68, 0x6f, 0x74, 0x6f, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x69, 0x64, 0x43, 0x61, + 0x72, 0x64, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x12, 0x20, 0x0a, 0x0b, 0x61, 0x72, 0x74, 0x69, 0x73, + 0x74, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x72, + 0x74, 0x69, 0x73, 0x74, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x64, 0x41, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0x2a, 0x0a, 0x16, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, + 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, + 0x67, 0x22, 0x6a, 0x0a, 0x0e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x69, 0x73, 0x45, 0x78, 0x69, 0x73, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x45, 0x78, 0x69, 0x73, 0x74, 0x12, 0x10, 0x0a, + 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, + 0x2c, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, + 0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0xa4, 0x01, + 0x0a, 0x0a, 0x45, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x42, 0x0a, 0x0a, + 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x18, 0x2e, 0x65, 0x78, 0x68, + 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, + 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0x1a, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x12, 0x52, 0x0a, 0x12, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, + 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x18, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, + 0x1a, 0x22, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x61, + 0x76, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, + 0x52, 0x65, 0x73, 0x70, 0x42, 0x11, 0x5a, 0x0f, 0x2e, 0x2f, 0x70, 0x62, 0x2f, 0x65, 0x78, 0x68, + 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_pb_exhibition_proto_rawDescOnce sync.Once + file_pb_exhibition_proto_rawDescData = file_pb_exhibition_proto_rawDesc +) + +func file_pb_exhibition_proto_rawDescGZIP() []byte { + file_pb_exhibition_proto_rawDescOnce.Do(func() { + file_pb_exhibition_proto_rawDescData = protoimpl.X.CompressGZIP(file_pb_exhibition_proto_rawDescData) + }) + return file_pb_exhibition_proto_rawDescData +} + +var file_pb_exhibition_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_pb_exhibition_proto_goTypes = []interface{}{ + (*RegisterInfo)(nil), // 0: exhibition.RegisterInfo + (*SaveRegisterRecordResp)(nil), // 1: exhibition.SaveRegisterRecordResp + (*CheckPhoneResp)(nil), // 2: exhibition.CheckPhoneResp +} +var file_pb_exhibition_proto_depIdxs = []int32{ + 0, // 0: exhibition.CheckPhoneResp.data:type_name -> exhibition.RegisterInfo + 0, // 1: exhibition.Exhibition.CheckPhone:input_type -> exhibition.RegisterInfo + 0, // 2: exhibition.Exhibition.SaveRegisterRecord:input_type -> exhibition.RegisterInfo + 2, // 3: exhibition.Exhibition.CheckPhone:output_type -> exhibition.CheckPhoneResp + 1, // 4: exhibition.Exhibition.SaveRegisterRecord:output_type -> exhibition.SaveRegisterRecordResp + 3, // [3:5] is the sub-list for method output_type + 1, // [1:3] 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_pb_exhibition_proto_init() } +func file_pb_exhibition_proto_init() { + if File_pb_exhibition_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_pb_exhibition_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RegisterInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pb_exhibition_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SaveRegisterRecordResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pb_exhibition_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CheckPhoneResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_pb_exhibition_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_pb_exhibition_proto_goTypes, + DependencyIndexes: file_pb_exhibition_proto_depIdxs, + MessageInfos: file_pb_exhibition_proto_msgTypes, + }.Build() + File_pb_exhibition_proto = out.File + file_pb_exhibition_proto_rawDesc = nil + file_pb_exhibition_proto_goTypes = nil + file_pb_exhibition_proto_depIdxs = nil +} diff --git a/pb/exhibition/exhibition.validator.pb.go b/pb/exhibition/exhibition.validator.pb.go new file mode 100644 index 0000000..a28dcf5 --- /dev/null +++ b/pb/exhibition/exhibition.validator.pb.go @@ -0,0 +1,33 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: pb/exhibition.proto + +package exhibition + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + _ "github.com/mwitkow/go-proto-validators" + github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators" + _ "google.golang.org/protobuf/types/descriptorpb" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +func (this *RegisterInfo) Validate() error { + return nil +} +func (this *SaveRegisterRecordResp) Validate() error { + return nil +} +func (this *CheckPhoneResp) Validate() error { + if this.Data != nil { + if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Data); err != nil { + return github_com_mwitkow_go_proto_validators.FieldError("Data", err) + } + } + return nil +} diff --git a/pb/exhibition/exhibition_triple.pb.go b/pb/exhibition/exhibition_triple.pb.go new file mode 100644 index 0000000..038374e --- /dev/null +++ b/pb/exhibition/exhibition_triple.pb.go @@ -0,0 +1,192 @@ +// Code generated by protoc-gen-go-triple. DO NOT EDIT. +// versions: +// - protoc-gen-go-triple v1.0.5 +// - protoc v3.21.1 +// source: pb/exhibition.proto + +package exhibition + +import ( + context "context" + protocol "dubbo.apache.org/dubbo-go/v3/protocol" + dubbo3 "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3" + invocation "dubbo.apache.org/dubbo-go/v3/protocol/invocation" + grpc_go "github.com/dubbogo/grpc-go" + codes "github.com/dubbogo/grpc-go/codes" + metadata "github.com/dubbogo/grpc-go/metadata" + status "github.com/dubbogo/grpc-go/status" + common "github.com/dubbogo/triple/pkg/common" + constant "github.com/dubbogo/triple/pkg/common/constant" + triple "github.com/dubbogo/triple/pkg/triple" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc_go.SupportPackageIsVersion7 + +// ExhibitionClient is the client API for Exhibition 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 ExhibitionClient interface { + CheckPhone(ctx context.Context, in *RegisterInfo, opts ...grpc_go.CallOption) (*CheckPhoneResp, common.ErrorWithAttachment) + SaveRegisterRecord(ctx context.Context, in *RegisterInfo, opts ...grpc_go.CallOption) (*SaveRegisterRecordResp, common.ErrorWithAttachment) +} + +type exhibitionClient struct { + cc *triple.TripleConn +} + +type ExhibitionClientImpl struct { + CheckPhone func(ctx context.Context, in *RegisterInfo) (*CheckPhoneResp, error) + SaveRegisterRecord func(ctx context.Context, in *RegisterInfo) (*SaveRegisterRecordResp, error) +} + +func (c *ExhibitionClientImpl) GetDubboStub(cc *triple.TripleConn) ExhibitionClient { + return NewExhibitionClient(cc) +} + +func (c *ExhibitionClientImpl) XXX_InterfaceName() string { + return "exhibition.Exhibition" +} + +func NewExhibitionClient(cc *triple.TripleConn) ExhibitionClient { + return &exhibitionClient{cc} +} + +func (c *exhibitionClient) CheckPhone(ctx context.Context, in *RegisterInfo, opts ...grpc_go.CallOption) (*CheckPhoneResp, common.ErrorWithAttachment) { + out := new(CheckPhoneResp) + interfaceKey := ctx.Value(constant.InterfaceKey).(string) + return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/CheckPhone", in, out) +} + +func (c *exhibitionClient) SaveRegisterRecord(ctx context.Context, in *RegisterInfo, opts ...grpc_go.CallOption) (*SaveRegisterRecordResp, common.ErrorWithAttachment) { + out := new(SaveRegisterRecordResp) + interfaceKey := ctx.Value(constant.InterfaceKey).(string) + return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/SaveRegisterRecord", in, out) +} + +// ExhibitionServer is the server API for Exhibition service. +// All implementations must embed UnimplementedExhibitionServer +// for forward compatibility +type ExhibitionServer interface { + CheckPhone(context.Context, *RegisterInfo) (*CheckPhoneResp, error) + SaveRegisterRecord(context.Context, *RegisterInfo) (*SaveRegisterRecordResp, error) + mustEmbedUnimplementedExhibitionServer() +} + +// UnimplementedExhibitionServer must be embedded to have forward compatible implementations. +type UnimplementedExhibitionServer struct { + proxyImpl protocol.Invoker +} + +func (UnimplementedExhibitionServer) CheckPhone(context.Context, *RegisterInfo) (*CheckPhoneResp, error) { + return nil, status.Errorf(codes.Unimplemented, "method CheckPhone not implemented") +} +func (UnimplementedExhibitionServer) SaveRegisterRecord(context.Context, *RegisterInfo) (*SaveRegisterRecordResp, error) { + return nil, status.Errorf(codes.Unimplemented, "method SaveRegisterRecord not implemented") +} +func (s *UnimplementedExhibitionServer) XXX_SetProxyImpl(impl protocol.Invoker) { + s.proxyImpl = impl +} + +func (s *UnimplementedExhibitionServer) XXX_GetProxyImpl() protocol.Invoker { + return s.proxyImpl +} + +func (s *UnimplementedExhibitionServer) XXX_ServiceDesc() *grpc_go.ServiceDesc { + return &Exhibition_ServiceDesc +} +func (s *UnimplementedExhibitionServer) XXX_InterfaceName() string { + return "exhibition.Exhibition" +} + +func (UnimplementedExhibitionServer) mustEmbedUnimplementedExhibitionServer() {} + +// UnsafeExhibitionServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ExhibitionServer will +// result in compilation errors. +type UnsafeExhibitionServer interface { + mustEmbedUnimplementedExhibitionServer() +} + +func RegisterExhibitionServer(s grpc_go.ServiceRegistrar, srv ExhibitionServer) { + s.RegisterService(&Exhibition_ServiceDesc, srv) +} + +func _Exhibition_CheckPhone_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { + in := new(RegisterInfo) + if err := dec(in); err != nil { + return nil, err + } + base := srv.(dubbo3.Dubbo3GrpcService) + args := []interface{}{} + args = append(args, in) + md, _ := metadata.FromIncomingContext(ctx) + invAttachment := make(map[string]interface{}, len(md)) + for k, v := range md { + invAttachment[k] = v + } + invo := invocation.NewRPCInvocation("CheckPhone", args, invAttachment) + if interceptor == nil { + result := base.XXX_GetProxyImpl().Invoke(ctx, invo) + return result, result.Error() + } + info := &grpc_go.UnaryServerInfo{ + Server: srv, + FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string), + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + result := base.XXX_GetProxyImpl().Invoke(ctx, invo) + return result, result.Error() + } + return interceptor(ctx, in, info, handler) +} + +func _Exhibition_SaveRegisterRecord_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { + in := new(RegisterInfo) + if err := dec(in); err != nil { + return nil, err + } + base := srv.(dubbo3.Dubbo3GrpcService) + args := []interface{}{} + args = append(args, in) + md, _ := metadata.FromIncomingContext(ctx) + invAttachment := make(map[string]interface{}, len(md)) + for k, v := range md { + invAttachment[k] = v + } + invo := invocation.NewRPCInvocation("SaveRegisterRecord", args, invAttachment) + if interceptor == nil { + result := base.XXX_GetProxyImpl().Invoke(ctx, invo) + return result, result.Error() + } + info := &grpc_go.UnaryServerInfo{ + Server: srv, + FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string), + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + result := base.XXX_GetProxyImpl().Invoke(ctx, invo) + return result, result.Error() + } + return interceptor(ctx, in, info, handler) +} + +// Exhibition_ServiceDesc is the grpc_go.ServiceDesc for Exhibition service. +// It's only intended for direct use with grpc_go.RegisterService, +// and not to be introspected or modified (even as a copy) +var Exhibition_ServiceDesc = grpc_go.ServiceDesc{ + ServiceName: "exhibition.Exhibition", + HandlerType: (*ExhibitionServer)(nil), + Methods: []grpc_go.MethodDesc{ + { + MethodName: "CheckPhone", + Handler: _Exhibition_CheckPhone_Handler, + }, + { + MethodName: "SaveRegisterRecord", + Handler: _Exhibition_SaveRegisterRecord_Handler, + }, + }, + Streams: []grpc_go.StreamDesc{}, + Metadata: "pb/exhibition.proto", +} diff --git a/pkg/db/mysql.go b/pkg/db/mysql.go index 2abadd8..f8f6837 100644 --- a/pkg/db/mysql.go +++ b/pkg/db/mysql.go @@ -1,6 +1,7 @@ package db import ( + "exhibition-register/internal/model" "github.com/gin-gonic/gin" "gorm.io/driver/mysql" "gorm.io/gorm" @@ -37,7 +38,7 @@ func loadMysqlConn(conn string) *gorm.DB { sqlDB.SetMaxIdleConns(20) //设置连接池,空闲 sqlDB.SetMaxOpenConns(100) //打开 sqlDB.SetConnMaxLifetime(time.Second * 30) - err = db.AutoMigrate() //自迁移 + err = db.AutoMigrate(model.RegisterRecord{}) //自迁移 if err != nil { return nil