From 6177a05eac2d92baa3df4d2c491241fdcf1f297a Mon Sep 17 00:00:00 2001 From: Fedorov Vladimir Date: Sat, 17 May 2025 01:35:40 +0700 Subject: [PATCH] add getTeam method --- api/main.proto | 29 +++- internal/app/server.go | 4 + proto/main.pb.go | 359 +++++++++++++++++++++++++++++++++++----- proto/main.pb.gw.go | 69 ++++++++ proto/main.swagger.json | 67 +++++++- proto/main_grpc.pb.go | 37 +++++ 6 files changed, 521 insertions(+), 44 deletions(-) diff --git a/api/main.proto b/api/main.proto index babdef5..d3192d2 100644 --- a/api/main.proto +++ b/api/main.proto @@ -19,6 +19,12 @@ service EveningDetective { body: "*" }; } + + rpc GetTeams(GetTeamsReq) returns (GetTeamsRsp) { + option (google.api.http) = { + get: "/teams" + }; + } } message PingReq {} @@ -30,7 +36,7 @@ message AddTeamsReq { } message Team { - string Name = 1; + string name = 1; } message AddTeamsRsp { @@ -39,6 +45,23 @@ message AddTeamsRsp { message TeamFull { int64 id = 1; - string Name = 2; - string Password = 3; + string name = 2; + string password = 3; +} + +message GetTeamsReq {} + +message GetTeamsRsp { + repeated TeamAdvanced teams = 1; +} + +message TeamAdvanced { + int64 id = 1; + string name = 2; + int64 spendTime = 3; + repeated Application applications = 4; +} + +message Application { + string name = 1; } diff --git a/internal/app/server.go b/internal/app/server.go index 72ac563..607b5f2 100644 --- a/internal/app/server.go +++ b/internal/app/server.go @@ -23,3 +23,7 @@ func (s *Server) Ping(_ context.Context, _ *proto.PingReq) (*proto.PingRsp, erro func (s *Server) AddTeams(context.Context, *proto.AddTeamsReq) (*proto.AddTeamsRsp, error) { return nil, status.Errorf(codes.Unimplemented, "method AddTeams not implemented") } + +func (s *Server) GetTeams(context.Context, *proto.GetTeamsReq) (*proto.GetTeamsRsp, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetTeams not implemented") +} diff --git a/proto/main.pb.go b/proto/main.pb.go index df40fb3..ee088ab 100644 --- a/proto/main.pb.go +++ b/proto/main.pb.go @@ -149,7 +149,7 @@ type Team struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` } func (x *Team) Reset() { @@ -244,8 +244,8 @@ type TeamFull struct { unknownFields protoimpl.UnknownFields Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` - Password string `protobuf:"bytes,3,opt,name=Password,proto3" json:"Password,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` } func (x *TeamFull) Reset() { @@ -301,6 +301,209 @@ func (x *TeamFull) GetPassword() string { return "" } +type GetTeamsReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *GetTeamsReq) Reset() { + *x = GetTeamsReq{} + if protoimpl.UnsafeEnabled { + mi := &file_main_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetTeamsReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetTeamsReq) ProtoMessage() {} + +func (x *GetTeamsReq) ProtoReflect() protoreflect.Message { + mi := &file_main_proto_msgTypes[6] + 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 GetTeamsReq.ProtoReflect.Descriptor instead. +func (*GetTeamsReq) Descriptor() ([]byte, []int) { + return file_main_proto_rawDescGZIP(), []int{6} +} + +type GetTeamsRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Teams []*TeamAdvanced `protobuf:"bytes,1,rep,name=teams,proto3" json:"teams,omitempty"` +} + +func (x *GetTeamsRsp) Reset() { + *x = GetTeamsRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_main_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetTeamsRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetTeamsRsp) ProtoMessage() {} + +func (x *GetTeamsRsp) ProtoReflect() protoreflect.Message { + mi := &file_main_proto_msgTypes[7] + 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 GetTeamsRsp.ProtoReflect.Descriptor instead. +func (*GetTeamsRsp) Descriptor() ([]byte, []int) { + return file_main_proto_rawDescGZIP(), []int{7} +} + +func (x *GetTeamsRsp) GetTeams() []*TeamAdvanced { + if x != nil { + return x.Teams + } + return nil +} + +type TeamAdvanced struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + SpendTime int64 `protobuf:"varint,3,opt,name=spendTime,proto3" json:"spendTime,omitempty"` + Applications []*Application `protobuf:"bytes,4,rep,name=applications,proto3" json:"applications,omitempty"` +} + +func (x *TeamAdvanced) Reset() { + *x = TeamAdvanced{} + if protoimpl.UnsafeEnabled { + mi := &file_main_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TeamAdvanced) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TeamAdvanced) ProtoMessage() {} + +func (x *TeamAdvanced) ProtoReflect() protoreflect.Message { + mi := &file_main_proto_msgTypes[8] + 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 TeamAdvanced.ProtoReflect.Descriptor instead. +func (*TeamAdvanced) Descriptor() ([]byte, []int) { + return file_main_proto_rawDescGZIP(), []int{8} +} + +func (x *TeamAdvanced) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *TeamAdvanced) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *TeamAdvanced) GetSpendTime() int64 { + if x != nil { + return x.SpendTime + } + return 0 +} + +func (x *TeamAdvanced) GetApplications() []*Application { + if x != nil { + return x.Applications + } + return nil +} + +type Application struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *Application) Reset() { + *x = Application{} + if protoimpl.UnsafeEnabled { + mi := &file_main_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Application) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Application) ProtoMessage() {} + +func (x *Application) ProtoReflect() protoreflect.Message { + mi := &file_main_proto_msgTypes[9] + 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 Application.ProtoReflect.Descriptor instead. +func (*Application) Descriptor() ([]byte, []int) { + return file_main_proto_rawDescGZIP(), []int{9} +} + +func (x *Application) GetName() string { + if x != nil { + return x.Name + } + return "" +} + var File_main_proto protoreflect.FileDescriptor var file_main_proto_rawDesc = []byte{ @@ -314,32 +517,56 @@ var file_main_proto_rawDesc = []byte{ 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x2e, 0x54, 0x65, 0x61, 0x6d, 0x52, 0x05, 0x74, 0x65, 0x61, 0x6d, 0x73, 0x22, 0x1a, 0x0a, - 0x04, 0x54, 0x65, 0x61, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x46, 0x0a, 0x0b, 0x41, 0x64, 0x64, + 0x04, 0x54, 0x65, 0x61, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x46, 0x0a, 0x0b, 0x41, 0x64, 0x64, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x52, 0x73, 0x70, 0x12, 0x37, 0x0a, 0x05, 0x74, 0x65, 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x2e, 0x54, 0x65, 0x61, 0x6d, 0x46, 0x75, 0x6c, 0x6c, 0x52, 0x05, 0x74, 0x65, 0x61, 0x6d, 0x73, 0x22, 0x4a, 0x0a, 0x08, 0x54, 0x65, 0x61, 0x6d, 0x46, 0x75, 0x6c, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, - 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, - 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x32, 0xd8, 0x01, - 0x0a, 0x10, 0x45, 0x76, 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x65, 0x74, 0x65, 0x63, 0x74, 0x69, - 0x76, 0x65, 0x12, 0x59, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x20, 0x2e, 0x63, 0x72, 0x61, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x0d, 0x0a, + 0x0b, 0x47, 0x65, 0x74, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x22, 0x4a, 0x0a, 0x0b, + 0x47, 0x65, 0x74, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x52, 0x73, 0x70, 0x12, 0x3b, 0x0a, 0x05, 0x74, + 0x65, 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74, 0x65, 0x63, - 0x74, 0x69, 0x76, 0x65, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x20, 0x2e, 0x63, - 0x72, 0x61, 0x62, 0x73, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74, - 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x73, 0x70, 0x22, 0x0d, - 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x07, 0x12, 0x05, 0x2f, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x69, 0x0a, - 0x08, 0x41, 0x64, 0x64, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x12, 0x24, 0x2e, 0x63, 0x72, 0x61, 0x62, - 0x73, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, - 0x69, 0x76, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x1a, + 0x74, 0x69, 0x76, 0x65, 0x2e, 0x54, 0x65, 0x61, 0x6d, 0x41, 0x64, 0x76, 0x61, 0x6e, 0x63, 0x65, + 0x64, 0x52, 0x05, 0x74, 0x65, 0x61, 0x6d, 0x73, 0x22, 0x9a, 0x01, 0x0a, 0x0c, 0x54, 0x65, 0x61, + 0x6d, 0x41, 0x64, 0x76, 0x61, 0x6e, 0x63, 0x65, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, + 0x09, 0x73, 0x70, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x09, 0x73, 0x70, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x48, 0x0a, 0x0c, 0x61, + 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x69, 0x6e, + 0x67, 0x5f, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x6c, + 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x21, 0x0a, 0x0b, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x32, 0xc0, 0x02, 0x0a, 0x10, 0x45, 0x76, 0x65, + 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x65, 0x74, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x12, 0x59, 0x0a, + 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x20, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x65, 0x76, + 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x2e, + 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x20, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, + 0x65, 0x76, 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x69, 0x76, + 0x65, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x73, 0x70, 0x22, 0x0d, 0x82, 0xd3, 0xe4, 0x93, 0x02, + 0x07, 0x12, 0x05, 0x2f, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x69, 0x0a, 0x08, 0x41, 0x64, 0x64, 0x54, + 0x65, 0x61, 0x6d, 0x73, 0x12, 0x24, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x65, 0x76, 0x65, + 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x2e, 0x41, + 0x64, 0x64, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x24, 0x2e, 0x63, 0x72, 0x61, + 0x62, 0x73, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74, 0x65, 0x63, + 0x74, 0x69, 0x76, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x52, 0x73, 0x70, + 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x3a, 0x01, 0x2a, 0x22, 0x06, 0x2f, 0x74, 0x65, + 0x61, 0x6d, 0x73, 0x12, 0x66, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x12, 0x24, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x5f, - 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x54, 0x65, 0x61, - 0x6d, 0x73, 0x52, 0x73, 0x70, 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x3a, 0x01, 0x2a, - 0x22, 0x06, 0x2f, 0x74, 0x65, 0x61, 0x6d, 0x73, 0x42, 0x0b, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x65, 0x61, + 0x6d, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x24, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x65, 0x76, + 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x2e, + 0x47, 0x65, 0x74, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x52, 0x73, 0x70, 0x22, 0x0e, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x08, 0x12, 0x06, 0x2f, 0x74, 0x65, 0x61, 0x6d, 0x73, 0x42, 0x0b, 0x5a, 0x09, 0x70, + 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -354,27 +581,35 @@ func file_main_proto_rawDescGZIP() []byte { return file_main_proto_rawDescData } -var file_main_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_main_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_main_proto_goTypes = []interface{}{ - (*PingReq)(nil), // 0: crabs.evening_detective.PingReq - (*PingRsp)(nil), // 1: crabs.evening_detective.PingRsp - (*AddTeamsReq)(nil), // 2: crabs.evening_detective.AddTeamsReq - (*Team)(nil), // 3: crabs.evening_detective.Team - (*AddTeamsRsp)(nil), // 4: crabs.evening_detective.AddTeamsRsp - (*TeamFull)(nil), // 5: crabs.evening_detective.TeamFull + (*PingReq)(nil), // 0: crabs.evening_detective.PingReq + (*PingRsp)(nil), // 1: crabs.evening_detective.PingRsp + (*AddTeamsReq)(nil), // 2: crabs.evening_detective.AddTeamsReq + (*Team)(nil), // 3: crabs.evening_detective.Team + (*AddTeamsRsp)(nil), // 4: crabs.evening_detective.AddTeamsRsp + (*TeamFull)(nil), // 5: crabs.evening_detective.TeamFull + (*GetTeamsReq)(nil), // 6: crabs.evening_detective.GetTeamsReq + (*GetTeamsRsp)(nil), // 7: crabs.evening_detective.GetTeamsRsp + (*TeamAdvanced)(nil), // 8: crabs.evening_detective.TeamAdvanced + (*Application)(nil), // 9: crabs.evening_detective.Application } var file_main_proto_depIdxs = []int32{ 3, // 0: crabs.evening_detective.AddTeamsReq.teams:type_name -> crabs.evening_detective.Team 5, // 1: crabs.evening_detective.AddTeamsRsp.teams:type_name -> crabs.evening_detective.TeamFull - 0, // 2: crabs.evening_detective.EveningDetective.Ping:input_type -> crabs.evening_detective.PingReq - 2, // 3: crabs.evening_detective.EveningDetective.AddTeams:input_type -> crabs.evening_detective.AddTeamsReq - 1, // 4: crabs.evening_detective.EveningDetective.Ping:output_type -> crabs.evening_detective.PingRsp - 4, // 5: crabs.evening_detective.EveningDetective.AddTeams:output_type -> crabs.evening_detective.AddTeamsRsp - 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 + 8, // 2: crabs.evening_detective.GetTeamsRsp.teams:type_name -> crabs.evening_detective.TeamAdvanced + 9, // 3: crabs.evening_detective.TeamAdvanced.applications:type_name -> crabs.evening_detective.Application + 0, // 4: crabs.evening_detective.EveningDetective.Ping:input_type -> crabs.evening_detective.PingReq + 2, // 5: crabs.evening_detective.EveningDetective.AddTeams:input_type -> crabs.evening_detective.AddTeamsReq + 6, // 6: crabs.evening_detective.EveningDetective.GetTeams:input_type -> crabs.evening_detective.GetTeamsReq + 1, // 7: crabs.evening_detective.EveningDetective.Ping:output_type -> crabs.evening_detective.PingRsp + 4, // 8: crabs.evening_detective.EveningDetective.AddTeams:output_type -> crabs.evening_detective.AddTeamsRsp + 7, // 9: crabs.evening_detective.EveningDetective.GetTeams:output_type -> crabs.evening_detective.GetTeamsRsp + 7, // [7:10] is the sub-list for method output_type + 4, // [4:7] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_main_proto_init() } @@ -455,6 +690,54 @@ func file_main_proto_init() { return nil } } + file_main_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetTeamsReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_main_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetTeamsRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_main_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TeamAdvanced); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_main_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Application); 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{ @@ -462,7 +745,7 @@ func file_main_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_main_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 10, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/main.pb.gw.go b/proto/main.pb.gw.go index 62963ce..2190033 100644 --- a/proto/main.pb.gw.go +++ b/proto/main.pb.gw.go @@ -75,6 +75,24 @@ func local_request_EveningDetective_AddTeams_0(ctx context.Context, marshaler ru } +func request_EveningDetective_GetTeams_0(ctx context.Context, marshaler runtime.Marshaler, client EveningDetectiveClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetTeamsReq + var metadata runtime.ServerMetadata + + msg, err := client.GetTeams(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_EveningDetective_GetTeams_0(ctx context.Context, marshaler runtime.Marshaler, server EveningDetectiveServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetTeamsReq + var metadata runtime.ServerMetadata + + msg, err := server.GetTeams(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterEveningDetectiveHandlerServer registers the http handlers for service EveningDetective to "mux". // UnaryRPC :call EveningDetectiveServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -131,6 +149,31 @@ func RegisterEveningDetectiveHandlerServer(ctx context.Context, mux *runtime.Ser }) + mux.Handle("GET", pattern_EveningDetective_GetTeams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/crabs.evening_detective.EveningDetective/GetTeams", runtime.WithHTTPPathPattern("/teams")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_EveningDetective_GetTeams_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_EveningDetective_GetTeams_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -216,6 +259,28 @@ func RegisterEveningDetectiveHandlerClient(ctx context.Context, mux *runtime.Ser }) + mux.Handle("GET", pattern_EveningDetective_GetTeams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/crabs.evening_detective.EveningDetective/GetTeams", runtime.WithHTTPPathPattern("/teams")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_EveningDetective_GetTeams_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_EveningDetective_GetTeams_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -223,10 +288,14 @@ var ( pattern_EveningDetective_Ping_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"ping"}, "")) pattern_EveningDetective_AddTeams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"teams"}, "")) + + pattern_EveningDetective_GetTeams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"teams"}, "")) ) var ( forward_EveningDetective_Ping_0 = runtime.ForwardResponseMessage forward_EveningDetective_AddTeams_0 = runtime.ForwardResponseMessage + + forward_EveningDetective_GetTeams_0 = runtime.ForwardResponseMessage ) diff --git a/proto/main.swagger.json b/proto/main.swagger.json index e3eb9e6..f0cc2f2 100644 --- a/proto/main.swagger.json +++ b/proto/main.swagger.json @@ -34,6 +34,26 @@ } }, "/teams": { + "get": { + "operationId": "EveningDetective_GetTeams", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/evening_detectiveGetTeamsRsp" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + }, + "tags": [ + "EveningDetective" + ] + }, "post": { "operationId": "EveningDetective_AddTeams", "responses": { @@ -89,17 +109,58 @@ } } }, + "evening_detectiveApplication": { + "type": "object", + "properties": { + "name": { + "type": "string" + } + } + }, + "evening_detectiveGetTeamsRsp": { + "type": "object", + "properties": { + "teams": { + "type": "array", + "items": { + "$ref": "#/definitions/evening_detectiveTeamAdvanced" + } + } + } + }, "evening_detectivePingRsp": { "type": "object" }, "evening_detectiveTeam": { "type": "object", "properties": { - "Name": { + "name": { "type": "string" } } }, + "evening_detectiveTeamAdvanced": { + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "int64" + }, + "name": { + "type": "string" + }, + "spendTime": { + "type": "string", + "format": "int64" + }, + "applications": { + "type": "array", + "items": { + "$ref": "#/definitions/evening_detectiveApplication" + } + } + } + }, "evening_detectiveTeamFull": { "type": "object", "properties": { @@ -107,10 +168,10 @@ "type": "string", "format": "int64" }, - "Name": { + "name": { "type": "string" }, - "Password": { + "password": { "type": "string" } } diff --git a/proto/main_grpc.pb.go b/proto/main_grpc.pb.go index 4934685..91230aa 100644 --- a/proto/main_grpc.pb.go +++ b/proto/main_grpc.pb.go @@ -21,6 +21,7 @@ const _ = grpc.SupportPackageIsVersion7 const ( EveningDetective_Ping_FullMethodName = "/crabs.evening_detective.EveningDetective/Ping" EveningDetective_AddTeams_FullMethodName = "/crabs.evening_detective.EveningDetective/AddTeams" + EveningDetective_GetTeams_FullMethodName = "/crabs.evening_detective.EveningDetective/GetTeams" ) // EveningDetectiveClient is the client API for EveningDetective service. @@ -29,6 +30,7 @@ const ( type EveningDetectiveClient interface { Ping(ctx context.Context, in *PingReq, opts ...grpc.CallOption) (*PingRsp, error) AddTeams(ctx context.Context, in *AddTeamsReq, opts ...grpc.CallOption) (*AddTeamsRsp, error) + GetTeams(ctx context.Context, in *GetTeamsReq, opts ...grpc.CallOption) (*GetTeamsRsp, error) } type eveningDetectiveClient struct { @@ -57,12 +59,22 @@ func (c *eveningDetectiveClient) AddTeams(ctx context.Context, in *AddTeamsReq, return out, nil } +func (c *eveningDetectiveClient) GetTeams(ctx context.Context, in *GetTeamsReq, opts ...grpc.CallOption) (*GetTeamsRsp, error) { + out := new(GetTeamsRsp) + err := c.cc.Invoke(ctx, EveningDetective_GetTeams_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // EveningDetectiveServer is the server API for EveningDetective service. // All implementations must embed UnimplementedEveningDetectiveServer // for forward compatibility type EveningDetectiveServer interface { Ping(context.Context, *PingReq) (*PingRsp, error) AddTeams(context.Context, *AddTeamsReq) (*AddTeamsRsp, error) + GetTeams(context.Context, *GetTeamsReq) (*GetTeamsRsp, error) mustEmbedUnimplementedEveningDetectiveServer() } @@ -76,6 +88,9 @@ func (UnimplementedEveningDetectiveServer) Ping(context.Context, *PingReq) (*Pin func (UnimplementedEveningDetectiveServer) AddTeams(context.Context, *AddTeamsReq) (*AddTeamsRsp, error) { return nil, status.Errorf(codes.Unimplemented, "method AddTeams not implemented") } +func (UnimplementedEveningDetectiveServer) GetTeams(context.Context, *GetTeamsReq) (*GetTeamsRsp, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetTeams not implemented") +} func (UnimplementedEveningDetectiveServer) mustEmbedUnimplementedEveningDetectiveServer() {} // UnsafeEveningDetectiveServer may be embedded to opt out of forward compatibility for this service. @@ -125,6 +140,24 @@ func _EveningDetective_AddTeams_Handler(srv interface{}, ctx context.Context, de return interceptor(ctx, in, info, handler) } +func _EveningDetective_GetTeams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetTeamsReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(EveningDetectiveServer).GetTeams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: EveningDetective_GetTeams_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(EveningDetectiveServer).GetTeams(ctx, req.(*GetTeamsReq)) + } + return interceptor(ctx, in, info, handler) +} + // EveningDetective_ServiceDesc is the grpc.ServiceDesc for EveningDetective service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -140,6 +173,10 @@ var EveningDetective_ServiceDesc = grpc.ServiceDesc{ MethodName: "AddTeams", Handler: _EveningDetective_AddTeams_Handler, }, + { + MethodName: "GetTeams", + Handler: _EveningDetective_GetTeams_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "main.proto",