diff --git a/api/delivery/v1/delivery.pb.go b/api/delivery/v1/delivery.pb.go new file mode 100644 index 0000000000000000000000000000000000000000..2ee75cd9228f7772945562f7e7edc6bf31131c51 --- /dev/null +++ b/api/delivery/v1/delivery.pb.go @@ -0,0 +1,779 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc v3.19.4 +// source: api/delivery/v1/delivery.proto + +package v1 + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +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 CreateStationRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + StationName string `protobuf:"bytes,2,opt,name=StationName,proto3" json:"StationName,omitempty"` // 站点名称 + Address string `protobuf:"bytes,3,opt,name=Address,proto3" json:"Address,omitempty"` // 站点地址 + Phone string `protobuf:"bytes,4,opt,name=Phone,proto3" json:"Phone,omitempty"` // 站点电话 + Status int32 `protobuf:"varint,5,opt,name=Status,proto3" json:"Status,omitempty"` // 状态 1正常 2停用 + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateStationRequest) Reset() { + *x = CreateStationRequest{} + mi := &file_api_delivery_v1_delivery_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateStationRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateStationRequest) ProtoMessage() {} + +func (x *CreateStationRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_delivery_v1_delivery_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 CreateStationRequest.ProtoReflect.Descriptor instead. +func (*CreateStationRequest) Descriptor() ([]byte, []int) { + return file_api_delivery_v1_delivery_proto_rawDescGZIP(), []int{0} +} + +func (x *CreateStationRequest) GetStationName() string { + if x != nil { + return x.StationName + } + return "" +} + +func (x *CreateStationRequest) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + +func (x *CreateStationRequest) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +func (x *CreateStationRequest) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +type CreateStationReply struct { + state protoimpl.MessageState `protogen:"open.v1"` + Msg string `protobuf:"bytes,1,opt,name=Msg,proto3" json:"Msg,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateStationReply) Reset() { + *x = CreateStationReply{} + mi := &file_api_delivery_v1_delivery_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateStationReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateStationReply) ProtoMessage() {} + +func (x *CreateStationReply) ProtoReflect() protoreflect.Message { + mi := &file_api_delivery_v1_delivery_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 CreateStationReply.ProtoReflect.Descriptor instead. +func (*CreateStationReply) Descriptor() ([]byte, []int) { + return file_api_delivery_v1_delivery_proto_rawDescGZIP(), []int{1} +} + +func (x *CreateStationReply) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +// 站点列表 +type StationListRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StationListRequest) Reset() { + *x = StationListRequest{} + mi := &file_api_delivery_v1_delivery_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StationListRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StationListRequest) ProtoMessage() {} + +func (x *StationListRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_delivery_v1_delivery_proto_msgTypes[2] + 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 StationListRequest.ProtoReflect.Descriptor instead. +func (*StationListRequest) Descriptor() ([]byte, []int) { + return file_api_delivery_v1_delivery_proto_rawDescGZIP(), []int{2} +} + +type StationListReply struct { + state protoimpl.MessageState `protogen:"open.v1"` + List []*StationListItem `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StationListReply) Reset() { + *x = StationListReply{} + mi := &file_api_delivery_v1_delivery_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StationListReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StationListReply) ProtoMessage() {} + +func (x *StationListReply) ProtoReflect() protoreflect.Message { + mi := &file_api_delivery_v1_delivery_proto_msgTypes[3] + 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 StationListReply.ProtoReflect.Descriptor instead. +func (*StationListReply) Descriptor() ([]byte, []int) { + return file_api_delivery_v1_delivery_proto_rawDescGZIP(), []int{3} +} + +func (x *StationListReply) GetList() []*StationListItem { + if x != nil { + return x.List + } + return nil +} + +type StationListItem struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"` + StationName string `protobuf:"bytes,2,opt,name=StationName,proto3" json:"StationName,omitempty"` // 站点名称 + Address string `protobuf:"bytes,3,opt,name=Address,proto3" json:"Address,omitempty"` // 站点地址 + Phone string `protobuf:"bytes,4,opt,name=Phone,proto3" json:"Phone,omitempty"` // 站点电话 + Status int32 `protobuf:"varint,5,opt,name=Status,proto3" json:"Status,omitempty"` // 状态 1正常 2停用 + CreatedAt string `protobuf:"bytes,6,opt,name=CreatedAt,proto3" json:"CreatedAt,omitempty"` //创建时间 + UpdatedAt string `protobuf:"bytes,7,opt,name=UpdatedAt,proto3" json:"UpdatedAt,omitempty"` //修改时间 + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StationListItem) Reset() { + *x = StationListItem{} + mi := &file_api_delivery_v1_delivery_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StationListItem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StationListItem) ProtoMessage() {} + +func (x *StationListItem) ProtoReflect() protoreflect.Message { + mi := &file_api_delivery_v1_delivery_proto_msgTypes[4] + 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 StationListItem.ProtoReflect.Descriptor instead. +func (*StationListItem) Descriptor() ([]byte, []int) { + return file_api_delivery_v1_delivery_proto_rawDescGZIP(), []int{4} +} + +func (x *StationListItem) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *StationListItem) GetStationName() string { + if x != nil { + return x.StationName + } + return "" +} + +func (x *StationListItem) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + +func (x *StationListItem) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +func (x *StationListItem) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *StationListItem) GetCreatedAt() string { + if x != nil { + return x.CreatedAt + } + return "" +} + +func (x *StationListItem) GetUpdatedAt() string { + if x != nil { + return x.UpdatedAt + } + return "" +} + +// 站点详情 +type StationShowRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"` //站点ID + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StationShowRequest) Reset() { + *x = StationShowRequest{} + mi := &file_api_delivery_v1_delivery_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StationShowRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StationShowRequest) ProtoMessage() {} + +func (x *StationShowRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_delivery_v1_delivery_proto_msgTypes[5] + 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 StationShowRequest.ProtoReflect.Descriptor instead. +func (*StationShowRequest) Descriptor() ([]byte, []int) { + return file_api_delivery_v1_delivery_proto_rawDescGZIP(), []int{5} +} + +func (x *StationShowRequest) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +type StationShowReply struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"` //站点ID + StationName string `protobuf:"bytes,2,opt,name=StationName,proto3" json:"StationName,omitempty"` // 站点名称 + Address string `protobuf:"bytes,3,opt,name=Address,proto3" json:"Address,omitempty"` // 站点地址 + Phone string `protobuf:"bytes,4,opt,name=Phone,proto3" json:"Phone,omitempty"` // 站点电话 + Status int32 `protobuf:"varint,5,opt,name=Status,proto3" json:"Status,omitempty"` // 状态 1正常 2停用 + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StationShowReply) Reset() { + *x = StationShowReply{} + mi := &file_api_delivery_v1_delivery_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StationShowReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StationShowReply) ProtoMessage() {} + +func (x *StationShowReply) ProtoReflect() protoreflect.Message { + mi := &file_api_delivery_v1_delivery_proto_msgTypes[6] + 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 StationShowReply.ProtoReflect.Descriptor instead. +func (*StationShowReply) Descriptor() ([]byte, []int) { + return file_api_delivery_v1_delivery_proto_rawDescGZIP(), []int{6} +} + +func (x *StationShowReply) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *StationShowReply) GetStationName() string { + if x != nil { + return x.StationName + } + return "" +} + +func (x *StationShowReply) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + +func (x *StationShowReply) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +func (x *StationShowReply) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +// 删除站点 +type DelStationRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"` //站点ID + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DelStationRequest) Reset() { + *x = DelStationRequest{} + mi := &file_api_delivery_v1_delivery_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DelStationRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DelStationRequest) ProtoMessage() {} + +func (x *DelStationRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_delivery_v1_delivery_proto_msgTypes[7] + 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 DelStationRequest.ProtoReflect.Descriptor instead. +func (*DelStationRequest) Descriptor() ([]byte, []int) { + return file_api_delivery_v1_delivery_proto_rawDescGZIP(), []int{7} +} + +func (x *DelStationRequest) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +type DelStationReply struct { + state protoimpl.MessageState `protogen:"open.v1"` + Msg string `protobuf:"bytes,1,opt,name=Msg,proto3" json:"Msg,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DelStationReply) Reset() { + *x = DelStationReply{} + mi := &file_api_delivery_v1_delivery_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DelStationReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DelStationReply) ProtoMessage() {} + +func (x *DelStationReply) ProtoReflect() protoreflect.Message { + mi := &file_api_delivery_v1_delivery_proto_msgTypes[8] + 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 DelStationReply.ProtoReflect.Descriptor instead. +func (*DelStationReply) Descriptor() ([]byte, []int) { + return file_api_delivery_v1_delivery_proto_rawDescGZIP(), []int{8} +} + +func (x *DelStationReply) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +// 修改站点 +type UpdateStationRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"` //站点ID + StationName string `protobuf:"bytes,2,opt,name=StationName,proto3" json:"StationName,omitempty"` // 站点名称 + Address string `protobuf:"bytes,3,opt,name=Address,proto3" json:"Address,omitempty"` // 站点地址 + Phone string `protobuf:"bytes,4,opt,name=Phone,proto3" json:"Phone,omitempty"` // 站点电话 + Status int32 `protobuf:"varint,5,opt,name=Status,proto3" json:"Status,omitempty"` // 状态 1正常 2停用 + CreatedAt string `protobuf:"bytes,6,opt,name=CreatedAt,proto3" json:"CreatedAt,omitempty"` //创建时间 + UpdatedAt string `protobuf:"bytes,7,opt,name=UpdatedAt,proto3" json:"UpdatedAt,omitempty"` //修改时间 + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateStationRequest) Reset() { + *x = UpdateStationRequest{} + mi := &file_api_delivery_v1_delivery_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateStationRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateStationRequest) ProtoMessage() {} + +func (x *UpdateStationRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_delivery_v1_delivery_proto_msgTypes[9] + 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 UpdateStationRequest.ProtoReflect.Descriptor instead. +func (*UpdateStationRequest) Descriptor() ([]byte, []int) { + return file_api_delivery_v1_delivery_proto_rawDescGZIP(), []int{9} +} + +func (x *UpdateStationRequest) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UpdateStationRequest) GetStationName() string { + if x != nil { + return x.StationName + } + return "" +} + +func (x *UpdateStationRequest) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + +func (x *UpdateStationRequest) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +func (x *UpdateStationRequest) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *UpdateStationRequest) GetCreatedAt() string { + if x != nil { + return x.CreatedAt + } + return "" +} + +func (x *UpdateStationRequest) GetUpdatedAt() string { + if x != nil { + return x.UpdatedAt + } + return "" +} + +type UpdateStationReply struct { + state protoimpl.MessageState `protogen:"open.v1"` + Msg string `protobuf:"bytes,1,opt,name=Msg,proto3" json:"Msg,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateStationReply) Reset() { + *x = UpdateStationReply{} + mi := &file_api_delivery_v1_delivery_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateStationReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateStationReply) ProtoMessage() {} + +func (x *UpdateStationReply) ProtoReflect() protoreflect.Message { + mi := &file_api_delivery_v1_delivery_proto_msgTypes[10] + 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 UpdateStationReply.ProtoReflect.Descriptor instead. +func (*UpdateStationReply) Descriptor() ([]byte, []int) { + return file_api_delivery_v1_delivery_proto_rawDescGZIP(), []int{10} +} + +func (x *UpdateStationReply) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +var File_api_delivery_v1_delivery_proto protoreflect.FileDescriptor + +const file_api_delivery_v1_delivery_proto_rawDesc = "" + + "\n" + + "\x1eapi/delivery/v1/delivery.proto\x12\x0fapi.delivery.v1\x1a\x1cgoogle/api/annotations.proto\"\x80\x01\n" + + "\x14CreateStationRequest\x12 \n" + + "\vStationName\x18\x02 \x01(\tR\vStationName\x12\x18\n" + + "\aAddress\x18\x03 \x01(\tR\aAddress\x12\x14\n" + + "\x05Phone\x18\x04 \x01(\tR\x05Phone\x12\x16\n" + + "\x06Status\x18\x05 \x01(\x05R\x06Status\"&\n" + + "\x12CreateStationReply\x12\x10\n" + + "\x03Msg\x18\x01 \x01(\tR\x03Msg\"\x14\n" + + "\x12StationListRequest\"H\n" + + "\x10StationListReply\x124\n" + + "\x04list\x18\x01 \x03(\v2 .api.delivery.v1.StationListItemR\x04list\"\xc7\x01\n" + + "\x0fStationListItem\x12\x0e\n" + + "\x02Id\x18\x01 \x01(\x05R\x02Id\x12 \n" + + "\vStationName\x18\x02 \x01(\tR\vStationName\x12\x18\n" + + "\aAddress\x18\x03 \x01(\tR\aAddress\x12\x14\n" + + "\x05Phone\x18\x04 \x01(\tR\x05Phone\x12\x16\n" + + "\x06Status\x18\x05 \x01(\x05R\x06Status\x12\x1c\n" + + "\tCreatedAt\x18\x06 \x01(\tR\tCreatedAt\x12\x1c\n" + + "\tUpdatedAt\x18\a \x01(\tR\tUpdatedAt\"$\n" + + "\x12StationShowRequest\x12\x0e\n" + + "\x02Id\x18\x01 \x01(\x05R\x02Id\"\x8c\x01\n" + + "\x10StationShowReply\x12\x0e\n" + + "\x02Id\x18\x01 \x01(\x05R\x02Id\x12 \n" + + "\vStationName\x18\x02 \x01(\tR\vStationName\x12\x18\n" + + "\aAddress\x18\x03 \x01(\tR\aAddress\x12\x14\n" + + "\x05Phone\x18\x04 \x01(\tR\x05Phone\x12\x16\n" + + "\x06Status\x18\x05 \x01(\x05R\x06Status\"#\n" + + "\x11DelStationRequest\x12\x0e\n" + + "\x02Id\x18\x01 \x01(\x05R\x02Id\"#\n" + + "\x0fDelStationReply\x12\x10\n" + + "\x03Msg\x18\x01 \x01(\tR\x03Msg\"\xcc\x01\n" + + "\x14UpdateStationRequest\x12\x0e\n" + + "\x02Id\x18\x01 \x01(\x05R\x02Id\x12 \n" + + "\vStationName\x18\x02 \x01(\tR\vStationName\x12\x18\n" + + "\aAddress\x18\x03 \x01(\tR\aAddress\x12\x14\n" + + "\x05Phone\x18\x04 \x01(\tR\x05Phone\x12\x16\n" + + "\x06Status\x18\x05 \x01(\x05R\x06Status\x12\x1c\n" + + "\tCreatedAt\x18\x06 \x01(\tR\tCreatedAt\x12\x1c\n" + + "\tUpdatedAt\x18\a \x01(\tR\tUpdatedAt\"&\n" + + "\x12UpdateStationReply\x12\x10\n" + + "\x03Msg\x18\x01 \x01(\tR\x03Msg2\xc0\x04\n" + + "\bDelivery\x12v\n" + + "\rCreateStation\x12%.api.delivery.v1.CreateStationRequest\x1a#.api.delivery.v1.CreateStationReply\"\x19\x82\xd3\xe4\x93\x02\x13:\x01*\"\x0e/CreateStation\x12k\n" + + "\vStationList\x12#.api.delivery.v1.StationListRequest\x1a!.api.delivery.v1.StationListReply\"\x14\x82\xd3\xe4\x93\x02\x0e\x12\f/StationList\x12k\n" + + "\vStationShow\x12#.api.delivery.v1.StationShowRequest\x1a!.api.delivery.v1.StationShowReply\"\x14\x82\xd3\xe4\x93\x02\x0e\x12\f/StationShow\x12j\n" + + "\n" + + "DelStation\x12\".api.delivery.v1.DelStationRequest\x1a .api.delivery.v1.DelStationReply\"\x16\x82\xd3\xe4\x93\x02\x10:\x01*\"\v/DelStation\x12v\n" + + "\rUpdateStation\x12%.api.delivery.v1.UpdateStationRequest\x1a#.api.delivery.v1.UpdateStationReply\"\x19\x82\xd3\xe4\x93\x02\x13:\x01*\"\x0e/UpdateStationB0\n" + + "\x0fapi.delivery.v1P\x01Z\x1bdelivery/api/delivery/v1;v1b\x06proto3" + +var ( + file_api_delivery_v1_delivery_proto_rawDescOnce sync.Once + file_api_delivery_v1_delivery_proto_rawDescData []byte +) + +func file_api_delivery_v1_delivery_proto_rawDescGZIP() []byte { + file_api_delivery_v1_delivery_proto_rawDescOnce.Do(func() { + file_api_delivery_v1_delivery_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_delivery_v1_delivery_proto_rawDesc), len(file_api_delivery_v1_delivery_proto_rawDesc))) + }) + return file_api_delivery_v1_delivery_proto_rawDescData +} + +var file_api_delivery_v1_delivery_proto_msgTypes = make([]protoimpl.MessageInfo, 11) +var file_api_delivery_v1_delivery_proto_goTypes = []any{ + (*CreateStationRequest)(nil), // 0: api.delivery.v1.CreateStationRequest + (*CreateStationReply)(nil), // 1: api.delivery.v1.CreateStationReply + (*StationListRequest)(nil), // 2: api.delivery.v1.StationListRequest + (*StationListReply)(nil), // 3: api.delivery.v1.StationListReply + (*StationListItem)(nil), // 4: api.delivery.v1.StationListItem + (*StationShowRequest)(nil), // 5: api.delivery.v1.StationShowRequest + (*StationShowReply)(nil), // 6: api.delivery.v1.StationShowReply + (*DelStationRequest)(nil), // 7: api.delivery.v1.DelStationRequest + (*DelStationReply)(nil), // 8: api.delivery.v1.DelStationReply + (*UpdateStationRequest)(nil), // 9: api.delivery.v1.UpdateStationRequest + (*UpdateStationReply)(nil), // 10: api.delivery.v1.UpdateStationReply +} +var file_api_delivery_v1_delivery_proto_depIdxs = []int32{ + 4, // 0: api.delivery.v1.StationListReply.list:type_name -> api.delivery.v1.StationListItem + 0, // 1: api.delivery.v1.Delivery.CreateStation:input_type -> api.delivery.v1.CreateStationRequest + 2, // 2: api.delivery.v1.Delivery.StationList:input_type -> api.delivery.v1.StationListRequest + 5, // 3: api.delivery.v1.Delivery.StationShow:input_type -> api.delivery.v1.StationShowRequest + 7, // 4: api.delivery.v1.Delivery.DelStation:input_type -> api.delivery.v1.DelStationRequest + 9, // 5: api.delivery.v1.Delivery.UpdateStation:input_type -> api.delivery.v1.UpdateStationRequest + 1, // 6: api.delivery.v1.Delivery.CreateStation:output_type -> api.delivery.v1.CreateStationReply + 3, // 7: api.delivery.v1.Delivery.StationList:output_type -> api.delivery.v1.StationListReply + 6, // 8: api.delivery.v1.Delivery.StationShow:output_type -> api.delivery.v1.StationShowReply + 8, // 9: api.delivery.v1.Delivery.DelStation:output_type -> api.delivery.v1.DelStationReply + 10, // 10: api.delivery.v1.Delivery.UpdateStation:output_type -> api.delivery.v1.UpdateStationReply + 6, // [6:11] is the sub-list for method output_type + 1, // [1:6] 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_delivery_v1_delivery_proto_init() } +func file_api_delivery_v1_delivery_proto_init() { + if File_api_delivery_v1_delivery_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_delivery_v1_delivery_proto_rawDesc), len(file_api_delivery_v1_delivery_proto_rawDesc)), + NumEnums: 0, + NumMessages: 11, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_api_delivery_v1_delivery_proto_goTypes, + DependencyIndexes: file_api_delivery_v1_delivery_proto_depIdxs, + MessageInfos: file_api_delivery_v1_delivery_proto_msgTypes, + }.Build() + File_api_delivery_v1_delivery_proto = out.File + file_api_delivery_v1_delivery_proto_goTypes = nil + file_api_delivery_v1_delivery_proto_depIdxs = nil +} diff --git a/api/delivery/v1/delivery.proto b/api/delivery/v1/delivery.proto new file mode 100644 index 0000000000000000000000000000000000000000..ff1d57ae2bc1ef8d31633799acf98edfb3305013 --- /dev/null +++ b/api/delivery/v1/delivery.proto @@ -0,0 +1,112 @@ +syntax = "proto3"; + +package api.delivery.v1; +import "google/api/annotations.proto"; +option go_package = "delivery/api/delivery/v1;v1"; +option java_multiple_files = true; +option java_package = "api.delivery.v1"; + + +service Delivery { + rpc CreateStation (CreateStationRequest) returns (CreateStationReply) { + option (google.api.http) = { + post: "/CreateStation" + body: "*" + }; + } + rpc StationList (StationListRequest) returns (StationListReply) { + option (google.api.http) = { + get: "/StationList" + //body: "*" + }; + } + rpc StationShow (StationShowRequest) returns (StationShowReply) { + option (google.api.http) = { + get: "/StationShow" + //body: "*" + }; + } + + rpc DelStation (DelStationRequest) returns (DelStationReply) { + option (google.api.http) = { + post: "/DelStation" + body: "*" + }; + } + + rpc UpdateStation (UpdateStationRequest) returns (UpdateStationReply) { + option (google.api.http) = { + post: "/UpdateStation" + body: "*" + }; + } +} +//添加站点 +message CreateStationRequest { + string StationName = 2; // 站点名称 + string Address = 3; // 站点地址 + string Phone = 4; // 站点电话 + int32 Status = 5; // 状态 1正常 2停用 +} +message CreateStationReply { + string Msg = 1; +} + + +//站点列表 +message StationListRequest { + +} +message StationListReply { +repeated StationListItem list = 1; +} + +message StationListItem { + int32 Id = 1; + string StationName = 2; // 站点名称 + string Address = 3; // 站点地址 + string Phone = 4; // 站点电话 + int32 Status = 5; // 状态 1正常 2停用 + string CreatedAt =6; //创建时间 + string UpdatedAt = 7; //修改时间 +} + +//站点详情 +message StationShowRequest { + int32 Id = 1; //站点ID +} + +message StationShowReply { + int32 Id = 1; //站点ID + string StationName = 2; // 站点名称 + string Address = 3; // 站点地址 + string Phone = 4; // 站点电话 + int32 Status = 5; // 状态 1正常 2停用 +// string CreatedAt =6; //创建时间 +// string UpdatedAt = 7; //修改时间 +} + + +//删除站点 +message DelStationRequest { + int32 Id = 1; //站点ID +} + +message DelStationReply { + string Msg = 1; +} + +//修改站点 +message UpdateStationRequest { + int32 Id = 1; //站点ID + string StationName = 2; // 站点名称 + string Address = 3; // 站点地址 + string Phone = 4; // 站点电话 + int32 Status = 5; // 状态 1正常 2停用 + string CreatedAt =6; //创建时间 + string UpdatedAt = 7; //修改时间 +} + +message UpdateStationReply { + string Msg = 1; +} \ No newline at end of file diff --git a/api/delivery/v1/delivery_grpc.pb.go b/api/delivery/v1/delivery_grpc.pb.go new file mode 100644 index 0000000000000000000000000000000000000000..39c7825a7b9d561c0fca2660091ee2208e8b05ae --- /dev/null +++ b/api/delivery/v1/delivery_grpc.pb.go @@ -0,0 +1,273 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v3.19.4 +// source: api/delivery/v1/delivery.proto + +package v1 + +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 ( + Delivery_CreateStation_FullMethodName = "/api.delivery.v1.Delivery/CreateStation" + Delivery_StationList_FullMethodName = "/api.delivery.v1.Delivery/StationList" + Delivery_StationShow_FullMethodName = "/api.delivery.v1.Delivery/StationShow" + Delivery_DelStation_FullMethodName = "/api.delivery.v1.Delivery/DelStation" + Delivery_UpdateStation_FullMethodName = "/api.delivery.v1.Delivery/UpdateStation" +) + +// DeliveryClient is the client API for Delivery 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 DeliveryClient interface { + CreateStation(ctx context.Context, in *CreateStationRequest, opts ...grpc.CallOption) (*CreateStationReply, error) + StationList(ctx context.Context, in *StationListRequest, opts ...grpc.CallOption) (*StationListReply, error) + StationShow(ctx context.Context, in *StationShowRequest, opts ...grpc.CallOption) (*StationShowReply, error) + DelStation(ctx context.Context, in *DelStationRequest, opts ...grpc.CallOption) (*DelStationReply, error) + UpdateStation(ctx context.Context, in *UpdateStationRequest, opts ...grpc.CallOption) (*UpdateStationReply, error) +} + +type deliveryClient struct { + cc grpc.ClientConnInterface +} + +func NewDeliveryClient(cc grpc.ClientConnInterface) DeliveryClient { + return &deliveryClient{cc} +} + +func (c *deliveryClient) CreateStation(ctx context.Context, in *CreateStationRequest, opts ...grpc.CallOption) (*CreateStationReply, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreateStationReply) + err := c.cc.Invoke(ctx, Delivery_CreateStation_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *deliveryClient) StationList(ctx context.Context, in *StationListRequest, opts ...grpc.CallOption) (*StationListReply, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(StationListReply) + err := c.cc.Invoke(ctx, Delivery_StationList_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *deliveryClient) StationShow(ctx context.Context, in *StationShowRequest, opts ...grpc.CallOption) (*StationShowReply, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(StationShowReply) + err := c.cc.Invoke(ctx, Delivery_StationShow_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *deliveryClient) DelStation(ctx context.Context, in *DelStationRequest, opts ...grpc.CallOption) (*DelStationReply, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DelStationReply) + err := c.cc.Invoke(ctx, Delivery_DelStation_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *deliveryClient) UpdateStation(ctx context.Context, in *UpdateStationRequest, opts ...grpc.CallOption) (*UpdateStationReply, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdateStationReply) + err := c.cc.Invoke(ctx, Delivery_UpdateStation_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// DeliveryServer is the server API for Delivery service. +// All implementations must embed UnimplementedDeliveryServer +// for forward compatibility. +type DeliveryServer interface { + CreateStation(context.Context, *CreateStationRequest) (*CreateStationReply, error) + StationList(context.Context, *StationListRequest) (*StationListReply, error) + StationShow(context.Context, *StationShowRequest) (*StationShowReply, error) + DelStation(context.Context, *DelStationRequest) (*DelStationReply, error) + UpdateStation(context.Context, *UpdateStationRequest) (*UpdateStationReply, error) + mustEmbedUnimplementedDeliveryServer() +} + +// UnimplementedDeliveryServer 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 UnimplementedDeliveryServer struct{} + +func (UnimplementedDeliveryServer) CreateStation(context.Context, *CreateStationRequest) (*CreateStationReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateStation not implemented") +} +func (UnimplementedDeliveryServer) StationList(context.Context, *StationListRequest) (*StationListReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method StationList not implemented") +} +func (UnimplementedDeliveryServer) StationShow(context.Context, *StationShowRequest) (*StationShowReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method StationShow not implemented") +} +func (UnimplementedDeliveryServer) DelStation(context.Context, *DelStationRequest) (*DelStationReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method DelStation not implemented") +} +func (UnimplementedDeliveryServer) UpdateStation(context.Context, *UpdateStationRequest) (*UpdateStationReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateStation not implemented") +} +func (UnimplementedDeliveryServer) mustEmbedUnimplementedDeliveryServer() {} +func (UnimplementedDeliveryServer) testEmbeddedByValue() {} + +// UnsafeDeliveryServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to DeliveryServer will +// result in compilation errors. +type UnsafeDeliveryServer interface { + mustEmbedUnimplementedDeliveryServer() +} + +func RegisterDeliveryServer(s grpc.ServiceRegistrar, srv DeliveryServer) { + // If the following call pancis, it indicates UnimplementedDeliveryServer 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(&Delivery_ServiceDesc, srv) +} + +func _Delivery_CreateStation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateStationRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DeliveryServer).CreateStation(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Delivery_CreateStation_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DeliveryServer).CreateStation(ctx, req.(*CreateStationRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Delivery_StationList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StationListRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DeliveryServer).StationList(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Delivery_StationList_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DeliveryServer).StationList(ctx, req.(*StationListRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Delivery_StationShow_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StationShowRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DeliveryServer).StationShow(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Delivery_StationShow_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DeliveryServer).StationShow(ctx, req.(*StationShowRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Delivery_DelStation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DelStationRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DeliveryServer).DelStation(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Delivery_DelStation_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DeliveryServer).DelStation(ctx, req.(*DelStationRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Delivery_UpdateStation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateStationRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DeliveryServer).UpdateStation(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Delivery_UpdateStation_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DeliveryServer).UpdateStation(ctx, req.(*UpdateStationRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Delivery_ServiceDesc is the grpc.ServiceDesc for Delivery service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Delivery_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.delivery.v1.Delivery", + HandlerType: (*DeliveryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateStation", + Handler: _Delivery_CreateStation_Handler, + }, + { + MethodName: "StationList", + Handler: _Delivery_StationList_Handler, + }, + { + MethodName: "StationShow", + Handler: _Delivery_StationShow_Handler, + }, + { + MethodName: "DelStation", + Handler: _Delivery_DelStation_Handler, + }, + { + MethodName: "UpdateStation", + Handler: _Delivery_UpdateStation_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "api/delivery/v1/delivery.proto", +} diff --git a/api/delivery/v1/delivery_http.pb.go b/api/delivery/v1/delivery_http.pb.go new file mode 100644 index 0000000000000000000000000000000000000000..fae952244662177d14b75589fc9e2c057c2d545d --- /dev/null +++ b/api/delivery/v1/delivery_http.pb.go @@ -0,0 +1,228 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.9.0 +// - protoc v3.19.4 +// source: api/delivery/v1/delivery.proto + +package v1 + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationDeliveryCreateStation = "/api.delivery.v1.Delivery/CreateStation" +const OperationDeliveryDelStation = "/api.delivery.v1.Delivery/DelStation" +const OperationDeliveryStationList = "/api.delivery.v1.Delivery/StationList" +const OperationDeliveryStationShow = "/api.delivery.v1.Delivery/StationShow" +const OperationDeliveryUpdateStation = "/api.delivery.v1.Delivery/UpdateStation" + +type DeliveryHTTPServer interface { + CreateStation(context.Context, *CreateStationRequest) (*CreateStationReply, error) + DelStation(context.Context, *DelStationRequest) (*DelStationReply, error) + StationList(context.Context, *StationListRequest) (*StationListReply, error) + StationShow(context.Context, *StationShowRequest) (*StationShowReply, error) + UpdateStation(context.Context, *UpdateStationRequest) (*UpdateStationReply, error) +} + +func RegisterDeliveryHTTPServer(s *http.Server, srv DeliveryHTTPServer) { + r := s.Route("/") + r.POST("/CreateStation", _Delivery_CreateStation0_HTTP_Handler(srv)) + r.GET("/StationList", _Delivery_StationList0_HTTP_Handler(srv)) + r.GET("/StationShow", _Delivery_StationShow0_HTTP_Handler(srv)) + r.POST("/DelStation", _Delivery_DelStation0_HTTP_Handler(srv)) + r.POST("/UpdateStation", _Delivery_UpdateStation0_HTTP_Handler(srv)) +} + +func _Delivery_CreateStation0_HTTP_Handler(srv DeliveryHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateStationRequest + if err := ctx.Bind(&in); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDeliveryCreateStation) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateStation(ctx, req.(*CreateStationRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*CreateStationReply) + return ctx.Result(200, reply) + } +} + +func _Delivery_StationList0_HTTP_Handler(srv DeliveryHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in StationListRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDeliveryStationList) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.StationList(ctx, req.(*StationListRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*StationListReply) + return ctx.Result(200, reply) + } +} + +func _Delivery_StationShow0_HTTP_Handler(srv DeliveryHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in StationShowRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDeliveryStationShow) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.StationShow(ctx, req.(*StationShowRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*StationShowReply) + return ctx.Result(200, reply) + } +} + +func _Delivery_DelStation0_HTTP_Handler(srv DeliveryHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DelStationRequest + if err := ctx.Bind(&in); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDeliveryDelStation) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DelStation(ctx, req.(*DelStationRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*DelStationReply) + return ctx.Result(200, reply) + } +} + +func _Delivery_UpdateStation0_HTTP_Handler(srv DeliveryHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateStationRequest + if err := ctx.Bind(&in); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDeliveryUpdateStation) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateStation(ctx, req.(*UpdateStationRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdateStationReply) + return ctx.Result(200, reply) + } +} + +type DeliveryHTTPClient interface { + CreateStation(ctx context.Context, req *CreateStationRequest, opts ...http.CallOption) (rsp *CreateStationReply, err error) + DelStation(ctx context.Context, req *DelStationRequest, opts ...http.CallOption) (rsp *DelStationReply, err error) + StationList(ctx context.Context, req *StationListRequest, opts ...http.CallOption) (rsp *StationListReply, err error) + StationShow(ctx context.Context, req *StationShowRequest, opts ...http.CallOption) (rsp *StationShowReply, err error) + UpdateStation(ctx context.Context, req *UpdateStationRequest, opts ...http.CallOption) (rsp *UpdateStationReply, err error) +} + +type DeliveryHTTPClientImpl struct { + cc *http.Client +} + +func NewDeliveryHTTPClient(client *http.Client) DeliveryHTTPClient { + return &DeliveryHTTPClientImpl{client} +} + +func (c *DeliveryHTTPClientImpl) CreateStation(ctx context.Context, in *CreateStationRequest, opts ...http.CallOption) (*CreateStationReply, error) { + var out CreateStationReply + pattern := "/CreateStation" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationDeliveryCreateStation)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *DeliveryHTTPClientImpl) DelStation(ctx context.Context, in *DelStationRequest, opts ...http.CallOption) (*DelStationReply, error) { + var out DelStationReply + pattern := "/DelStation" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationDeliveryDelStation)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *DeliveryHTTPClientImpl) StationList(ctx context.Context, in *StationListRequest, opts ...http.CallOption) (*StationListReply, error) { + var out StationListReply + pattern := "/StationList" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationDeliveryStationList)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *DeliveryHTTPClientImpl) StationShow(ctx context.Context, in *StationShowRequest, opts ...http.CallOption) (*StationShowReply, error) { + var out StationShowReply + pattern := "/StationShow" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationDeliveryStationShow)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *DeliveryHTTPClientImpl) UpdateStation(ctx context.Context, in *UpdateStationRequest, opts ...http.CallOption) (*UpdateStationReply, error) { + var out UpdateStationReply + pattern := "/UpdateStation" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationDeliveryUpdateStation)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/cmd/delivery/delivery b/cmd/delivery/delivery new file mode 100644 index 0000000000000000000000000000000000000000..1f463377a79dd6d6b86d6951090b9ab700ae87d0 Binary files /dev/null and b/cmd/delivery/delivery differ diff --git a/cmd/delivery/main.go b/cmd/delivery/main.go index 78ea5bff7fd57e005ec00a06bd3d395b88284f11..98e5918732cf686f0da534440a05e8e6ccb0253c 100644 --- a/cmd/delivery/main.go +++ b/cmd/delivery/main.go @@ -4,8 +4,8 @@ import ( "flag" "os" + "delivery/internal/biz" "delivery/internal/conf" - "github.com/go-kratos/kratos/v2" "github.com/go-kratos/kratos/v2/config" "github.com/go-kratos/kratos/v2/config/file" @@ -74,12 +74,23 @@ func main() { panic(err) } - app, cleanup, err := wireApp(bc.Server, bc.Data, logger) + appWithDeps, cleanup, err := wireApp(bc.Server, bc.Data, logger) if err != nil { panic(err) } defer cleanup() + // 从AppWithDependencies获取应用和依赖 + app := appWithDeps.App + orderUsecase := appWithDeps.OrderUsecase + + // 初始化Kafka消费者 + kafkaCleanup, err := biz.StartKafkaConsumer(bc.Data, orderUsecase, logger) + if err != nil { + panic(err) + } + defer kafkaCleanup() + // start and wait for stop signal if err := app.Run(); err != nil { panic(err) diff --git a/cmd/delivery/wire.go b/cmd/delivery/wire.go index 7f8b638a003e5f12d80cc59bd0cff8eb7c101313..e4e039f15d11f3439697c8e39703df155ed62472 100644 --- a/cmd/delivery/wire.go +++ b/cmd/delivery/wire.go @@ -17,15 +17,29 @@ import ( "github.com/google/wire" ) -// wireApp init kratos application. -func wireApp(*conf.Server, *conf.Data, log.Logger) (*kratos.App, func(), error) { +// AppWithDependencies 封装应用和所需依赖的结构体 +type AppWithDependencies struct { + App *kratos.App + OrderUsecase *biz.OrderUsecase +} + +// newAppWithDependencies 创建AppWithDependencies实例 +func newAppWithDependencies(app *kratos.App, orderUsecase *biz.OrderUsecase) *AppWithDependencies { + return &AppWithDependencies{ + App: app, + OrderUsecase: orderUsecase, + } +} + +// wireApp init kratos application. Returns app with dependencies, cleanup, error +func wireApp(*conf.Server, *conf.Data, log.Logger) (*AppWithDependencies, func(), error) { panic(wire.Build( server.ProviderSet, data.ProviderSet, biz.ProviderSet, service.ProviderSet, newApp, - initKafkaConsumer, // 初始化Kafka消费者 + newAppWithDependencies, )) } diff --git a/cmd/delivery/wire_gen.go b/cmd/delivery/wire_gen.go index 93fee64a040d08d8b9604ad00756e1ed57047023..25db8e94cf4daaf8a2216ee3c8a8c1c3c9806f37 100644 --- a/cmd/delivery/wire_gen.go +++ b/cmd/delivery/wire_gen.go @@ -22,8 +22,8 @@ import ( // Injectors from wire.go: -// wireApp init kratos application. -func wireApp(confServer *conf.Server, confData *conf.Data, logger log.Logger) (*kratos.App, func(), error) { +// wireApp init kratos application. Returns app with dependencies, cleanup, error +func wireApp(confServer *conf.Server, confData *conf.Data, logger log.Logger) (*AppWithDependencies, func(), error) { client, cleanup, err := data.Redis(confData, logger) if err != nil { return nil, nil, err @@ -33,42 +33,52 @@ func wireApp(confServer *conf.Server, confData *conf.Data, logger log.Logger) (* cleanup() return nil, nil, err } + greeterRepo := data.NewGreeterRepo(dataData, logger) + greeterUsecase := biz.NewGreeterUsecase(greeterRepo, logger) + greeterService := service.NewGreeterService(greeterUsecase) + stationRepo := data.NewStationRepo(dataData, logger) + stationUsecase := biz.NewStationUsecase(stationRepo, logger) + deliveryService := service.NewStationService(stationUsecase, logger) + orderRepo := data.NewOrderRepo(dataData, logger) + couponRepo := data.NewCouponRepo(dataData, logger) + stockRepo := data.NewStockRepo(dataData, logger) kafkaProducer, cleanup3, err := data.NewKafkaProducer(confData, logger) if err != nil { cleanup2() cleanup() return nil, nil, err } - greeterRepo := data.NewGreeterRepo(dataData, logger) - orderRepo := data.NewOrderRepo(dataData, logger) - couponRepo := data.NewCouponRepo(dataData, logger) - stockRepo := data.NewStockRepo(dataData, logger) - greeterUsecase := biz.NewGreeterUsecase(greeterRepo, logger) orderUsecase := biz.NewOrderUsecase(orderRepo, couponRepo, stockRepo, kafkaProducer, logger) orderService := service.NewOrderService(orderUsecase, logger) - greeterService := service.NewGreeterService(greeterUsecase) - grpcServer := server.NewGRPCServer(confServer, greeterService, orderService, logger) - httpServer := server.NewHTTPServer(confServer, greeterService, orderService, logger) - kafkaConsumerCleanup := func() {} - if confData != nil { - kConsumerCleanup, err := biz.StartKafkaConsumer(confData, orderUsecase, logger) - if err != nil { - if cleanup3 != nil { - cleanup3() - } - cleanup2() - cleanup() - return nil, nil, err - } - kafkaConsumerCleanup = kConsumerCleanup - } + grpcServer := server.NewGRPCServer(confServer, greeterService, deliveryService, orderService, logger) + httpServer := server.NewHTTPServer(confServer, greeterService, deliveryService, orderService, logger) app := newApp(logger, grpcServer, httpServer) - return app, func() { - kafkaConsumerCleanup() - if cleanup3 != nil { - cleanup3() - } + appWithDependencies := newAppWithDependencies(app, orderUsecase) + return appWithDependencies, func() { + cleanup3() cleanup2() cleanup() }, nil } + +// wire.go: + +// AppWithDependencies 封装应用和所需依赖的结构体 +type AppWithDependencies struct { + App *kratos.App + OrderUsecase *biz.OrderUsecase +} + +// newAppWithDependencies 创建AppWithDependencies实例 +func newAppWithDependencies(app *kratos.App, orderUsecase *biz.OrderUsecase) *AppWithDependencies { + return &AppWithDependencies{ + App: app, + OrderUsecase: orderUsecase, + } +} + +// initKafkaConsumer 初始化Kafka消费者 +func initKafkaConsumer(c *conf.Data, orderUsecase *biz.OrderUsecase, logger log.Logger) (func(), error) { + cleanup, err := biz.StartKafkaConsumer(c, orderUsecase, logger) + return cleanup, err +} diff --git a/delivery b/delivery index 94b6f245859cfb1de7f7f3e781e3e64dae651f4e..897a21494032a45dcbdc573b22cefbfa04f31e02 100755 Binary files a/delivery and b/delivery differ diff --git a/go.mod b/go.mod index b34f2b30064969182bfaf61d6b75cbfd5cf05f07..42faf1a1706405dafd61bdbd38ceaa427c722720 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module delivery -go 1.23.0 +go 1.25.1 require ( github.com/go-kratos/kratos/v2 v2.8.0 diff --git a/internal/biz/biz.go b/internal/biz/biz.go index 1f5d1f09bf0f7d697d300bb3191b1375e568a4c6..3c58d0148f6ca7f8414d1f150312ca397e6e41db 100644 --- a/internal/biz/biz.go +++ b/internal/biz/biz.go @@ -3,4 +3,4 @@ package biz import "github.com/google/wire" // ProviderSet is biz providers. -var ProviderSet = wire.NewSet(NewGreeterUsecase, NewOrderUsecase) +var ProviderSet = wire.NewSet(NewGreeterUsecase, NewStationUsecase, NewOrderUsecase) diff --git a/internal/biz/delivery.go b/internal/biz/delivery.go new file mode 100644 index 0000000000000000000000000000000000000000..2af61e62c2d9a741f319065e29ab7353449cb254 --- /dev/null +++ b/internal/biz/delivery.go @@ -0,0 +1,112 @@ +package biz + +import ( + "context" + "github.com/go-kratos/kratos/v2/log" + "time" +) + +// Greeter is a Greeter model. +type Station struct { + Id int32 `gorm:"column:id;type:int;primaryKey;not null;" json:"id"` + StationName string `gorm:"column:staton_name;type:varchar(255);comment:站点名称;default:NULL;" json:"staton_name"` // 站点名称 + Address string `gorm:"column:address;type:varchar(255);comment:站点地址;default:NULL;" json:"address"` // 站点地址 + Phone string `gorm:"column:phone;type:varchar(255);comment:站点电话;default:NULL;" json:"phone"` // 站点电话 + Status int32 `gorm:"column:status;type:int;comment:状态 1正常 2停用;default:NULL;" json:"status"` // 状态 1正常 2停用 + CreatedAt time.Time `gorm:"column:created_at;type:datetime;comment:创建时间;default:NULL;" json:"created_at"` // 创建时间 + UpdatedAt time.Time `gorm:"column:updated_at;type:datetime;comment:修改时间;default:NULL;" json:"updated_at"` // 修改时间 +} + +func (s *Station) TableName() string { + return "station" +} + +// GreeterRepo is a Greater repo. +type StationRepo interface { + CreateStation(ctx context.Context, station *Station) error + StationList(ctx context.Context) ([]*Station, error) + StationShow(ctx context.Context, Id int32) (*Station, error) + DelStation(ctx context.Context, Id int32) error + UpdateStation(ctx context.Context, station *Station) error +} + +// GreeterUsecase is a Greeter usecase. +type StationUsecase struct { + repo StationRepo + log *log.Helper +} + +// NewGreeterUsecase new a Greeter usecase. +func NewStationUsecase(repo StationRepo, logger log.Logger) *StationUsecase { + return &StationUsecase{repo: repo, log: log.NewHelper(logger)} +} + +// 添加站点 +func (uc *StationUsecase) CreateStation(ctx context.Context, StationName, Address, Phone string, Status int32) (*Station, error) { + station := &Station{ + StationName: StationName, + Address: Address, + Phone: Phone, + Status: Status, + CreatedAt: time.Now(), + UpdatedAt: time.Now(), + } + err := uc.repo.CreateStation(ctx, station) + if err != nil { + return nil, err + } + uc.log.Warnf("站点创建成功") + return station, err + +} + +// 站点列表 +// CreateGreeter creates a Greeter, and returns the new Greeter. +func (uc *StationUsecase) StationList(ctx context.Context) ([]*Station, error) { + list, err := uc.repo.StationList(ctx) + if err != nil { + return nil, err + } + uc.log.Warnf("列表查询成功:%s", list) + return list, nil +} + +// 站点详情 +func (uc *StationUsecase) StationShow(ctx context.Context, Id int32) (*Station, error) { + + show, err := uc.repo.StationShow(ctx, Id) + if err != nil { + return nil, err + } + uc.log.Warnf("站点查询详情成功") + return show, err +} + +// 站点删除 +func (uc *StationUsecase) DelStation(ctx context.Context, Id int32) (*Station, error) { + err := uc.repo.DelStation(ctx, Id) + if err != nil { + return nil, err + } + uc.log.Warnf("删除站点成功") + return nil, err +} + +// 修改站点 +func (uc *StationUsecase) UpdateStation(ctx context.Context, Id, Status int32, StationName, Address, Phone string) (*Station, error) { + station := &Station{ + Id: Id, + StationName: StationName, + Address: Address, + Phone: Phone, + Status: Status, + CreatedAt: time.Now(), + UpdatedAt: time.Now(), + } + err := uc.repo.UpdateStation(ctx, station) + if err != nil { + return nil, err + } + uc.log.Warnf("站点修改成功") + return station, err +} diff --git a/internal/data/data.go b/internal/data/data.go index 8af066d8618bc3c993486008817a5c5bbbcbf815..14e55e9e62dbad8eef912edf861c39b2c1be7ccc 100644 --- a/internal/data/data.go +++ b/internal/data/data.go @@ -2,6 +2,7 @@ package data import ( "context" + "delivery/internal/biz" "delivery/internal/conf" "time" @@ -16,10 +17,12 @@ import ( var ProviderSet = wire.NewSet( NewData, NewGreeterRepo, + NewStationRepo, NewOrderRepo, NewCouponRepo, NewStockRepo, NewKafkaProducer, + wire.Bind(new(biz.KafkaProducer), new(*kafkaProducer)), Redis, ) diff --git a/internal/data/deliver.go b/internal/data/deliver.go new file mode 100644 index 0000000000000000000000000000000000000000..1185dadb67e320968f5c4b17c8247d75dd12b65a --- /dev/null +++ b/internal/data/deliver.go @@ -0,0 +1,74 @@ +package data + +import ( + "context" + "fmt" + + "delivery/internal/biz" + + "github.com/go-kratos/kratos/v2/log" +) + +type StationRepo struct { + data *Data + log *log.Helper +} + +// NewGreeterRepo . +func NewStationRepo(data *Data, logger log.Logger) biz.StationRepo { + return &StationRepo{ + data: data, + log: log.NewHelper(logger), + } +} + +// 创建站点 +func (r *StationRepo) CreateStation(ctx context.Context, g *biz.Station) error { + err := r.data.DB.WithContext(ctx).Create(g).Error + if err != nil { + return err + } + return nil +} + +// 站点列表 +func (r *StationRepo) StationList(ctx context.Context) ([]*biz.Station, error) { + var station []*biz.Station + err := r.data.DB.WithContext(ctx).Find(&station).Error + if err != nil { + return nil, err + } + return station, nil +} + +// 站点详情 +func (r *StationRepo) StationShow(ctx context.Context, Id int32) (*biz.Station, error) { + var station biz.Station + err := r.data.DB.WithContext(ctx).Where("id = ?", Id).First(&station).Error + if err != nil { + return nil, fmt.Errorf("查询站点详情失败: %v", err) + } + return &station, nil +} + +// 站点删除 +func (r *StationRepo) DelStation(ctx context.Context, Id int32) error { + var station biz.Station + err := r.data.DB.WithContext(ctx).Where("id = ?", Id).Delete(&station).Error + if err != nil { + return err + } + r.log.Warnf("站点删除成功") + return nil +} + +// 修改站点 +func (r *StationRepo) UpdateStation(ctx context.Context, g *biz.Station) error { + + err := r.data.DB.WithContext(ctx).Where("id = ?", g.Id).Updates(&g).Error + if err != nil { + return err + } + r.log.Warnf("站点修改成功") + return nil +} diff --git a/internal/server/grpc.go b/internal/server/grpc.go index 80f4f994379a5481a8c4006baa786a5c9d1b000a..20d29417b20213a9c513636f72c57bb7c87f09cf 100644 --- a/internal/server/grpc.go +++ b/internal/server/grpc.go @@ -1,6 +1,7 @@ package server import ( + pb "delivery/api/delivery/v1" helloworldv1 "delivery/api/helloworld/v1" orderv1 "delivery/api/order/v1" "delivery/internal/conf" @@ -12,7 +13,7 @@ import ( ) // NewGRPCServer new a gRPC server. -func NewGRPCServer(c *conf.Server, greeter *service.GreeterService, order *service.OrderService, logger log.Logger) *grpc.Server { +func NewGRPCServer(c *conf.Server, greeter *service.GreeterService, delivery *service.DeliveryService, order *service.OrderService, logger log.Logger) *grpc.Server { var opts = []grpc.ServerOption{ grpc.Middleware( recovery.Recovery(), @@ -29,6 +30,7 @@ func NewGRPCServer(c *conf.Server, greeter *service.GreeterService, order *servi } srv := grpc.NewServer(opts...) helloworldv1.RegisterGreeterServer(srv, greeter) + pb.RegisterDeliveryServer(srv, delivery) orderv1.RegisterOrderServer(srv, order) return srv } diff --git a/internal/server/http.go b/internal/server/http.go index befa84fab60a243ffadf7d7f3e1d83cdb098b88d..030ea06d80c071ea7e2525d8917f4701282ede18 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -1,6 +1,7 @@ package server import ( + pb "delivery/api/delivery/v1" helloworldv1 "delivery/api/helloworld/v1" orderv1 "delivery/api/order/v1" "delivery/internal/conf" @@ -12,7 +13,7 @@ import ( ) // NewHTTPServer new an HTTP server. -func NewHTTPServer(c *conf.Server, greeter *service.GreeterService, order *service.OrderService, logger log.Logger) *http.Server { +func NewHTTPServer(c *conf.Server, greeter *service.GreeterService, delivery *service.DeliveryService, order *service.OrderService, logger log.Logger) *http.Server { var opts = []http.ServerOption{ http.Middleware( recovery.Recovery(), @@ -29,6 +30,7 @@ func NewHTTPServer(c *conf.Server, greeter *service.GreeterService, order *servi } srv := http.NewServer(opts...) helloworldv1.RegisterGreeterHTTPServer(srv, greeter) + pb.RegisterDeliveryHTTPServer(srv, delivery) orderv1.RegisterOrderHTTPServer(srv, order) return srv } diff --git a/internal/service/delivery.go b/internal/service/delivery.go new file mode 100644 index 0000000000000000000000000000000000000000..267a7ac5ef0beee728aa415b960d59e7db3d3c9d --- /dev/null +++ b/internal/service/delivery.go @@ -0,0 +1,94 @@ +package service + +import ( + "context" + "delivery/internal/biz" + "fmt" + "github.com/go-kratos/kratos/v2/log" + + pb "delivery/api/delivery/v1" +) + +type DeliveryService struct { + pb.UnimplementedDeliveryServer + uc *biz.StationUsecase + log *log.Helper +} + +func NewStationService(uc *biz.StationUsecase, logger log.Logger) *DeliveryService { + return &DeliveryService{ + uc: uc, + log: log.NewHelper(logger), + } +} + +// 创建站点 +func (s *DeliveryService) CreateStation(ctx context.Context, req *pb.CreateStationRequest) (*pb.CreateStationReply, error) { + station, err := s.uc.CreateStation(ctx, req.StationName, req.Phone, req.Address, req.Status) + if err != nil { + return nil, fmt.Errorf("站点创建失败%s", station) + } + return &pb.CreateStationReply{Msg: "站点创建成功"}, nil +} + +// 站点列表 +func (s *DeliveryService) StationList(ctx context.Context, req *pb.StationListRequest) (*pb.StationListReply, error) { + station, err := s.uc.StationList(ctx) + if err != nil { + return nil, err + } + var list []*pb.StationListItem + for _, i := range station { + list = append(list, &pb.StationListItem{ + Id: i.Id, + StationName: i.StationName, + Address: i.Address, + Phone: i.Phone, + Status: i.Status, + CreatedAt: i.CreatedAt.Format("2006-01-02 15:04:05"), + UpdatedAt: i.UpdatedAt.Format("2006-01-02 15:04:05"), + }) + } + return &pb.StationListReply{ + List: list, + }, nil +} + +// 站点详情 +func (s *DeliveryService) StationShow(ctx context.Context, req *pb.StationShowRequest) (*pb.StationShowReply, error) { + station, err := s.uc.StationShow(ctx, req.Id) + if err != nil { + return nil, fmt.Errorf("站点查询失败%s", err) + } + return &pb.StationShowReply{ + Id: station.Id, + StationName: station.StationName, + Address: station.Address, + Phone: station.Phone, + Status: station.Status, + }, nil +} + +// 站点删除 +func (s *DeliveryService) DelStation(ctx context.Context, req *pb.DelStationRequest) (*pb.DelStationReply, error) { + station, err := s.uc.DelStation(ctx, req.Id) + if err != nil { + return nil, fmt.Errorf("站点删除失败%s", err) + } + s.log.Warnf("站点删除成功%s", station) + return &pb.DelStationReply{ + Msg: "站点删除成功", + }, nil +} + +// 站点修改 +func (s *DeliveryService) UpdateStation(ctx context.Context, req *pb.UpdateStationRequest) (*pb.UpdateStationReply, error) { + station, err := s.uc.UpdateStation(ctx, req.Id, req.Status, req.StationName, req.Address, req.Phone) + if err != nil { + return nil, fmt.Errorf("站点修改失败%s", err) + } + s.log.Warnf("站点修改成功%s", station) + return &pb.UpdateStationReply{ + Msg: "站点修改成功", + }, nil +} diff --git a/internal/service/order.go b/internal/service/order.go index 62bff325b748708a611aa2d2e2d876daf2a4cf21..8581ab0d5812f008daff10e88fce52211e94d243 100644 --- a/internal/service/order.go +++ b/internal/service/order.go @@ -9,8 +9,13 @@ import ( ) // OrderService 订单服务 +// It implements both gRPC and HTTP server interfaces +// v1.UnimplementedOrderServer 是gRPC服务器接口 +// 该服务将同时注册为HTTP服务和gRPC服务 +// HTTP服务监听配置文件中的http.addr地址 +// gRPC服务监听配置文件中的grpc.addr地址 type OrderService struct { - v1.UnimplementedOrderServer + v1.UnimplementedOrderServer // 实现gRPC服务器接口 uc *biz.OrderUsecase log *log.Helper diff --git a/internal/service/service.go b/internal/service/service.go index 7fb89c134c59a27ed118773ed6e72eb266f1b97f..ed54aaa489d26ab7e4a68d8d84d09a0b3b847478 100644 --- a/internal/service/service.go +++ b/internal/service/service.go @@ -3,4 +3,4 @@ package service import "github.com/google/wire" // ProviderSet is service providers. -var ProviderSet = wire.NewSet(NewGreeterService, NewOrderService) +var ProviderSet = wire.NewSet(NewGreeterService, NewStationService, NewOrderService) diff --git a/openapi.yaml b/openapi.yaml index 68670575160047700c3225ea94aac6d0a8e78dba..3a8be2f374039bee46df21ecd126ee5b5e4b8583 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -3,37 +3,244 @@ openapi: 3.0.3 info: - title: Greeter API - description: The greeting service definition. + title: Delivery API version: 0.0.1 paths: - /helloworld/{name}: + /CreateStation: + post: + tags: + - Delivery + operationId: Delivery_CreateStation + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateStationRequest' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/CreateStationReply' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/Status' + /DelStation: + post: + tags: + - Delivery + operationId: Delivery_DelStation + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/DelStationRequest' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/DelStationReply' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/Status' + /StationList: get: tags: - - Greeter - - subgroup - description: Sends a greeting - operationId: Greeter_SayHello + - Delivery + operationId: Delivery_StationList + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/StationListReply' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/Status' + /StationShow: + get: + tags: + - Delivery + operationId: Delivery_StationShow parameters: - - name: name - in: path - required: true + - name: Id + in: query schema: - type: string + type: integer + format: int32 responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/helloworld.v1.HelloReply' + $ref: '#/components/schemas/StationShowReply' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/Status' + /UpdateStation: + post: + tags: + - Delivery + operationId: Delivery_UpdateStation + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateStationRequest' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateStationReply' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/Status' components: schemas: - helloworld.v1.HelloReply: + CreateStationReply: + type: object + properties: + Msg: + type: string + CreateStationRequest: + type: object + properties: + StationName: + type: string + Address: + type: string + Phone: + type: string + Status: + type: integer + format: int32 + description: 添加站点 + DelStationReply: + type: object + properties: + Msg: + type: string + DelStationRequest: + type: object + properties: + Id: + type: integer + format: int32 + description: 删除站点 + GoogleProtobufAny: + type: object + properties: + '@type': + type: string + description: The type of the serialized message. + additionalProperties: true + description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. + StationListItem: + type: object + properties: + Id: + type: integer + format: int32 + StationName: + type: string + Address: + type: string + Phone: + type: string + Status: + type: integer + format: int32 + CreatedAt: + type: string + UpdatedAt: + type: string + StationListReply: + type: object + properties: + list: + type: array + items: + $ref: '#/components/schemas/StationListItem' + StationShowReply: + type: object + properties: + Id: + type: integer + format: int32 + StationName: + type: string + Address: + type: string + Phone: + type: string + Status: + type: integer + format: int32 + Status: type: object properties: + code: + type: integer + description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. + format: int32 message: type: string - description: The response message containing the greetings + description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. + details: + type: array + items: + $ref: '#/components/schemas/GoogleProtobufAny' + description: A list of messages that carry the error details. There is a common set of message types for APIs to use. + description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' + UpdateStationReply: + type: object + properties: + Msg: + type: string + UpdateStationRequest: + type: object + properties: + Id: + type: integer + format: int32 + StationName: + type: string + Address: + type: string + Phone: + type: string + Status: + type: integer + format: int32 + CreatedAt: + type: string + UpdatedAt: + type: string + description: 修改站点 tags: - - name: Greeter + - name: Delivery