From c1f1e315699cb015648dadad974f3316dc6be468 Mon Sep 17 00:00:00 2001 From: Evstigneev Denis Date: Fri, 11 Aug 2023 08:58:31 +0300 Subject: [PATCH] rename fields --- handler/handlers.go | 28 +- proto/dashboard.proto | 26 +- proto/go_generate/dashboard.pb.go | 569 ++++++----- proto/go_generate/dashboard.pb.validate.go | 1018 ++++++++++++-------- proto/micro/dashboard_micro.pb.go | 14 +- proto/micro/dashboard_micro_http.pb.go | 38 +- service/client_git/client.go | 16 +- service/client_git/client_test.go | 4 +- service/service.go | 1 + storage/postgres/storage.go | 14 +- storage/postgres/storage_test.go | 20 +- storage/sqlite/storage.go | 14 +- storage/storage.go | 8 +- 13 files changed, 1090 insertions(+), 680 deletions(-) diff --git a/handler/handlers.go b/handler/handlers.go index 1021fdf..a9cbfc4 100644 --- a/handler/handlers.go +++ b/handler/handlers.go @@ -24,7 +24,7 @@ type Handler struct { protojson.UnmarshalOptions git cligit.Client - chanUrl chan *pb.AddPackageRsp + chanUrl chan *pb.AddPackageReq } func (h *Handler) ListPackage(w http.ResponseWriter, r *http.Request) { @@ -59,20 +59,20 @@ func (h *Handler) UpdatePackage(w http.ResponseWriter, r *http.Request) { return } - rsp := new(pb.UpdatePackageRsp) - if err = h.Unmarshal(all, rsp); err != nil { + req := new(pb.UpdatePackageReq) + if err = h.Unmarshal(all, req); err != nil { logger.Error(ctx, err) h.writer.Response(ctx, w, NewUnmarshalError(err)) return } - if err = rsp.Validate(); err != nil { + if err = req.Validate(); err != nil { logger.Error(ctx, err) h.writer.Response(ctx, w, NewValidationError(err)) return } - if err = h.store.UpdatePackage(ctx, rsp); err != nil { + if err = h.store.UpdatePackage(ctx, req); err != nil { logger.Error(ctx, err) h.writer.Response(ctx, w, NewInternalError(err)) return @@ -94,20 +94,20 @@ func (h *Handler) AddComment(w http.ResponseWriter, r *http.Request) { return } - rsp := new(pb.AddCommentRsp) - if err = h.Unmarshal(all, rsp); err != nil { + req := new(pb.AddCommentReq) + if err = h.Unmarshal(all, req); err != nil { logger.Error(ctx, err) h.writer.Response(ctx, w, NewUnmarshalError(err)) return } - if err = rsp.Validate(); err != nil { + if err = req.Validate(); err != nil { logger.Error(ctx, err) h.writer.Response(ctx, w, NewValidationError(err)) return } - if err = h.store.AddComment(ctx, rsp); err != nil { + if err = h.store.AddComment(ctx, req); err != nil { logger.Error(ctx, err) h.writer.Response(ctx, w, NewInternalError(err)) return @@ -129,7 +129,7 @@ func (h *Handler) AddPackage(w http.ResponseWriter, r *http.Request) { return } - req := new(pb.AddPackageRsp) + req := new(pb.AddPackageReq) if err = h.Unmarshal(all, req); err != nil { logger.Error(ctx, err) h.writer.Response(ctx, w, NewUnmarshalError(err)) @@ -151,6 +151,14 @@ func (h *Handler) AddPackage(w http.ResponseWriter, r *http.Request) { logger.Debug(ctx, "Success finish addPackage") } +func (h *Handler) GetModule(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + logger := h.svc.Logger() + logger.Debug(ctx, "Start GetModule") + + //rsp := new(pb.GetModuleRsp) +} + func NewHandler(svc micro.Service, w writer, client cligit.Client) *Handler { h := &Handler{ svc: svc, diff --git a/proto/dashboard.proto b/proto/dashboard.proto index d8cf391..5dc2a57 100644 --- a/proto/dashboard.proto +++ b/proto/dashboard.proto @@ -9,9 +9,10 @@ import "google/protobuf/wrappers.proto"; service DashboardService { rpc ListPackage(ListPackageReq) returns (ListPackageRsp) {}; - rpc UpdatePackage(UpdatePackageRsp) returns (UpdatePackageReq) {}; - rpc AddComment(AddCommentRsp) returns (AddCommentReq) {}; - rpc AddPackage(AddPackageRsp) returns (AddPackageReq) {}; + rpc UpdatePackage(UpdatePackageReq) returns (UpdatePackageRsp) {}; + rpc AddComment(AddCommentReq) returns (AddCommentRsp) {}; + rpc AddPackage(AddPackageReq) returns (AddPackageRsp) {}; + rpc GetModule(GetModuleReq) returns (GetModuleRsp) {}; }; message ErrorRsp { @@ -62,29 +63,36 @@ message ListPackageRsp{ repeated Package packages = 1; } -message UpdatePackageRsp { +message UpdatePackageReq { google.protobuf.UInt64Value id = 1 [(validate.rules).message.required = true]; google.protobuf.StringValue name = 2 [(validate.rules).message.required = true]; google.protobuf.StringValue url = 3 [(validate.rules).message.required = true]; repeated uint64 modules = 4 ; repeated uint64 issues = 5 ; } -message UpdatePackageReq { +message UpdatePackageRsp { uint64 id = 1 [(validate.rules).uint64.gt = 0]; } -message AddCommentRsp { +message AddCommentReq { google.protobuf.UInt64Value idPackage = 1 [(validate.rules).message.required = true]; string text = 2; } -message AddCommentReq { +message AddCommentRsp { uint64 id = 1 [(validate.rules).uint64.gt = 0]; } -message AddPackageRsp { +message AddPackageReq { google.protobuf.StringValue name = 1 [(validate.rules).message.required = true]; google.protobuf.StringValue url = 2 [(validate.rules).message.required = true]; repeated uint64 modules = 3; } -message AddPackageReq{} \ No newline at end of file +message AddPackageRsp{} + +message GetModuleReq { + repeated uint64 modules_id = 1 ; +} +message GetModuleRsp { + repeated Module modules = 1 ; +} \ No newline at end of file diff --git a/proto/go_generate/dashboard.pb.go b/proto/go_generate/dashboard.pb.go index 51adab9..c893678 100644 --- a/proto/go_generate/dashboard.pb.go +++ b/proto/go_generate/dashboard.pb.go @@ -541,7 +541,7 @@ func (x *ListPackageRsp) GetPackages() []*Package { return nil } -type UpdatePackageRsp struct { +type UpdatePackageReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -553,85 +553,10 @@ type UpdatePackageRsp struct { Issues []uint64 `protobuf:"varint,5,rep,packed,name=issues,proto3" json:"issues,omitempty"` } -func (x *UpdatePackageRsp) Reset() { - *x = UpdatePackageRsp{} - if protoimpl.UnsafeEnabled { - mi := &file_dashboard_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UpdatePackageRsp) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePackageRsp) ProtoMessage() {} - -func (x *UpdatePackageRsp) ProtoReflect() protoreflect.Message { - mi := &file_dashboard_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 UpdatePackageRsp.ProtoReflect.Descriptor instead. -func (*UpdatePackageRsp) Descriptor() ([]byte, []int) { - return file_dashboard_proto_rawDescGZIP(), []int{8} -} - -func (x *UpdatePackageRsp) GetId() *wrapperspb.UInt64Value { - if x != nil { - return x.Id - } - return nil -} - -func (x *UpdatePackageRsp) GetName() *wrapperspb.StringValue { - if x != nil { - return x.Name - } - return nil -} - -func (x *UpdatePackageRsp) GetUrl() *wrapperspb.StringValue { - if x != nil { - return x.Url - } - return nil -} - -func (x *UpdatePackageRsp) GetModules() []uint64 { - if x != nil { - return x.Modules - } - return nil -} - -func (x *UpdatePackageRsp) GetIssues() []uint64 { - if x != nil { - return x.Issues - } - return nil -} - -type UpdatePackageReq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` -} - func (x *UpdatePackageReq) Reset() { *x = UpdatePackageReq{} if protoimpl.UnsafeEnabled { - mi := &file_dashboard_proto_msgTypes[9] + mi := &file_dashboard_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -644,7 +569,7 @@ func (x *UpdatePackageReq) String() string { func (*UpdatePackageReq) ProtoMessage() {} func (x *UpdatePackageReq) ProtoReflect() protoreflect.Message { - mi := &file_dashboard_proto_msgTypes[9] + mi := &file_dashboard_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -657,42 +582,69 @@ func (x *UpdatePackageReq) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdatePackageReq.ProtoReflect.Descriptor instead. func (*UpdatePackageReq) Descriptor() ([]byte, []int) { - return file_dashboard_proto_rawDescGZIP(), []int{9} + return file_dashboard_proto_rawDescGZIP(), []int{8} } -func (x *UpdatePackageReq) GetId() uint64 { +func (x *UpdatePackageReq) GetId() *wrapperspb.UInt64Value { if x != nil { return x.Id } - return 0 + return nil } -type AddCommentRsp struct { +func (x *UpdatePackageReq) GetName() *wrapperspb.StringValue { + if x != nil { + return x.Name + } + return nil +} + +func (x *UpdatePackageReq) GetUrl() *wrapperspb.StringValue { + if x != nil { + return x.Url + } + return nil +} + +func (x *UpdatePackageReq) GetModules() []uint64 { + if x != nil { + return x.Modules + } + return nil +} + +func (x *UpdatePackageReq) GetIssues() []uint64 { + if x != nil { + return x.Issues + } + return nil +} + +type UpdatePackageRsp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - IdPackage *wrapperspb.UInt64Value `protobuf:"bytes,1,opt,name=idPackage,proto3" json:"idPackage,omitempty"` - Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"` + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` } -func (x *AddCommentRsp) Reset() { - *x = AddCommentRsp{} +func (x *UpdatePackageRsp) Reset() { + *x = UpdatePackageRsp{} if protoimpl.UnsafeEnabled { - mi := &file_dashboard_proto_msgTypes[10] + mi := &file_dashboard_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *AddCommentRsp) String() string { +func (x *UpdatePackageRsp) String() string { return protoimpl.X.MessageStringOf(x) } -func (*AddCommentRsp) ProtoMessage() {} +func (*UpdatePackageRsp) ProtoMessage() {} -func (x *AddCommentRsp) ProtoReflect() protoreflect.Message { - mi := &file_dashboard_proto_msgTypes[10] +func (x *UpdatePackageRsp) ProtoReflect() protoreflect.Message { + mi := &file_dashboard_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -703,23 +655,16 @@ func (x *AddCommentRsp) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use AddCommentRsp.ProtoReflect.Descriptor instead. -func (*AddCommentRsp) Descriptor() ([]byte, []int) { - return file_dashboard_proto_rawDescGZIP(), []int{10} +// Deprecated: Use UpdatePackageRsp.ProtoReflect.Descriptor instead. +func (*UpdatePackageRsp) Descriptor() ([]byte, []int) { + return file_dashboard_proto_rawDescGZIP(), []int{9} } -func (x *AddCommentRsp) GetIdPackage() *wrapperspb.UInt64Value { +func (x *UpdatePackageRsp) GetId() uint64 { if x != nil { - return x.IdPackage + return x.Id } - return nil -} - -func (x *AddCommentRsp) GetText() string { - if x != nil { - return x.Text - } - return "" + return 0 } type AddCommentReq struct { @@ -727,13 +672,14 @@ type AddCommentReq struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + IdPackage *wrapperspb.UInt64Value `protobuf:"bytes,1,opt,name=idPackage,proto3" json:"idPackage,omitempty"` + Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"` } func (x *AddCommentReq) Reset() { *x = AddCommentReq{} if protoimpl.UnsafeEnabled { - mi := &file_dashboard_proto_msgTypes[11] + mi := &file_dashboard_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -746,7 +692,7 @@ func (x *AddCommentReq) String() string { func (*AddCommentReq) ProtoMessage() {} func (x *AddCommentReq) ProtoReflect() protoreflect.Message { - mi := &file_dashboard_proto_msgTypes[11] + mi := &file_dashboard_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -759,43 +705,48 @@ func (x *AddCommentReq) ProtoReflect() protoreflect.Message { // Deprecated: Use AddCommentReq.ProtoReflect.Descriptor instead. func (*AddCommentReq) Descriptor() ([]byte, []int) { - return file_dashboard_proto_rawDescGZIP(), []int{11} + return file_dashboard_proto_rawDescGZIP(), []int{10} } -func (x *AddCommentReq) GetId() uint64 { +func (x *AddCommentReq) GetIdPackage() *wrapperspb.UInt64Value { if x != nil { - return x.Id + return x.IdPackage } - return 0 + return nil } -type AddPackageRsp struct { +func (x *AddCommentReq) GetText() string { + if x != nil { + return x.Text + } + return "" +} + +type AddCommentRsp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Name *wrapperspb.StringValue `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Url *wrapperspb.StringValue `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` - Modules []uint64 `protobuf:"varint,3,rep,packed,name=modules,proto3" json:"modules,omitempty"` + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` } -func (x *AddPackageRsp) Reset() { - *x = AddPackageRsp{} +func (x *AddCommentRsp) Reset() { + *x = AddCommentRsp{} if protoimpl.UnsafeEnabled { - mi := &file_dashboard_proto_msgTypes[12] + mi := &file_dashboard_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *AddPackageRsp) String() string { +func (x *AddCommentRsp) String() string { return protoimpl.X.MessageStringOf(x) } -func (*AddPackageRsp) ProtoMessage() {} +func (*AddCommentRsp) ProtoMessage() {} -func (x *AddPackageRsp) ProtoReflect() protoreflect.Message { - mi := &file_dashboard_proto_msgTypes[12] +func (x *AddCommentRsp) ProtoReflect() protoreflect.Message { + mi := &file_dashboard_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -806,42 +757,32 @@ func (x *AddPackageRsp) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use AddPackageRsp.ProtoReflect.Descriptor instead. -func (*AddPackageRsp) Descriptor() ([]byte, []int) { - return file_dashboard_proto_rawDescGZIP(), []int{12} +// Deprecated: Use AddCommentRsp.ProtoReflect.Descriptor instead. +func (*AddCommentRsp) Descriptor() ([]byte, []int) { + return file_dashboard_proto_rawDescGZIP(), []int{11} } -func (x *AddPackageRsp) GetName() *wrapperspb.StringValue { +func (x *AddCommentRsp) GetId() uint64 { if x != nil { - return x.Name + return x.Id } - return nil -} - -func (x *AddPackageRsp) GetUrl() *wrapperspb.StringValue { - if x != nil { - return x.Url - } - return nil -} - -func (x *AddPackageRsp) GetModules() []uint64 { - if x != nil { - return x.Modules - } - return nil + return 0 } type AddPackageReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Name *wrapperspb.StringValue `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Url *wrapperspb.StringValue `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` + Modules []uint64 `protobuf:"varint,3,rep,packed,name=modules,proto3" json:"modules,omitempty"` } func (x *AddPackageReq) Reset() { *x = AddPackageReq{} if protoimpl.UnsafeEnabled { - mi := &file_dashboard_proto_msgTypes[13] + mi := &file_dashboard_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -854,7 +795,7 @@ func (x *AddPackageReq) String() string { func (*AddPackageReq) ProtoMessage() {} func (x *AddPackageReq) ProtoReflect() protoreflect.Message { - mi := &file_dashboard_proto_msgTypes[13] + mi := &file_dashboard_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -867,9 +808,162 @@ func (x *AddPackageReq) ProtoReflect() protoreflect.Message { // Deprecated: Use AddPackageReq.ProtoReflect.Descriptor instead. func (*AddPackageReq) Descriptor() ([]byte, []int) { + return file_dashboard_proto_rawDescGZIP(), []int{12} +} + +func (x *AddPackageReq) GetName() *wrapperspb.StringValue { + if x != nil { + return x.Name + } + return nil +} + +func (x *AddPackageReq) GetUrl() *wrapperspb.StringValue { + if x != nil { + return x.Url + } + return nil +} + +func (x *AddPackageReq) GetModules() []uint64 { + if x != nil { + return x.Modules + } + return nil +} + +type AddPackageRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *AddPackageRsp) Reset() { + *x = AddPackageRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_dashboard_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddPackageRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddPackageRsp) ProtoMessage() {} + +func (x *AddPackageRsp) ProtoReflect() protoreflect.Message { + mi := &file_dashboard_proto_msgTypes[13] + 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 AddPackageRsp.ProtoReflect.Descriptor instead. +func (*AddPackageRsp) Descriptor() ([]byte, []int) { return file_dashboard_proto_rawDescGZIP(), []int{13} } +type GetModuleReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ModulesId []uint64 `protobuf:"varint,1,rep,packed,name=modules_id,json=modulesId,proto3" json:"modules_id,omitempty"` +} + +func (x *GetModuleReq) Reset() { + *x = GetModuleReq{} + if protoimpl.UnsafeEnabled { + mi := &file_dashboard_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetModuleReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetModuleReq) ProtoMessage() {} + +func (x *GetModuleReq) ProtoReflect() protoreflect.Message { + mi := &file_dashboard_proto_msgTypes[14] + 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 GetModuleReq.ProtoReflect.Descriptor instead. +func (*GetModuleReq) Descriptor() ([]byte, []int) { + return file_dashboard_proto_rawDescGZIP(), []int{14} +} + +func (x *GetModuleReq) GetModulesId() []uint64 { + if x != nil { + return x.ModulesId + } + return nil +} + +type GetModuleRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Modules []*Module `protobuf:"bytes,1,rep,name=modules,proto3" json:"modules,omitempty"` +} + +func (x *GetModuleRsp) Reset() { + *x = GetModuleRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_dashboard_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetModuleRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetModuleRsp) ProtoMessage() {} + +func (x *GetModuleRsp) ProtoReflect() protoreflect.Message { + mi := &file_dashboard_proto_msgTypes[15] + 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 GetModuleRsp.ProtoReflect.Descriptor instead. +func (*GetModuleRsp) Descriptor() ([]byte, []int) { + return file_dashboard_proto_rawDescGZIP(), []int{15} +} + +func (x *GetModuleRsp) GetModules() []*Module { + if x != nil { + return x.Modules + } + return nil +} + var File_dashboard_proto protoreflect.FileDescriptor var file_dashboard_proto_rawDesc = []byte{ @@ -932,7 +1026,7 @@ var file_dashboard_proto_rawDesc = []byte{ 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x08, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x22, 0xf2, 0x01, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, - 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x73, 0x70, 0x12, 0x36, 0x0a, 0x02, 0x69, 0x64, 0x18, + 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x36, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x02, 0x69, @@ -947,19 +1041,19 @@ var file_dashboard_proto_rawDesc = []byte{ 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x04, 0x52, 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x73, 0x75, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x04, 0x52, 0x06, 0x69, 0x73, 0x73, 0x75, 0x65, 0x73, 0x22, 0x2b, 0x0a, 0x10, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x17, 0x0a, + 0x61, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x73, 0x70, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, 0x02, 0x69, 0x64, 0x22, 0x69, 0x0a, 0x0d, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6d, - 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x73, 0x70, 0x12, 0x44, 0x0a, 0x09, 0x69, 0x64, 0x50, 0x61, 0x63, + 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x12, 0x44, 0x0a, 0x09, 0x69, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x09, 0x69, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x28, 0x0a, 0x0d, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, - 0x65, 0x71, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, + 0x73, 0x70, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, 0x02, 0x69, 0x64, 0x22, 0x9f, 0x01, 0x0a, 0x0d, - 0x41, 0x64, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x73, 0x70, 0x12, 0x3a, 0x0a, + 0x41, 0x64, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x3a, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, @@ -969,29 +1063,39 @@ var file_dashboard_proto_rawDesc = []byte{ 0x61, 0x6c, 0x75, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x04, 0x52, 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x22, 0x0f, 0x0a, - 0x0d, 0x41, 0x64, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x32, 0x8e, - 0x02, 0x0a, 0x10, 0x44, 0x61, 0x73, 0x68, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x12, 0x3d, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, - 0x67, 0x65, 0x12, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, - 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x73, 0x70, - 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, - 0x61, 0x67, 0x65, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x73, 0x70, 0x1a, 0x17, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, - 0x67, 0x65, 0x52, 0x65, 0x71, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x43, 0x6f, - 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, - 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x73, 0x70, 0x1a, 0x14, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, - 0x71, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, - 0x65, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x61, 0x63, - 0x6b, 0x61, 0x67, 0x65, 0x52, 0x73, 0x70, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, - 0x41, 0x64, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x22, 0x00, 0x42, - 0x44, 0x5a, 0x42, 0x67, 0x6f, 0x2e, 0x75, 0x6e, 0x69, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2e, 0x6f, - 0x72, 0x67, 0x2f, 0x75, 0x6e, 0x69, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2d, 0x6f, 0x72, 0x67, 0x2f, - 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, - 0x5f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x3b, 0x67, 0x6f, 0x5f, 0x67, 0x65, 0x6e, - 0x65, 0x72, 0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x0d, 0x41, 0x64, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x73, 0x70, 0x22, 0x2d, + 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1d, + 0x0a, 0x0a, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x04, 0x52, 0x09, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x49, 0x64, 0x22, 0x37, 0x0a, + 0x0c, 0x47, 0x65, 0x74, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x73, 0x70, 0x12, 0x27, 0x0a, + 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x07, 0x6d, + 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x32, 0xc7, 0x02, 0x0a, 0x10, 0x44, 0x61, 0x73, 0x68, 0x62, + 0x6f, 0x61, 0x72, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3d, 0x0a, 0x0b, 0x4c, + 0x69, 0x73, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x15, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, + 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, + 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x73, 0x70, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0d, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x17, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, + 0x65, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x73, 0x70, 0x22, 0x00, 0x12, + 0x3a, 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x14, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, + 0x52, 0x65, 0x71, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x43, + 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x73, 0x70, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x0a, 0x41, + 0x64, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x1a, + 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x61, + 0x67, 0x65, 0x52, 0x73, 0x70, 0x22, 0x00, 0x12, 0x37, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x4d, 0x6f, + 0x64, 0x75, 0x6c, 0x65, 0x12, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, + 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x73, 0x70, 0x22, 0x00, + 0x42, 0x44, 0x5a, 0x42, 0x67, 0x6f, 0x2e, 0x75, 0x6e, 0x69, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2e, + 0x6f, 0x72, 0x67, 0x2f, 0x75, 0x6e, 0x69, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2d, 0x6f, 0x72, 0x67, + 0x2f, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, + 0x6f, 0x5f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x3b, 0x67, 0x6f, 0x5f, 0x67, 0x65, + 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1006,7 +1110,7 @@ func file_dashboard_proto_rawDescGZIP() []byte { return file_dashboard_proto_rawDescData } -var file_dashboard_proto_msgTypes = make([]protoimpl.MessageInfo, 14) +var file_dashboard_proto_msgTypes = make([]protoimpl.MessageInfo, 16) var file_dashboard_proto_goTypes = []interface{}{ (*ErrorRsp)(nil), // 0: proto.ErrorRsp (*Error)(nil), // 1: proto.Error @@ -1016,37 +1120,42 @@ var file_dashboard_proto_goTypes = []interface{}{ (*Comment)(nil), // 5: proto.Comment (*ListPackageReq)(nil), // 6: proto.ListPackageReq (*ListPackageRsp)(nil), // 7: proto.ListPackageRsp - (*UpdatePackageRsp)(nil), // 8: proto.UpdatePackageRsp - (*UpdatePackageReq)(nil), // 9: proto.UpdatePackageReq - (*AddCommentRsp)(nil), // 10: proto.AddCommentRsp - (*AddCommentReq)(nil), // 11: proto.AddCommentReq - (*AddPackageRsp)(nil), // 12: proto.AddPackageRsp - (*AddPackageReq)(nil), // 13: proto.AddPackageReq - (*wrapperspb.UInt64Value)(nil), // 14: google.protobuf.UInt64Value - (*wrapperspb.StringValue)(nil), // 15: google.protobuf.StringValue + (*UpdatePackageReq)(nil), // 8: proto.UpdatePackageReq + (*UpdatePackageRsp)(nil), // 9: proto.UpdatePackageRsp + (*AddCommentReq)(nil), // 10: proto.AddCommentReq + (*AddCommentRsp)(nil), // 11: proto.AddCommentRsp + (*AddPackageReq)(nil), // 12: proto.AddPackageReq + (*AddPackageRsp)(nil), // 13: proto.AddPackageRsp + (*GetModuleReq)(nil), // 14: proto.GetModuleReq + (*GetModuleRsp)(nil), // 15: proto.GetModuleRsp + (*wrapperspb.UInt64Value)(nil), // 16: google.protobuf.UInt64Value + (*wrapperspb.StringValue)(nil), // 17: google.protobuf.StringValue } var file_dashboard_proto_depIdxs = []int32{ 1, // 0: proto.ErrorRsp.error:type_name -> proto.Error 2, // 1: proto.ListPackageRsp.packages:type_name -> proto.Package - 14, // 2: proto.UpdatePackageRsp.id:type_name -> google.protobuf.UInt64Value - 15, // 3: proto.UpdatePackageRsp.name:type_name -> google.protobuf.StringValue - 15, // 4: proto.UpdatePackageRsp.url:type_name -> google.protobuf.StringValue - 14, // 5: proto.AddCommentRsp.idPackage:type_name -> google.protobuf.UInt64Value - 15, // 6: proto.AddPackageRsp.name:type_name -> google.protobuf.StringValue - 15, // 7: proto.AddPackageRsp.url:type_name -> google.protobuf.StringValue - 6, // 8: proto.DashboardService.ListPackage:input_type -> proto.ListPackageReq - 8, // 9: proto.DashboardService.UpdatePackage:input_type -> proto.UpdatePackageRsp - 10, // 10: proto.DashboardService.AddComment:input_type -> proto.AddCommentRsp - 12, // 11: proto.DashboardService.AddPackage:input_type -> proto.AddPackageRsp - 7, // 12: proto.DashboardService.ListPackage:output_type -> proto.ListPackageRsp - 9, // 13: proto.DashboardService.UpdatePackage:output_type -> proto.UpdatePackageReq - 11, // 14: proto.DashboardService.AddComment:output_type -> proto.AddCommentReq - 13, // 15: proto.DashboardService.AddPackage:output_type -> proto.AddPackageReq - 12, // [12:16] is the sub-list for method output_type - 8, // [8:12] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name + 16, // 2: proto.UpdatePackageReq.id:type_name -> google.protobuf.UInt64Value + 17, // 3: proto.UpdatePackageReq.name:type_name -> google.protobuf.StringValue + 17, // 4: proto.UpdatePackageReq.url:type_name -> google.protobuf.StringValue + 16, // 5: proto.AddCommentReq.idPackage:type_name -> google.protobuf.UInt64Value + 17, // 6: proto.AddPackageReq.name:type_name -> google.protobuf.StringValue + 17, // 7: proto.AddPackageReq.url:type_name -> google.protobuf.StringValue + 3, // 8: proto.GetModuleRsp.modules:type_name -> proto.Module + 6, // 9: proto.DashboardService.ListPackage:input_type -> proto.ListPackageReq + 8, // 10: proto.DashboardService.UpdatePackage:input_type -> proto.UpdatePackageReq + 10, // 11: proto.DashboardService.AddComment:input_type -> proto.AddCommentReq + 12, // 12: proto.DashboardService.AddPackage:input_type -> proto.AddPackageReq + 14, // 13: proto.DashboardService.GetModule:input_type -> proto.GetModuleReq + 7, // 14: proto.DashboardService.ListPackage:output_type -> proto.ListPackageRsp + 9, // 15: proto.DashboardService.UpdatePackage:output_type -> proto.UpdatePackageRsp + 11, // 16: proto.DashboardService.AddComment:output_type -> proto.AddCommentRsp + 13, // 17: proto.DashboardService.AddPackage:output_type -> proto.AddPackageRsp + 15, // 18: proto.DashboardService.GetModule:output_type -> proto.GetModuleRsp + 14, // [14:19] is the sub-list for method output_type + 9, // [9:14] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name } func init() { file_dashboard_proto_init() } @@ -1152,18 +1261,6 @@ func file_dashboard_proto_init() { } } file_dashboard_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdatePackageRsp); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_dashboard_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*UpdatePackageReq); i { case 0: return &v.state @@ -1175,8 +1272,8 @@ func file_dashboard_proto_init() { return nil } } - file_dashboard_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AddCommentRsp); i { + file_dashboard_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdatePackageRsp); i { case 0: return &v.state case 1: @@ -1187,7 +1284,7 @@ func file_dashboard_proto_init() { return nil } } - file_dashboard_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_dashboard_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*AddCommentReq); i { case 0: return &v.state @@ -1199,8 +1296,20 @@ func file_dashboard_proto_init() { return nil } } + file_dashboard_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddCommentRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } file_dashboard_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AddPackageRsp); i { + switch v := v.(*AddPackageReq); i { case 0: return &v.state case 1: @@ -1212,7 +1321,31 @@ func file_dashboard_proto_init() { } } file_dashboard_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AddPackageReq); i { + switch v := v.(*AddPackageRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dashboard_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetModuleReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dashboard_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetModuleRsp); i { case 0: return &v.state case 1: @@ -1230,7 +1363,7 @@ func file_dashboard_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_dashboard_proto_rawDesc, NumEnums: 0, - NumMessages: 14, + NumMessages: 16, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/go_generate/dashboard.pb.validate.go b/proto/go_generate/dashboard.pb.validate.go index a98f164..92131ab 100644 --- a/proto/go_generate/dashboard.pb.validate.go +++ b/proto/go_generate/dashboard.pb.validate.go @@ -1062,226 +1062,6 @@ var _ interface { ErrorName() string } = ListPackageRspValidationError{} -// Validate checks the field values on UpdatePackageRsp with the rules defined -// in the proto definition for this message. If any rules are violated, the -// first error encountered is returned, or nil if there are no violations. -func (m *UpdatePackageRsp) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePackageRsp with the rules -// defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// UpdatePackageRspMultiError, or nil if none found. -func (m *UpdatePackageRsp) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePackageRsp) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if m.GetId() == nil { - err := UpdatePackageRspValidationError{ - field: "Id", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if all { - switch v := interface{}(m.GetId()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePackageRspValidationError{ - field: "Id", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePackageRspValidationError{ - field: "Id", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetId()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePackageRspValidationError{ - field: "Id", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if m.GetName() == nil { - err := UpdatePackageRspValidationError{ - field: "Name", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if all { - switch v := interface{}(m.GetName()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePackageRspValidationError{ - field: "Name", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePackageRspValidationError{ - field: "Name", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetName()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePackageRspValidationError{ - field: "Name", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if m.GetUrl() == nil { - err := UpdatePackageRspValidationError{ - field: "Url", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if all { - switch v := interface{}(m.GetUrl()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePackageRspValidationError{ - field: "Url", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePackageRspValidationError{ - field: "Url", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUrl()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePackageRspValidationError{ - field: "Url", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePackageRspMultiError(errors) - } - - return nil -} - -// UpdatePackageRspMultiError is an error wrapping multiple validation errors -// returned by UpdatePackageRsp.ValidateAll() if the designated constraints -// aren't met. -type UpdatePackageRspMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePackageRspMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m UpdatePackageRspMultiError) AllErrors() []error { return m } - -// UpdatePackageRspValidationError is the validation error returned by -// UpdatePackageRsp.Validate if the designated constraints aren't met. -type UpdatePackageRspValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePackageRspValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePackageRspValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePackageRspValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePackageRspValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePackageRspValidationError) ErrorName() string { return "UpdatePackageRspValidationError" } - -// Error satisfies the builtin error interface -func (e UpdatePackageRspValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sUpdatePackageRsp.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePackageRspValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePackageRspValidationError{} - // Validate checks the field values on UpdatePackageReq with the rules defined // in the proto definition for this message. If any rules are violated, the // first error encountered is returned, or nil if there are no violations. @@ -1304,10 +1084,10 @@ func (m *UpdatePackageReq) validate(all bool) error { var errors []error - if m.GetId() <= 0 { + if m.GetId() == nil { err := UpdatePackageReqValidationError{ field: "Id", - reason: "value must be greater than 0", + reason: "value is required", } if !all { return err @@ -1315,6 +1095,115 @@ func (m *UpdatePackageReq) validate(all bool) error { errors = append(errors, err) } + if all { + switch v := interface{}(m.GetId()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePackageReqValidationError{ + field: "Id", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePackageReqValidationError{ + field: "Id", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetId()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePackageReqValidationError{ + field: "Id", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if m.GetName() == nil { + err := UpdatePackageReqValidationError{ + field: "Name", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetName()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePackageReqValidationError{ + field: "Name", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePackageReqValidationError{ + field: "Name", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetName()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePackageReqValidationError{ + field: "Name", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if m.GetUrl() == nil { + err := UpdatePackageReqValidationError{ + field: "Url", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetUrl()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePackageReqValidationError{ + field: "Url", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePackageReqValidationError{ + field: "Url", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUrl()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePackageReqValidationError{ + field: "Url", + reason: "embedded message failed validation", + cause: err, + } + } + } + if len(errors) > 0 { return UpdatePackageReqMultiError(errors) } @@ -1393,32 +1282,32 @@ var _ interface { ErrorName() string } = UpdatePackageReqValidationError{} -// Validate checks the field values on AddCommentRsp with the rules defined in -// the proto definition for this message. If any rules are violated, the first -// error encountered is returned, or nil if there are no violations. -func (m *AddCommentRsp) Validate() error { +// Validate checks the field values on UpdatePackageRsp with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *UpdatePackageRsp) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on AddCommentRsp with the rules defined -// in the proto definition for this message. If any rules are violated, the -// result is a list of violation errors wrapped in AddCommentRspMultiError, or -// nil if none found. -func (m *AddCommentRsp) ValidateAll() error { +// ValidateAll checks the field values on UpdatePackageRsp with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdatePackageRspMultiError, or nil if none found. +func (m *UpdatePackageRsp) ValidateAll() error { return m.validate(true) } -func (m *AddCommentRsp) validate(all bool) error { +func (m *UpdatePackageRsp) validate(all bool) error { if m == nil { return nil } var errors []error - if m.GetIdPackage() == nil { - err := AddCommentRspValidationError{ - field: "IdPackage", - reason: "value is required", + if m.GetId() <= 0 { + err := UpdatePackageRspValidationError{ + field: "Id", + reason: "value must be greater than 0", } if !all { return err @@ -1426,51 +1315,20 @@ func (m *AddCommentRsp) validate(all bool) error { errors = append(errors, err) } - if all { - switch v := interface{}(m.GetIdPackage()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, AddCommentRspValidationError{ - field: "IdPackage", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, AddCommentRspValidationError{ - field: "IdPackage", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetIdPackage()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return AddCommentRspValidationError{ - field: "IdPackage", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for Text - if len(errors) > 0 { - return AddCommentRspMultiError(errors) + return UpdatePackageRspMultiError(errors) } return nil } -// AddCommentRspMultiError is an error wrapping multiple validation errors -// returned by AddCommentRsp.ValidateAll() if the designated constraints +// UpdatePackageRspMultiError is an error wrapping multiple validation errors +// returned by UpdatePackageRsp.ValidateAll() if the designated constraints // aren't met. -type AddCommentRspMultiError []error +type UpdatePackageRspMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m AddCommentRspMultiError) Error() string { +func (m UpdatePackageRspMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) @@ -1479,11 +1337,11 @@ func (m AddCommentRspMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m AddCommentRspMultiError) AllErrors() []error { return m } +func (m UpdatePackageRspMultiError) AllErrors() []error { return m } -// AddCommentRspValidationError is the validation error returned by -// AddCommentRsp.Validate if the designated constraints aren't met. -type AddCommentRspValidationError struct { +// UpdatePackageRspValidationError is the validation error returned by +// UpdatePackageRsp.Validate if the designated constraints aren't met. +type UpdatePackageRspValidationError struct { field string reason string cause error @@ -1491,22 +1349,22 @@ type AddCommentRspValidationError struct { } // Field function returns field value. -func (e AddCommentRspValidationError) Field() string { return e.field } +func (e UpdatePackageRspValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e AddCommentRspValidationError) Reason() string { return e.reason } +func (e UpdatePackageRspValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e AddCommentRspValidationError) Cause() error { return e.cause } +func (e UpdatePackageRspValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e AddCommentRspValidationError) Key() bool { return e.key } +func (e UpdatePackageRspValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e AddCommentRspValidationError) ErrorName() string { return "AddCommentRspValidationError" } +func (e UpdatePackageRspValidationError) ErrorName() string { return "UpdatePackageRspValidationError" } // Error satisfies the builtin error interface -func (e AddCommentRspValidationError) Error() string { +func (e UpdatePackageRspValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -1518,14 +1376,14 @@ func (e AddCommentRspValidationError) Error() string { } return fmt.Sprintf( - "invalid %sAddCommentRsp.%s: %s%s", + "invalid %sUpdatePackageRsp.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = AddCommentRspValidationError{} +var _ error = UpdatePackageRspValidationError{} var _ interface { Field() string @@ -1533,7 +1391,7 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = AddCommentRspValidationError{} +} = UpdatePackageRspValidationError{} // Validate checks the field values on AddCommentReq with the rules defined in // the proto definition for this message. If any rules are violated, the first @@ -1557,10 +1415,10 @@ func (m *AddCommentReq) validate(all bool) error { var errors []error - if m.GetId() <= 0 { + if m.GetIdPackage() == nil { err := AddCommentReqValidationError{ - field: "Id", - reason: "value must be greater than 0", + field: "IdPackage", + reason: "value is required", } if !all { return err @@ -1568,6 +1426,37 @@ func (m *AddCommentReq) validate(all bool) error { errors = append(errors, err) } + if all { + switch v := interface{}(m.GetIdPackage()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, AddCommentReqValidationError{ + field: "IdPackage", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, AddCommentReqValidationError{ + field: "IdPackage", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetIdPackage()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return AddCommentReqValidationError{ + field: "IdPackage", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Text + if len(errors) > 0 { return AddCommentReqMultiError(errors) } @@ -1646,6 +1535,297 @@ var _ interface { ErrorName() string } = AddCommentReqValidationError{} +// Validate checks the field values on AddCommentRsp with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *AddCommentRsp) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on AddCommentRsp with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in AddCommentRspMultiError, or +// nil if none found. +func (m *AddCommentRsp) ValidateAll() error { + return m.validate(true) +} + +func (m *AddCommentRsp) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if m.GetId() <= 0 { + err := AddCommentRspValidationError{ + field: "Id", + reason: "value must be greater than 0", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return AddCommentRspMultiError(errors) + } + + return nil +} + +// AddCommentRspMultiError is an error wrapping multiple validation errors +// returned by AddCommentRsp.ValidateAll() if the designated constraints +// aren't met. +type AddCommentRspMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m AddCommentRspMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m AddCommentRspMultiError) AllErrors() []error { return m } + +// AddCommentRspValidationError is the validation error returned by +// AddCommentRsp.Validate if the designated constraints aren't met. +type AddCommentRspValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e AddCommentRspValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e AddCommentRspValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e AddCommentRspValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e AddCommentRspValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e AddCommentRspValidationError) ErrorName() string { return "AddCommentRspValidationError" } + +// Error satisfies the builtin error interface +func (e AddCommentRspValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sAddCommentRsp.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = AddCommentRspValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = AddCommentRspValidationError{} + +// Validate checks the field values on AddPackageReq with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *AddPackageReq) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on AddPackageReq with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in AddPackageReqMultiError, or +// nil if none found. +func (m *AddPackageReq) ValidateAll() error { + return m.validate(true) +} + +func (m *AddPackageReq) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if m.GetName() == nil { + err := AddPackageReqValidationError{ + field: "Name", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetName()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, AddPackageReqValidationError{ + field: "Name", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, AddPackageReqValidationError{ + field: "Name", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetName()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return AddPackageReqValidationError{ + field: "Name", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if m.GetUrl() == nil { + err := AddPackageReqValidationError{ + field: "Url", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetUrl()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, AddPackageReqValidationError{ + field: "Url", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, AddPackageReqValidationError{ + field: "Url", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUrl()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return AddPackageReqValidationError{ + field: "Url", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return AddPackageReqMultiError(errors) + } + + return nil +} + +// AddPackageReqMultiError is an error wrapping multiple validation errors +// returned by AddPackageReq.ValidateAll() if the designated constraints +// aren't met. +type AddPackageReqMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m AddPackageReqMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m AddPackageReqMultiError) AllErrors() []error { return m } + +// AddPackageReqValidationError is the validation error returned by +// AddPackageReq.Validate if the designated constraints aren't met. +type AddPackageReqValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e AddPackageReqValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e AddPackageReqValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e AddPackageReqValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e AddPackageReqValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e AddPackageReqValidationError) ErrorName() string { return "AddPackageReqValidationError" } + +// Error satisfies the builtin error interface +func (e AddPackageReqValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sAddPackageReq.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = AddPackageReqValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = AddPackageReqValidationError{} + // Validate checks the field values on AddPackageRsp with the rules defined in // the proto definition for this message. If any rules are violated, the first // error encountered is returned, or nil if there are no violations. @@ -1668,86 +1848,6 @@ func (m *AddPackageRsp) validate(all bool) error { var errors []error - if m.GetName() == nil { - err := AddPackageRspValidationError{ - field: "Name", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if all { - switch v := interface{}(m.GetName()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, AddPackageRspValidationError{ - field: "Name", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, AddPackageRspValidationError{ - field: "Name", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetName()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return AddPackageRspValidationError{ - field: "Name", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if m.GetUrl() == nil { - err := AddPackageRspValidationError{ - field: "Url", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if all { - switch v := interface{}(m.GetUrl()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, AddPackageRspValidationError{ - field: "Url", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, AddPackageRspValidationError{ - field: "Url", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUrl()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return AddPackageRspValidationError{ - field: "Url", - reason: "embedded message failed validation", - cause: err, - } - } - } - if len(errors) > 0 { return AddPackageRspMultiError(errors) } @@ -1826,22 +1926,22 @@ var _ interface { ErrorName() string } = AddPackageRspValidationError{} -// Validate checks the field values on AddPackageReq with the rules defined in +// Validate checks the field values on GetModuleReq with the rules defined in // the proto definition for this message. If any rules are violated, the first // error encountered is returned, or nil if there are no violations. -func (m *AddPackageReq) Validate() error { +func (m *GetModuleReq) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on AddPackageReq with the rules defined +// ValidateAll checks the field values on GetModuleReq with the rules defined // in the proto definition for this message. If any rules are violated, the -// result is a list of violation errors wrapped in AddPackageReqMultiError, or +// result is a list of violation errors wrapped in GetModuleReqMultiError, or // nil if none found. -func (m *AddPackageReq) ValidateAll() error { +func (m *GetModuleReq) ValidateAll() error { return m.validate(true) } -func (m *AddPackageReq) validate(all bool) error { +func (m *GetModuleReq) validate(all bool) error { if m == nil { return nil } @@ -1849,19 +1949,18 @@ func (m *AddPackageReq) validate(all bool) error { var errors []error if len(errors) > 0 { - return AddPackageReqMultiError(errors) + return GetModuleReqMultiError(errors) } return nil } -// AddPackageReqMultiError is an error wrapping multiple validation errors -// returned by AddPackageReq.ValidateAll() if the designated constraints -// aren't met. -type AddPackageReqMultiError []error +// GetModuleReqMultiError is an error wrapping multiple validation errors +// returned by GetModuleReq.ValidateAll() if the designated constraints aren't met. +type GetModuleReqMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m AddPackageReqMultiError) Error() string { +func (m GetModuleReqMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) @@ -1870,11 +1969,11 @@ func (m AddPackageReqMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m AddPackageReqMultiError) AllErrors() []error { return m } +func (m GetModuleReqMultiError) AllErrors() []error { return m } -// AddPackageReqValidationError is the validation error returned by -// AddPackageReq.Validate if the designated constraints aren't met. -type AddPackageReqValidationError struct { +// GetModuleReqValidationError is the validation error returned by +// GetModuleReq.Validate if the designated constraints aren't met. +type GetModuleReqValidationError struct { field string reason string cause error @@ -1882,22 +1981,22 @@ type AddPackageReqValidationError struct { } // Field function returns field value. -func (e AddPackageReqValidationError) Field() string { return e.field } +func (e GetModuleReqValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e AddPackageReqValidationError) Reason() string { return e.reason } +func (e GetModuleReqValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e AddPackageReqValidationError) Cause() error { return e.cause } +func (e GetModuleReqValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e AddPackageReqValidationError) Key() bool { return e.key } +func (e GetModuleReqValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e AddPackageReqValidationError) ErrorName() string { return "AddPackageReqValidationError" } +func (e GetModuleReqValidationError) ErrorName() string { return "GetModuleReqValidationError" } // Error satisfies the builtin error interface -func (e AddPackageReqValidationError) Error() string { +func (e GetModuleReqValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -1909,14 +2008,14 @@ func (e AddPackageReqValidationError) Error() string { } return fmt.Sprintf( - "invalid %sAddPackageReq.%s: %s%s", + "invalid %sGetModuleReq.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = AddPackageReqValidationError{} +var _ error = GetModuleReqValidationError{} var _ interface { Field() string @@ -1924,4 +2023,137 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = AddPackageReqValidationError{} +} = GetModuleReqValidationError{} + +// Validate checks the field values on GetModuleRsp with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *GetModuleRsp) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetModuleRsp with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in GetModuleRspMultiError, or +// nil if none found. +func (m *GetModuleRsp) ValidateAll() error { + return m.validate(true) +} + +func (m *GetModuleRsp) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetModules() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetModuleRspValidationError{ + field: fmt.Sprintf("Modules[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetModuleRspValidationError{ + field: fmt.Sprintf("Modules[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetModuleRspValidationError{ + field: fmt.Sprintf("Modules[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return GetModuleRspMultiError(errors) + } + + return nil +} + +// GetModuleRspMultiError is an error wrapping multiple validation errors +// returned by GetModuleRsp.ValidateAll() if the designated constraints aren't met. +type GetModuleRspMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetModuleRspMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetModuleRspMultiError) AllErrors() []error { return m } + +// GetModuleRspValidationError is the validation error returned by +// GetModuleRsp.Validate if the designated constraints aren't met. +type GetModuleRspValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetModuleRspValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetModuleRspValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetModuleRspValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetModuleRspValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetModuleRspValidationError) ErrorName() string { return "GetModuleRspValidationError" } + +// Error satisfies the builtin error interface +func (e GetModuleRspValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sGetModuleRsp.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetModuleRspValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetModuleRspValidationError{} diff --git a/proto/micro/dashboard_micro.pb.go b/proto/micro/dashboard_micro.pb.go index 2120f79..2d09b9d 100644 --- a/proto/micro/dashboard_micro.pb.go +++ b/proto/micro/dashboard_micro.pb.go @@ -22,14 +22,16 @@ var ( type DashboardServiceClient interface { ListPackage(ctx context.Context, req *go_generate.ListPackageReq, opts ...client.CallOption) (*go_generate.ListPackageRsp, error) - UpdatePackage(ctx context.Context, req *go_generate.UpdatePackageRsp, opts ...client.CallOption) (*go_generate.UpdatePackageReq, error) - AddComment(ctx context.Context, req *go_generate.AddCommentRsp, opts ...client.CallOption) (*go_generate.AddCommentReq, error) - AddPackage(ctx context.Context, req *go_generate.AddPackageRsp, opts ...client.CallOption) (*go_generate.AddPackageReq, error) + UpdatePackage(ctx context.Context, req *go_generate.UpdatePackageReq, opts ...client.CallOption) (*go_generate.UpdatePackageRsp, error) + AddComment(ctx context.Context, req *go_generate.AddCommentReq, opts ...client.CallOption) (*go_generate.AddCommentRsp, error) + AddPackage(ctx context.Context, req *go_generate.AddPackageReq, opts ...client.CallOption) (*go_generate.AddPackageRsp, error) + GetModule(ctx context.Context, req *go_generate.GetModuleReq, opts ...client.CallOption) (*go_generate.GetModuleRsp, error) } type DashboardServiceServer interface { ListPackage(ctx context.Context, req *go_generate.ListPackageReq, rsp *go_generate.ListPackageRsp) error - UpdatePackage(ctx context.Context, req *go_generate.UpdatePackageRsp, rsp *go_generate.UpdatePackageReq) error - AddComment(ctx context.Context, req *go_generate.AddCommentRsp, rsp *go_generate.AddCommentReq) error - AddPackage(ctx context.Context, req *go_generate.AddPackageRsp, rsp *go_generate.AddPackageReq) error + UpdatePackage(ctx context.Context, req *go_generate.UpdatePackageReq, rsp *go_generate.UpdatePackageRsp) error + AddComment(ctx context.Context, req *go_generate.AddCommentReq, rsp *go_generate.AddCommentRsp) error + AddPackage(ctx context.Context, req *go_generate.AddPackageReq, rsp *go_generate.AddPackageRsp) error + GetModule(ctx context.Context, req *go_generate.GetModuleReq, rsp *go_generate.GetModuleRsp) error } diff --git a/proto/micro/dashboard_micro_http.pb.go b/proto/micro/dashboard_micro_http.pb.go index 0db14fe..769cc56 100644 --- a/proto/micro/dashboard_micro_http.pb.go +++ b/proto/micro/dashboard_micro_http.pb.go @@ -31,8 +31,8 @@ func (c *dashboardServiceClient) ListPackage(ctx context.Context, req *go_genera return rsp, nil } -func (c *dashboardServiceClient) UpdatePackage(ctx context.Context, req *go_generate.UpdatePackageRsp, opts ...client.CallOption) (*go_generate.UpdatePackageReq, error) { - rsp := &go_generate.UpdatePackageReq{} +func (c *dashboardServiceClient) UpdatePackage(ctx context.Context, req *go_generate.UpdatePackageReq, opts ...client.CallOption) (*go_generate.UpdatePackageRsp, error) { + rsp := &go_generate.UpdatePackageRsp{} err := c.c.Call(ctx, c.c.NewRequest(c.name, "DashboardService.UpdatePackage", req), rsp, opts...) if err != nil { return nil, err @@ -40,8 +40,8 @@ func (c *dashboardServiceClient) UpdatePackage(ctx context.Context, req *go_gene return rsp, nil } -func (c *dashboardServiceClient) AddComment(ctx context.Context, req *go_generate.AddCommentRsp, opts ...client.CallOption) (*go_generate.AddCommentReq, error) { - rsp := &go_generate.AddCommentReq{} +func (c *dashboardServiceClient) AddComment(ctx context.Context, req *go_generate.AddCommentReq, opts ...client.CallOption) (*go_generate.AddCommentRsp, error) { + rsp := &go_generate.AddCommentRsp{} err := c.c.Call(ctx, c.c.NewRequest(c.name, "DashboardService.AddComment", req), rsp, opts...) if err != nil { return nil, err @@ -49,8 +49,8 @@ func (c *dashboardServiceClient) AddComment(ctx context.Context, req *go_generat return rsp, nil } -func (c *dashboardServiceClient) AddPackage(ctx context.Context, req *go_generate.AddPackageRsp, opts ...client.CallOption) (*go_generate.AddPackageReq, error) { - rsp := &go_generate.AddPackageReq{} +func (c *dashboardServiceClient) AddPackage(ctx context.Context, req *go_generate.AddPackageReq, opts ...client.CallOption) (*go_generate.AddPackageRsp, error) { + rsp := &go_generate.AddPackageRsp{} err := c.c.Call(ctx, c.c.NewRequest(c.name, "DashboardService.AddPackage", req), rsp, opts...) if err != nil { return nil, err @@ -58,6 +58,15 @@ func (c *dashboardServiceClient) AddPackage(ctx context.Context, req *go_generat return rsp, nil } +func (c *dashboardServiceClient) GetModule(ctx context.Context, req *go_generate.GetModuleReq, opts ...client.CallOption) (*go_generate.GetModuleRsp, error) { + rsp := &go_generate.GetModuleRsp{} + err := c.c.Call(ctx, c.c.NewRequest(c.name, "DashboardService.GetModule", req), rsp, opts...) + if err != nil { + return nil, err + } + return rsp, nil +} + type dashboardServiceServer struct { DashboardServiceServer } @@ -66,24 +75,29 @@ func (h *dashboardServiceServer) ListPackage(ctx context.Context, req *go_genera return h.DashboardServiceServer.ListPackage(ctx, req, rsp) } -func (h *dashboardServiceServer) UpdatePackage(ctx context.Context, req *go_generate.UpdatePackageRsp, rsp *go_generate.UpdatePackageReq) error { +func (h *dashboardServiceServer) UpdatePackage(ctx context.Context, req *go_generate.UpdatePackageReq, rsp *go_generate.UpdatePackageRsp) error { return h.DashboardServiceServer.UpdatePackage(ctx, req, rsp) } -func (h *dashboardServiceServer) AddComment(ctx context.Context, req *go_generate.AddCommentRsp, rsp *go_generate.AddCommentReq) error { +func (h *dashboardServiceServer) AddComment(ctx context.Context, req *go_generate.AddCommentReq, rsp *go_generate.AddCommentRsp) error { return h.DashboardServiceServer.AddComment(ctx, req, rsp) } -func (h *dashboardServiceServer) AddPackage(ctx context.Context, req *go_generate.AddPackageRsp, rsp *go_generate.AddPackageReq) error { +func (h *dashboardServiceServer) AddPackage(ctx context.Context, req *go_generate.AddPackageReq, rsp *go_generate.AddPackageRsp) error { return h.DashboardServiceServer.AddPackage(ctx, req, rsp) } +func (h *dashboardServiceServer) GetModule(ctx context.Context, req *go_generate.GetModuleReq, rsp *go_generate.GetModuleRsp) error { + return h.DashboardServiceServer.GetModule(ctx, req, rsp) +} + func RegisterDashboardServiceServer(s server.Server, sh DashboardServiceServer, opts ...server.HandlerOption) error { type dashboardService interface { ListPackage(ctx context.Context, req *go_generate.ListPackageReq, rsp *go_generate.ListPackageRsp) error - UpdatePackage(ctx context.Context, req *go_generate.UpdatePackageRsp, rsp *go_generate.UpdatePackageReq) error - AddComment(ctx context.Context, req *go_generate.AddCommentRsp, rsp *go_generate.AddCommentReq) error - AddPackage(ctx context.Context, req *go_generate.AddPackageRsp, rsp *go_generate.AddPackageReq) error + UpdatePackage(ctx context.Context, req *go_generate.UpdatePackageReq, rsp *go_generate.UpdatePackageRsp) error + AddComment(ctx context.Context, req *go_generate.AddCommentReq, rsp *go_generate.AddCommentRsp) error + AddPackage(ctx context.Context, req *go_generate.AddPackageReq, rsp *go_generate.AddPackageRsp) error + GetModule(ctx context.Context, req *go_generate.GetModuleReq, rsp *go_generate.GetModuleRsp) error } type DashboardService struct { dashboardService diff --git a/service/client_git/client.go b/service/client_git/client.go index 664d221..de49bdc 100644 --- a/service/client_git/client.go +++ b/service/client_git/client.go @@ -24,26 +24,26 @@ import ( ) type Client interface { - Run(ctx context.Context, st storage.Storage) chan *pb.AddPackageRsp + Run(ctx context.Context, st storage.Storage) chan *pb.AddPackageReq IsClose() bool Done() <-chan struct{} } type client struct { - worker chan *pb.AddPackageRsp + worker chan *pb.AddPackageReq closed bool lock chan struct{} } func NewClient(cap uint) Client { return &client{ - make(chan *pb.AddPackageRsp, cap), + make(chan *pb.AddPackageReq, cap), false, make(chan struct{}), } } -func (c *client) Run(ctx context.Context, st storage.Storage) chan *pb.AddPackageRsp { +func (c *client) Run(ctx context.Context, st storage.Storage) chan *pb.AddPackageReq { go func() { defer close(c.worker) for { @@ -71,8 +71,8 @@ func (c *client) Done() <-chan struct{} { return c.lock } -func runner(ctx context.Context, st storage.Storage, rsp *pb.AddPackageRsp) { - modules, err := getGoModule(ctx, rsp.Url.Value) +func runner(ctx context.Context, st storage.Storage, req *pb.AddPackageReq) { + modules, err := getGoModule(ctx, req.Url.Value) if err != nil { logger.Error(ctx, err) return @@ -80,12 +80,12 @@ func runner(ctx context.Context, st storage.Storage, rsp *pb.AddPackageRsp) { logger.Infof(ctx, "success get list mod", modules) - if rsp.Modules, err = st.InsertButchModules(ctx, modules); err != nil { + if req.Modules, err = st.InsertButchModules(ctx, modules); err != nil { logger.Error(ctx, err) return } - if err = st.AddPackage(ctx, rsp); err != nil { + if err = st.AddPackage(ctx, req); err != nil { logger.Error(ctx, err) } } diff --git a/service/client_git/client_test.go b/service/client_git/client_test.go index 784685f..a779ad5 100644 --- a/service/client_git/client_test.go +++ b/service/client_git/client_test.go @@ -39,7 +39,7 @@ func TestClientPG(t *testing.T) { ch := cli.Run(ctx, s) - data := &pb.AddPackageRsp{ + data := &pb.AddPackageReq{ Name: wrapperspb.String("test"), Url: wrapperspb.String("https://github.com/dantedenis/service_history.git"), } @@ -75,7 +75,7 @@ func TestClientLite(t *testing.T) { ch := cli.Run(ctx, s) - data := &pb.AddPackageRsp{ + data := &pb.AddPackageReq{ Name: wrapperspb.String("test"), Url: wrapperspb.String("https://github.com/dantedenis/service_history.git"), } diff --git a/service/service.go b/service/service.go index c43ed6b..8b8fb75 100644 --- a/service/service.go +++ b/service/service.go @@ -132,6 +132,7 @@ func NewService(ctx context.Context) (micro.Service, error) { mux.HandleFunc("/updatePackage", handler.Methods(http.MethodPost, h.UpdatePackage)) mux.HandleFunc("/addComment", handler.Methods(http.MethodPut, h.AddComment)) mux.HandleFunc("/addPackage", handler.Methods(http.MethodPost, h.AddPackage)) + mux.HandleFunc("/getModule", handler.Methods(http.MethodGet, h.GetModule)) if err = svc.Server().Handle(svc.Server().NewHandler(mux)); err != nil { logger.Fatalf(ctx, "failed to register handler: %v", err) diff --git a/storage/postgres/storage.go b/storage/postgres/storage.go index 81e62ff..ad50e56 100644 --- a/storage/postgres/storage.go +++ b/storage/postgres/storage.go @@ -89,7 +89,7 @@ func (s *Postgres) MigrateDown() error { return nil } -func (s *Postgres) UpdatePackage(ctx context.Context, rsp *pb.UpdatePackageRsp) error { +func (s *Postgres) UpdatePackage(ctx context.Context, req *pb.UpdatePackageReq) error { panic("need implement") } @@ -122,7 +122,7 @@ func (s *Postgres) ListPackage(ctx context.Context) (models.ListPackage, error) return result, err } -func (s *Postgres) AddComment(ctx context.Context, rsp *pb.AddCommentRsp) error { +func (s *Postgres) AddComment(ctx context.Context, req *pb.AddCommentReq) error { tx, err := s.db.BeginTx(ctx, nil) if err != nil { return err @@ -138,7 +138,7 @@ func (s *Postgres) AddComment(ctx context.Context, rsp *pb.AddCommentRsp) error } }() - res, err := tx.ExecContext(ctx, queryAddComment, rsp.Text, rsp.IdPackage.Value) + res, err := tx.ExecContext(ctx, queryAddComment, req.Text, req.IdPackage.Value) if err != nil { return err } @@ -152,7 +152,7 @@ func (s *Postgres) AddComment(ctx context.Context, rsp *pb.AddCommentRsp) error return err } -func (s *Postgres) AddPackage(ctx context.Context, rsp *pb.AddPackageRsp) error { +func (s *Postgres) AddPackage(ctx context.Context, req *pb.AddPackageReq) error { tx, err := s.db.BeginTx(ctx, nil) if err != nil { return err @@ -168,7 +168,7 @@ func (s *Postgres) AddPackage(ctx context.Context, rsp *pb.AddPackageRsp) error } }() - res, err := tx.ExecContext(ctx, queryAddPackage, rsp.Name.Value, rsp.Url.Value, pq.Array(rsp.Modules)) + res, err := tx.ExecContext(ctx, queryAddPackage, req.Name.Value, req.Url.Value, pq.Array(req.Modules)) if err != nil { return err } @@ -182,7 +182,7 @@ func (s *Postgres) AddPackage(ctx context.Context, rsp *pb.AddPackageRsp) error return err } -func (s *Postgres) InsertButchModules(ctx context.Context, rsp []models.Module) ([]uint64, error) { +func (s *Postgres) InsertButchModules(ctx context.Context, req []models.Module) ([]uint64, error) { tx, err := s.db.BeginTx(ctx, nil) if err != nil { return nil, err @@ -197,7 +197,7 @@ func (s *Postgres) InsertButchModules(ctx context.Context, rsp []models.Module) } }() - query := generateQuery(rsp) + query := generateQuery(req) rows, err := tx.QueryContext(ctx, query) if err != nil { diff --git a/storage/postgres/storage_test.go b/storage/postgres/storage_test.go index 9f228b1..2fcbd67 100644 --- a/storage/postgres/storage_test.go +++ b/storage/postgres/storage_test.go @@ -9,16 +9,28 @@ import ( func TestGenerate(t *testing.T) { m := []models.Module{ { - 1, "test", "1.2.3", 2, "23.31", + ID: 1, + Name: "test", + Version: "1.2.3", + Package: 2, + LastVersion: "23.31", }, { - 1, "321test", "1.3", 4, "2111.31", + ID: 1, + Name: "321test", + Version: "1.3", + Package: 4, + LastVersion: "2111.31", }, { - 1, "testabcd", "1.2.3", 2, "153453.31", + ID: 1, + Name: "testabcd", + Version: "1.2.3", + Package: 2, + LastVersion: "153453.31", }, } - + str := generateQuery(m) fmt.Println(str) diff --git a/storage/sqlite/storage.go b/storage/sqlite/storage.go index 5e21b5b..1b2f140 100644 --- a/storage/sqlite/storage.go +++ b/storage/sqlite/storage.go @@ -91,7 +91,7 @@ func (s *Sqlite) MigrateDown() error { return nil } -func (s *Sqlite) UpdatePackage(ctx context.Context, rsp *pb.UpdatePackageRsp) error { +func (s *Sqlite) UpdatePackage(ctx context.Context, req *pb.UpdatePackageReq) error { panic("need implement") } @@ -124,7 +124,7 @@ func (s *Sqlite) ListPackage(ctx context.Context) (models.ListPackage, error) { return result, err } -func (s *Sqlite) AddComment(ctx context.Context, rsp *pb.AddCommentRsp) error { +func (s *Sqlite) AddComment(ctx context.Context, req *pb.AddCommentReq) error { tx, err := s.db.BeginTx(ctx, nil) if err != nil { return err @@ -140,7 +140,7 @@ func (s *Sqlite) AddComment(ctx context.Context, rsp *pb.AddCommentRsp) error { } }() - res, err := tx.ExecContext(ctx, queryAddComment, rsp.Text, rsp.IdPackage.Value) + res, err := tx.ExecContext(ctx, queryAddComment, req.Text, req.IdPackage.Value) if err != nil { return err } @@ -154,7 +154,7 @@ func (s *Sqlite) AddComment(ctx context.Context, rsp *pb.AddCommentRsp) error { return err } -func (s *Sqlite) AddPackage(ctx context.Context, rsp *pb.AddPackageRsp) error { +func (s *Sqlite) AddPackage(ctx context.Context, req *pb.AddPackageReq) error { tx, err := s.db.BeginTx(ctx, nil) if err != nil { return err @@ -170,7 +170,7 @@ func (s *Sqlite) AddPackage(ctx context.Context, rsp *pb.AddPackageRsp) error { } }() - res, err := tx.ExecContext(ctx, queryAddPackage, rsp.Name.Value, rsp.Url.Value, pq.Array(rsp.Modules)) + res, err := tx.ExecContext(ctx, queryAddPackage, req.Name.Value, req.Url.Value, pq.Array(req.Modules)) if err != nil { return err } @@ -184,7 +184,7 @@ func (s *Sqlite) AddPackage(ctx context.Context, rsp *pb.AddPackageRsp) error { return err } -func (s *Sqlite) InsertButchModules(ctx context.Context, rsp []models.Module) ([]uint64, error) { +func (s *Sqlite) InsertButchModules(ctx context.Context, req []models.Module) ([]uint64, error) { tx, err := s.db.BeginTx(ctx, nil) if err != nil { return nil, err @@ -199,7 +199,7 @@ func (s *Sqlite) InsertButchModules(ctx context.Context, rsp []models.Module) ([ } }() - query := generateQuery(rsp) + query := generateQuery(req) rows, err := tx.QueryContext(ctx, query) if err != nil { diff --git a/storage/storage.go b/storage/storage.go index 64df6c5..7d93511 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -28,10 +28,10 @@ type Storage interface { cmsstorage.Migrator ListPackage(ctx context.Context) (models.ListPackage, error) - UpdatePackage(ctx context.Context, rsp *pb.UpdatePackageRsp) error - AddComment(ctx context.Context, rsp *pb.AddCommentRsp) error - AddPackage(ctx context.Context, rsp *pb.AddPackageRsp) error - InsertButchModules(ctx context.Context, rsp []models.Module) ([]uint64, error) + UpdatePackage(ctx context.Context, req *pb.UpdatePackageReq) error + AddComment(ctx context.Context, req *pb.AddCommentReq) error + AddPackage(ctx context.Context, req *pb.AddPackageReq) error + InsertButchModules(ctx context.Context, req []models.Module) ([]uint64, error) } func NewStorage(name string, db *sql.DB) (interface{}, error) {