From b5a8e87c4b9507af13e9bb5dadcd1653cb93c330 Mon Sep 17 00:00:00 2001 From: "jiaji.H" Date: Thu, 25 Sep 2025 16:10:58 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=A2=9E=E5=8A=A0=E9=82=AE?= =?UTF-8?q?=E4=BB=B6=E9=80=9A=E7=9F=A5=E6=A8=A1=E5=9D=97=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/emailAlerts/emailAlerts.pb.go | 644 ++++++++++++++++++++ api/emailAlerts/emailAlerts.proto | 43 +- api/emailAlerts/emailAlerts.validator.pb.go | 47 ++ api/emailAlerts/emailAlerts_triple.pb.go | 194 ++++++ clear.sh | 2 +- cmd/app.go | 1 + internel/controller/emailAlerts.go | 19 + internel/dao/emailAlerts.go | 48 ++ internel/logic/emailAlerts.go | 53 ++ internel/model/emailAlerts.go | 24 + pkg/db/db.go | 1 + protocEmailAlerts.bat | 3 + 12 files changed, 1072 insertions(+), 7 deletions(-) create mode 100644 api/emailAlerts/emailAlerts.pb.go create mode 100644 api/emailAlerts/emailAlerts.validator.pb.go create mode 100644 api/emailAlerts/emailAlerts_triple.pb.go create mode 100644 internel/controller/emailAlerts.go create mode 100644 internel/dao/emailAlerts.go create mode 100644 internel/logic/emailAlerts.go create mode 100644 internel/model/emailAlerts.go create mode 100644 protocEmailAlerts.bat diff --git a/api/emailAlerts/emailAlerts.pb.go b/api/emailAlerts/emailAlerts.pb.go new file mode 100644 index 0000000..8fccfe3 --- /dev/null +++ b/api/emailAlerts/emailAlerts.pb.go @@ -0,0 +1,644 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v5.26.0 +// source: api/emailAlerts/emailAlerts.proto + +package emailAlerts + +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 EmailAlertsSubmitReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FirstName string `protobuf:"bytes,1,opt,name=firstName,proto3" json:"firstName"` + LastName string `protobuf:"bytes,2,opt,name=lastName,proto3" json:"lastName"` + Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email"` + Company string `protobuf:"bytes,4,opt,name=company,proto3" json:"company"` + Phone string `protobuf:"bytes,5,opt,name=phone,proto3" json:"phone"` +} + +func (x *EmailAlertsSubmitReq) Reset() { + *x = EmailAlertsSubmitReq{} + if protoimpl.UnsafeEnabled { + mi := &file_api_emailAlerts_emailAlerts_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EmailAlertsSubmitReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EmailAlertsSubmitReq) ProtoMessage() {} + +func (x *EmailAlertsSubmitReq) ProtoReflect() protoreflect.Message { + mi := &file_api_emailAlerts_emailAlerts_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 EmailAlertsSubmitReq.ProtoReflect.Descriptor instead. +func (*EmailAlertsSubmitReq) Descriptor() ([]byte, []int) { + return file_api_emailAlerts_emailAlerts_proto_rawDescGZIP(), []int{0} +} + +func (x *EmailAlertsSubmitReq) GetFirstName() string { + if x != nil { + return x.FirstName + } + return "" +} + +func (x *EmailAlertsSubmitReq) GetLastName() string { + if x != nil { + return x.LastName + } + return "" +} + +func (x *EmailAlertsSubmitReq) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +func (x *EmailAlertsSubmitReq) GetCompany() string { + if x != nil { + return x.Company + } + return "" +} + +func (x *EmailAlertsSubmitReq) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +type EmailAlertsSubmitResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg"` +} + +func (x *EmailAlertsSubmitResp) Reset() { + *x = EmailAlertsSubmitResp{} + if protoimpl.UnsafeEnabled { + mi := &file_api_emailAlerts_emailAlerts_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EmailAlertsSubmitResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EmailAlertsSubmitResp) ProtoMessage() {} + +func (x *EmailAlertsSubmitResp) ProtoReflect() protoreflect.Message { + mi := &file_api_emailAlerts_emailAlerts_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 EmailAlertsSubmitResp.ProtoReflect.Descriptor instead. +func (*EmailAlertsSubmitResp) Descriptor() ([]byte, []int) { + return file_api_emailAlerts_emailAlerts_proto_rawDescGZIP(), []int{1} +} + +func (x *EmailAlertsSubmitResp) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +// ========================= EmailInformatio ============================== +type Filtrate struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name"` + Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email"` + Company string `protobuf:"bytes,3,opt,name=company,proto3" json:"company"` +} + +func (x *Filtrate) Reset() { + *x = Filtrate{} + if protoimpl.UnsafeEnabled { + mi := &file_api_emailAlerts_emailAlerts_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Filtrate) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Filtrate) ProtoMessage() {} + +func (x *Filtrate) ProtoReflect() protoreflect.Message { + mi := &file_api_emailAlerts_emailAlerts_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 Filtrate.ProtoReflect.Descriptor instead. +func (*Filtrate) Descriptor() ([]byte, []int) { + return file_api_emailAlerts_emailAlerts_proto_rawDescGZIP(), []int{2} +} + +func (x *Filtrate) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Filtrate) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +func (x *Filtrate) GetCompany() string { + if x != nil { + return x.Company + } + return "" +} + +type GetEmailInformationListReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Page int32 `protobuf:"varint,1,opt,name=page,proto3" json:"page"` + PageSize int32 `protobuf:"varint,2,opt,name=pageSize,proto3" json:"pageSize"` + Filtrate *Filtrate `protobuf:"bytes,3,opt,name=filtrate,proto3" json:"filtrate"` +} + +func (x *GetEmailInformationListReq) Reset() { + *x = GetEmailInformationListReq{} + if protoimpl.UnsafeEnabled { + mi := &file_api_emailAlerts_emailAlerts_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetEmailInformationListReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetEmailInformationListReq) ProtoMessage() {} + +func (x *GetEmailInformationListReq) ProtoReflect() protoreflect.Message { + mi := &file_api_emailAlerts_emailAlerts_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetEmailInformationListReq.ProtoReflect.Descriptor instead. +func (*GetEmailInformationListReq) Descriptor() ([]byte, []int) { + return file_api_emailAlerts_emailAlerts_proto_rawDescGZIP(), []int{3} +} + +func (x *GetEmailInformationListReq) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *GetEmailInformationListReq) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *GetEmailInformationListReq) GetFiltrate() *Filtrate { + if x != nil { + return x.Filtrate + } + return nil +} + +type GetEmailInformationListResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg"` + Page int32 `protobuf:"varint,2,opt,name=page,proto3" json:"page"` + PageSize int32 `protobuf:"varint,3,opt,name=pageSize,proto3" json:"pageSize"` + Total int32 `protobuf:"varint,4,opt,name=total,proto3" json:"total"` + Data []*EmailInformation `protobuf:"bytes,5,rep,name=data,proto3" json:"data"` +} + +func (x *GetEmailInformationListResp) Reset() { + *x = GetEmailInformationListResp{} + if protoimpl.UnsafeEnabled { + mi := &file_api_emailAlerts_emailAlerts_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetEmailInformationListResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetEmailInformationListResp) ProtoMessage() {} + +func (x *GetEmailInformationListResp) ProtoReflect() protoreflect.Message { + mi := &file_api_emailAlerts_emailAlerts_proto_msgTypes[4] + 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 GetEmailInformationListResp.ProtoReflect.Descriptor instead. +func (*GetEmailInformationListResp) Descriptor() ([]byte, []int) { + return file_api_emailAlerts_emailAlerts_proto_rawDescGZIP(), []int{4} +} + +func (x *GetEmailInformationListResp) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +func (x *GetEmailInformationListResp) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *GetEmailInformationListResp) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *GetEmailInformationListResp) GetTotal() int32 { + if x != nil { + return x.Total + } + return 0 +} + +func (x *GetEmailInformationListResp) GetData() []*EmailInformation { + if x != nil { + return x.Data + } + return nil +} + +type EmailInformation struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id"` + FullName string `protobuf:"bytes,2,opt,name=fullName,proto3" json:"fullName"` + Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email"` + Company string `protobuf:"bytes,4,opt,name=company,proto3" json:"company"` + Phone string `protobuf:"bytes,5,opt,name=phone,proto3" json:"phone"` + CreatedAt string `protobuf:"bytes,6,opt,name=createdAt,proto3" json:"createdAt"` +} + +func (x *EmailInformation) Reset() { + *x = EmailInformation{} + if protoimpl.UnsafeEnabled { + mi := &file_api_emailAlerts_emailAlerts_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EmailInformation) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EmailInformation) ProtoMessage() {} + +func (x *EmailInformation) ProtoReflect() protoreflect.Message { + mi := &file_api_emailAlerts_emailAlerts_proto_msgTypes[5] + 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 EmailInformation.ProtoReflect.Descriptor instead. +func (*EmailInformation) Descriptor() ([]byte, []int) { + return file_api_emailAlerts_emailAlerts_proto_rawDescGZIP(), []int{5} +} + +func (x *EmailInformation) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *EmailInformation) GetFullName() string { + if x != nil { + return x.FullName + } + return "" +} + +func (x *EmailInformation) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +func (x *EmailInformation) GetCompany() string { + if x != nil { + return x.Company + } + return "" +} + +func (x *EmailInformation) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +func (x *EmailInformation) GetCreatedAt() string { + if x != nil { + return x.CreatedAt + } + return "" +} + +var File_api_emailAlerts_emailAlerts_proto protoreflect.FileDescriptor + +var file_api_emailAlerts_emailAlerts_proto_rawDesc = []byte{ + 0x0a, 0x21, 0x61, 0x70, 0x69, 0x2f, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x41, 0x6c, 0x65, 0x72, 0x74, + 0x73, 0x2f, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x73, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x73, + 0x22, 0x96, 0x01, 0x0a, 0x14, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x73, + 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x66, 0x69, 0x72, + 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x66, 0x69, + 0x72, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x61, 0x73, 0x74, 0x4e, + 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x61, 0x73, 0x74, 0x4e, + 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, + 0x70, 0x61, 0x6e, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x70, + 0x61, 0x6e, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x22, 0x29, 0x0a, 0x15, 0x45, 0x6d, 0x61, + 0x69, 0x6c, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x73, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x6d, 0x73, 0x67, 0x22, 0x4e, 0x0a, 0x08, 0x46, 0x69, 0x6c, 0x74, 0x72, 0x61, 0x74, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, + 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, + 0x70, 0x61, 0x6e, 0x79, 0x22, 0x7f, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x45, 0x6d, 0x61, 0x69, 0x6c, + 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x73, 0x74, 0x52, + 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, + 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, + 0x7a, 0x65, 0x12, 0x31, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x74, 0x72, 0x61, 0x74, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x41, 0x6c, 0x65, 0x72, + 0x74, 0x73, 0x2e, 0x46, 0x69, 0x6c, 0x74, 0x72, 0x61, 0x74, 0x65, 0x52, 0x08, 0x66, 0x69, 0x6c, + 0x74, 0x72, 0x61, 0x74, 0x65, 0x22, 0xa8, 0x01, 0x0a, 0x1b, 0x47, 0x65, 0x74, 0x45, 0x6d, 0x61, + 0x69, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x73, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x67, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, + 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, + 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x12, 0x31, 0x0a, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x65, 0x6d, + 0x61, 0x69, 0x6c, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x73, 0x2e, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x49, + 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, + 0x22, 0xa2, 0x01, 0x0a, 0x10, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x75, 0x6c, 0x6c, 0x4e, 0x61, 0x6d, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x75, 0x6c, 0x6c, 0x4e, 0x61, 0x6d, + 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x70, 0x61, + 0x6e, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, + 0x79, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x64, 0x41, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x64, 0x41, 0x74, 0x32, 0xd7, 0x01, 0x0a, 0x0b, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x41, + 0x6c, 0x65, 0x72, 0x74, 0x73, 0x12, 0x5a, 0x0a, 0x11, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x41, 0x6c, + 0x65, 0x72, 0x74, 0x73, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x12, 0x21, 0x2e, 0x65, 0x6d, 0x61, + 0x69, 0x6c, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x73, 0x2e, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x41, 0x6c, + 0x65, 0x72, 0x74, 0x73, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x22, 0x2e, + 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x73, 0x2e, 0x45, 0x6d, 0x61, 0x69, + 0x6c, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x73, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x12, 0x6c, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x49, 0x6e, 0x66, + 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x27, 0x2e, 0x65, + 0x6d, 0x61, 0x69, 0x6c, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x73, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x6d, + 0x61, 0x69, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, + 0x73, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x28, 0x2e, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x41, 0x6c, 0x65, + 0x72, 0x74, 0x73, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x49, 0x6e, 0x66, 0x6f, + 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x42, + 0x10, 0x5a, 0x0e, 0x2e, 0x2f, 0x3b, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x41, 0x6c, 0x65, 0x72, 0x74, + 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_api_emailAlerts_emailAlerts_proto_rawDescOnce sync.Once + file_api_emailAlerts_emailAlerts_proto_rawDescData = file_api_emailAlerts_emailAlerts_proto_rawDesc +) + +func file_api_emailAlerts_emailAlerts_proto_rawDescGZIP() []byte { + file_api_emailAlerts_emailAlerts_proto_rawDescOnce.Do(func() { + file_api_emailAlerts_emailAlerts_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_emailAlerts_emailAlerts_proto_rawDescData) + }) + return file_api_emailAlerts_emailAlerts_proto_rawDescData +} + +var file_api_emailAlerts_emailAlerts_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_api_emailAlerts_emailAlerts_proto_goTypes = []interface{}{ + (*EmailAlertsSubmitReq)(nil), // 0: emailAlerts.EmailAlertsSubmitReq + (*EmailAlertsSubmitResp)(nil), // 1: emailAlerts.EmailAlertsSubmitResp + (*Filtrate)(nil), // 2: emailAlerts.Filtrate + (*GetEmailInformationListReq)(nil), // 3: emailAlerts.GetEmailInformationListReq + (*GetEmailInformationListResp)(nil), // 4: emailAlerts.GetEmailInformationListResp + (*EmailInformation)(nil), // 5: emailAlerts.EmailInformation +} +var file_api_emailAlerts_emailAlerts_proto_depIdxs = []int32{ + 2, // 0: emailAlerts.GetEmailInformationListReq.filtrate:type_name -> emailAlerts.Filtrate + 5, // 1: emailAlerts.GetEmailInformationListResp.data:type_name -> emailAlerts.EmailInformation + 0, // 2: emailAlerts.EmailAlerts.EmailAlertsSubmit:input_type -> emailAlerts.EmailAlertsSubmitReq + 3, // 3: emailAlerts.EmailAlerts.GetEmailInformationList:input_type -> emailAlerts.GetEmailInformationListReq + 1, // 4: emailAlerts.EmailAlerts.EmailAlertsSubmit:output_type -> emailAlerts.EmailAlertsSubmitResp + 4, // 5: emailAlerts.EmailAlerts.GetEmailInformationList:output_type -> emailAlerts.GetEmailInformationListResp + 4, // [4:6] is the sub-list for method output_type + 2, // [2:4] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_api_emailAlerts_emailAlerts_proto_init() } +func file_api_emailAlerts_emailAlerts_proto_init() { + if File_api_emailAlerts_emailAlerts_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_api_emailAlerts_emailAlerts_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EmailAlertsSubmitReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_emailAlerts_emailAlerts_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EmailAlertsSubmitResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_emailAlerts_emailAlerts_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Filtrate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_emailAlerts_emailAlerts_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetEmailInformationListReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_emailAlerts_emailAlerts_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetEmailInformationListResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_emailAlerts_emailAlerts_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EmailInformation); 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_api_emailAlerts_emailAlerts_proto_rawDesc, + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_api_emailAlerts_emailAlerts_proto_goTypes, + DependencyIndexes: file_api_emailAlerts_emailAlerts_proto_depIdxs, + MessageInfos: file_api_emailAlerts_emailAlerts_proto_msgTypes, + }.Build() + File_api_emailAlerts_emailAlerts_proto = out.File + file_api_emailAlerts_emailAlerts_proto_rawDesc = nil + file_api_emailAlerts_emailAlerts_proto_goTypes = nil + file_api_emailAlerts_emailAlerts_proto_depIdxs = nil +} diff --git a/api/emailAlerts/emailAlerts.proto b/api/emailAlerts/emailAlerts.proto index cc51240..50957df 100644 --- a/api/emailAlerts/emailAlerts.proto +++ b/api/emailAlerts/emailAlerts.proto @@ -7,17 +7,48 @@ option go_package = "./;emailAlerts"; service EmailAlerts{ rpc EmailAlertsSubmit(EmailAlertsSubmitReq) returns (EmailAlertsSubmitResp); + //========================= EmailInformatio ============================== + rpc GetEmailInformationList(GetEmailInformationListReq) returns (GetEmailInformationListResp); } message EmailAlertsSubmitReq{ - string uuid = 2; - string firstName = 3; - string lastName = 4; - string email = 5; - string company = 6; - string phone = 7; + string firstName = 1; + string lastName = 2; + string email = 3; + string company = 4; + string phone = 5; } message EmailAlertsSubmitResp{ string msg = 1; } + +//========================= EmailInformatio ============================== +message Filtrate{ + string name = 1; + string email = 2; + string company = 3; +} + +message GetEmailInformationListReq{ + int32 page = 1; + int32 pageSize = 2; + Filtrate filtrate = 3; +} + +message GetEmailInformationListResp{ + string msg = 1; + int32 page=2; + int32 pageSize =3; + int32 total = 4; + repeated EmailInformation data = 5; +} + +message EmailInformation{ + int32 id = 1; + string fullName = 2; + string email = 3; + string company = 4; + string phone = 5; + string createdAt = 6; +} \ No newline at end of file diff --git a/api/emailAlerts/emailAlerts.validator.pb.go b/api/emailAlerts/emailAlerts.validator.pb.go new file mode 100644 index 0000000..4f738bf --- /dev/null +++ b/api/emailAlerts/emailAlerts.validator.pb.go @@ -0,0 +1,47 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: api/emailAlerts/emailAlerts.proto + +package emailAlerts + +import ( + fmt "fmt" + math "math" + proto "github.com/golang/protobuf/proto" + github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +func (this *EmailAlertsSubmitReq) Validate() error { + return nil +} +func (this *EmailAlertsSubmitResp) Validate() error { + return nil +} +func (this *Filtrate) Validate() error { + return nil +} +func (this *GetEmailInformationListReq) Validate() error { + if this.Filtrate != nil { + if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Filtrate); err != nil { + return github_com_mwitkow_go_proto_validators.FieldError("Filtrate", err) + } + } + return nil +} +func (this *GetEmailInformationListResp) Validate() error { + for _, item := range this.Data { + if item != nil { + if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil { + return github_com_mwitkow_go_proto_validators.FieldError("Data", err) + } + } + } + return nil +} +func (this *EmailInformation) Validate() error { + return nil +} diff --git a/api/emailAlerts/emailAlerts_triple.pb.go b/api/emailAlerts/emailAlerts_triple.pb.go new file mode 100644 index 0000000..03b8eb9 --- /dev/null +++ b/api/emailAlerts/emailAlerts_triple.pb.go @@ -0,0 +1,194 @@ +// Code generated by protoc-gen-go-triple. DO NOT EDIT. +// versions: +// - protoc-gen-go-triple v1.0.5 +// - protoc v5.26.0 +// source: api/emailAlerts/emailAlerts.proto + +package emailAlerts + +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 + +// EmailAlertsClient is the client API for EmailAlerts 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 EmailAlertsClient interface { + EmailAlertsSubmit(ctx context.Context, in *EmailAlertsSubmitReq, opts ...grpc_go.CallOption) (*EmailAlertsSubmitResp, common.ErrorWithAttachment) + // ========================= EmailInformatio ============================== + GetEmailInformationList(ctx context.Context, in *GetEmailInformationListReq, opts ...grpc_go.CallOption) (*GetEmailInformationListResp, common.ErrorWithAttachment) +} + +type emailAlertsClient struct { + cc *triple.TripleConn +} + +type EmailAlertsClientImpl struct { + EmailAlertsSubmit func(ctx context.Context, in *EmailAlertsSubmitReq) (*EmailAlertsSubmitResp, error) + GetEmailInformationList func(ctx context.Context, in *GetEmailInformationListReq) (*GetEmailInformationListResp, error) +} + +func (c *EmailAlertsClientImpl) GetDubboStub(cc *triple.TripleConn) EmailAlertsClient { + return NewEmailAlertsClient(cc) +} + +func (c *EmailAlertsClientImpl) XXX_InterfaceName() string { + return "emailAlerts.EmailAlerts" +} + +func NewEmailAlertsClient(cc *triple.TripleConn) EmailAlertsClient { + return &emailAlertsClient{cc} +} + +func (c *emailAlertsClient) EmailAlertsSubmit(ctx context.Context, in *EmailAlertsSubmitReq, opts ...grpc_go.CallOption) (*EmailAlertsSubmitResp, common.ErrorWithAttachment) { + out := new(EmailAlertsSubmitResp) + interfaceKey := ctx.Value(constant.InterfaceKey).(string) + return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/EmailAlertsSubmit", in, out) +} + +func (c *emailAlertsClient) GetEmailInformationList(ctx context.Context, in *GetEmailInformationListReq, opts ...grpc_go.CallOption) (*GetEmailInformationListResp, common.ErrorWithAttachment) { + out := new(GetEmailInformationListResp) + interfaceKey := ctx.Value(constant.InterfaceKey).(string) + return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/GetEmailInformationList", in, out) +} + +// EmailAlertsServer is the server API for EmailAlerts service. +// All implementations must embed UnimplementedEmailAlertsServer +// for forward compatibility +type EmailAlertsServer interface { + EmailAlertsSubmit(context.Context, *EmailAlertsSubmitReq) (*EmailAlertsSubmitResp, error) + // ========================= EmailInformatio ============================== + GetEmailInformationList(context.Context, *GetEmailInformationListReq) (*GetEmailInformationListResp, error) + mustEmbedUnimplementedEmailAlertsServer() +} + +// UnimplementedEmailAlertsServer must be embedded to have forward compatible implementations. +type UnimplementedEmailAlertsServer struct { + proxyImpl protocol.Invoker +} + +func (UnimplementedEmailAlertsServer) EmailAlertsSubmit(context.Context, *EmailAlertsSubmitReq) (*EmailAlertsSubmitResp, error) { + return nil, status.Errorf(codes.Unimplemented, "method EmailAlertsSubmit not implemented") +} +func (UnimplementedEmailAlertsServer) GetEmailInformationList(context.Context, *GetEmailInformationListReq) (*GetEmailInformationListResp, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetEmailInformationList not implemented") +} +func (s *UnimplementedEmailAlertsServer) XXX_SetProxyImpl(impl protocol.Invoker) { + s.proxyImpl = impl +} + +func (s *UnimplementedEmailAlertsServer) XXX_GetProxyImpl() protocol.Invoker { + return s.proxyImpl +} + +func (s *UnimplementedEmailAlertsServer) XXX_ServiceDesc() *grpc_go.ServiceDesc { + return &EmailAlerts_ServiceDesc +} +func (s *UnimplementedEmailAlertsServer) XXX_InterfaceName() string { + return "emailAlerts.EmailAlerts" +} + +func (UnimplementedEmailAlertsServer) mustEmbedUnimplementedEmailAlertsServer() {} + +// UnsafeEmailAlertsServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to EmailAlertsServer will +// result in compilation errors. +type UnsafeEmailAlertsServer interface { + mustEmbedUnimplementedEmailAlertsServer() +} + +func RegisterEmailAlertsServer(s grpc_go.ServiceRegistrar, srv EmailAlertsServer) { + s.RegisterService(&EmailAlerts_ServiceDesc, srv) +} + +func _EmailAlerts_EmailAlertsSubmit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { + in := new(EmailAlertsSubmitReq) + 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("EmailAlertsSubmit", 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 _EmailAlerts_GetEmailInformationList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { + in := new(GetEmailInformationListReq) + 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("GetEmailInformationList", 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) +} + +// EmailAlerts_ServiceDesc is the grpc_go.ServiceDesc for EmailAlerts service. +// It's only intended for direct use with grpc_go.RegisterService, +// and not to be introspected or modified (even as a copy) +var EmailAlerts_ServiceDesc = grpc_go.ServiceDesc{ + ServiceName: "emailAlerts.EmailAlerts", + HandlerType: (*EmailAlertsServer)(nil), + Methods: []grpc_go.MethodDesc{ + { + MethodName: "EmailAlertsSubmit", + Handler: _EmailAlerts_EmailAlertsSubmit_Handler, + }, + { + MethodName: "GetEmailInformationList", + Handler: _EmailAlerts_GetEmailInformationList_Handler, + }, + }, + Streams: []grpc_go.StreamDesc{}, + Metadata: "api/emailAlerts/emailAlerts.proto", +} diff --git a/clear.sh b/clear.sh index 8e483b1..afdb8fd 100644 --- a/clear.sh +++ b/clear.sh @@ -1,2 +1,2 @@ ls api/reports/*.pb.go | xargs -n1 -IX bash -c 'sed s/,omitempty// X > X.tmp && mv X{.tmp,}'; - +ls api/emailAlerts/*.pb.go | xargs -n1 -IX bash -c 'sed s/,omitempty// X > X.tmp && mv X{.tmp,}'; diff --git a/cmd/app.go b/cmd/app.go index a181a95..aa749b8 100644 --- a/cmd/app.go +++ b/cmd/app.go @@ -22,6 +22,7 @@ func main() { config.SetProviderService(&controller.PressReleasesProvider{}) config.SetProviderService(&controller.SecFilingsProvider{}) config.SetProviderService(&controller.ReportProvider{}) + config.SetProviderService(&controller.EmailAlertsProvider{}) if err := config.Load(); err != nil { panic(err) diff --git a/internel/controller/emailAlerts.go b/internel/controller/emailAlerts.go new file mode 100644 index 0000000..09ad41a --- /dev/null +++ b/internel/controller/emailAlerts.go @@ -0,0 +1,19 @@ +package controller + +import ( + "context" + "micro-document/api/emailAlerts" + "micro-document/internel/logic" +) + +type EmailAlertsProvider struct { + emailAlerts.UnimplementedEmailAlertsServer +} + +func (EmailAlertsProvider) EmailAlertsSubmit(_ context.Context, req *emailAlerts.EmailAlertsSubmitReq) (*emailAlerts.EmailAlertsSubmitResp, error) { + return logic.EmailAlertsLogic.EmailAlertsSubmit(req) +} + +func (EmailAlertsProvider) GetEmailInformationList(_ context.Context, req *emailAlerts.GetEmailInformationListReq) (*emailAlerts.GetEmailInformationListResp, error) { + return logic.EmailAlertsLogic.GetEmailInformationList(req) +} diff --git a/internel/dao/emailAlerts.go b/internel/dao/emailAlerts.go new file mode 100644 index 0000000..5319a2d --- /dev/null +++ b/internel/dao/emailAlerts.go @@ -0,0 +1,48 @@ +package dao + +import ( + "errors" + "micro-document/api/emailAlerts" + "micro-document/internel/model" + "micro-document/pkg/db" +) + +type emailAlertsDao struct{} + +var EmailAlertsDao = new(emailAlertsDao) + +func (emailAlertsDao) Submit(req *emailAlerts.EmailAlertsSubmitReq) (err error) { + err = db.DocDB.Model(&model.EmailAlerts{}).Create(&model.EmailAlerts{ + FirstName: req.FirstName, + LastName: req.LastName, + FullName: req.FirstName + req.LastName, + Email: req.Email, + Company: req.Company, + Phone: req.Phone, + }).Error + if err != nil { + return errors.New("新增邮件提醒失败") + } + return +} + +func (emailAlertsDao) GetEmailInformationList(req *emailAlerts.GetEmailInformationListReq) (data []model.EmailAlerts, total int64, err error) { + dbQuery := db.DocDB.Model(&model.EmailAlerts{}) + if req.Filtrate != nil { + if req.Filtrate.Name != "" { + dbQuery = dbQuery.Where("full_name LIKE ?", "%"+req.Filtrate.Name+"%") + } + if req.Filtrate.Email != "" { + dbQuery = dbQuery.Where("email LIKE ?", "%"+req.Filtrate.Email+"%") + } + if req.Filtrate.Company != "" { + dbQuery = dbQuery.Where("company LIKE ?", "%"+req.Filtrate.Company+"%") + } + } + dbQuery.Count(&total) + err = dbQuery.Scopes(db.Pagination(req.Page, req.PageSize)).Find(&data).Error + if err != nil { + return + } + return +} diff --git a/internel/logic/emailAlerts.go b/internel/logic/emailAlerts.go new file mode 100644 index 0000000..e8a19f8 --- /dev/null +++ b/internel/logic/emailAlerts.go @@ -0,0 +1,53 @@ +package logic + +import ( + "errors" + "micro-document/api/emailAlerts" + "micro-document/internel/dao" + util "micro-document/pkg/utils" + + "github.com/jinzhu/copier" +) + +type emailAlertsLogic struct{} + +var EmailAlertsLogic = new(emailAlertsLogic) + +func (emailAlertsLogic) EmailAlertsSubmit(req *emailAlerts.EmailAlertsSubmitReq) (result *emailAlerts.EmailAlertsSubmitResp, err error) { + result = &emailAlerts.EmailAlertsSubmitResp{} + if req.FirstName == "" { + return nil, errors.New("FirstName is null") + } + if req.LastName == "" { + return nil, errors.New("LastName is null") + } + if req.Email == "" { + return nil, errors.New("Email is null") + } + if req.Company == "" { + return nil, errors.New("Company is null") + } + if req.Phone == "" { + return nil, errors.New("Phone is null") + } + err = dao.EmailAlertsDao.Submit(req) + if err != nil { + result.Msg = err.Error() + return nil, err + } + result.Msg = "新增邮件提醒成功" + return +} + +func (emailAlertsLogic) GetEmailInformationList(req *emailAlerts.GetEmailInformationListReq) (result *emailAlerts.GetEmailInformationListResp, err error) { + result = &emailAlerts.GetEmailInformationListResp{} + data, total, err := dao.EmailAlertsDao.GetEmailInformationList(req) + if err != nil { + return nil, errors.New("查询邮件提醒失败") + } + result.Total = int32(total) + if err = copier.CopyWithOption(&result.Data, &data, util.CopierProtoOptions); err != nil { + return nil, errors.New("复制邮件提醒失败") + } + return +} diff --git a/internel/model/emailAlerts.go b/internel/model/emailAlerts.go new file mode 100644 index 0000000..842bdb6 --- /dev/null +++ b/internel/model/emailAlerts.go @@ -0,0 +1,24 @@ +package model + +import ( + "time" + + "gorm.io/gorm" +) + +type EmailAlerts struct { + ID uint `gorm:"primarykey"` + CreatedAt time.Time + UpdatedAt time.Time + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index:idx_email_alerts_deleted_at;"` + FirstName string `gorm:"column:first_name;type:varchar(50);not null;default:'';comment:姓"` + LastName string `gorm:"column:last_name;type:varchar(50);not null;default:'';comment:名"` + FullName string `gorm:"column:full_name;type:varchar(100);not null;default:'';comment:全名"` + Email string `gorm:"column:email;type:varchar(100);not null;default:'';comment:邮箱"` + Company string `gorm:"column:company;type:varchar(100);not null;default:'';comment:公司"` + Phone string `gorm:"column:phone;type:varchar(30);not null;default:'';comment:电话"` +} + +func (*EmailAlerts) TableName() string { + return "email_alerts" +} diff --git a/pkg/db/db.go b/pkg/db/db.go index 808646b..33d596c 100644 --- a/pkg/db/db.go +++ b/pkg/db/db.go @@ -42,6 +42,7 @@ func DbInit() { &model.FormType{}, &model.AnnualReport{}, &model.QuarterlyReport{}, + &model.EmailAlerts{}, ) } } diff --git a/protocEmailAlerts.bat b/protocEmailAlerts.bat new file mode 100644 index 0000000..d5a417b --- /dev/null +++ b/protocEmailAlerts.bat @@ -0,0 +1,3 @@ +@echo off +protoc -I . -I ./api/emailAlerts --proto_path=./api/emailAlerts --go_out=./api/emailAlerts --go-triple_out=./api/emailAlerts --govalidators_out=./api/emailAlerts ./api/emailAlerts/emailAlerts.proto +.\clear.sh \ No newline at end of file