From 726bb4643c6334cc4998f2876ef35230e1523d1e Mon Sep 17 00:00:00 2001 From: Nicolas CARON Date: Mon, 10 Feb 2025 12:07:54 +0100 Subject: [PATCH] Edit proto & add Diagdate --- grpcapi/diag.go | 3 ++ grpcapi/diag.pb.go | 80 +++++++++++++++++++++++++++------------------- grpcapi/diag.proto | 2 ++ storage/Diag.go | 3 ++ 4 files changed, 56 insertions(+), 32 deletions(-) diff --git a/grpcapi/diag.go b/grpcapi/diag.go index b275aa2..5ed7978 100644 --- a/grpcapi/diag.go +++ b/grpcapi/diag.go @@ -7,6 +7,7 @@ import ( "github.com/rs/zerolog/log" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/types/known/structpb" + "google.golang.org/protobuf/types/known/timestamppb" ) @@ -19,6 +20,7 @@ func (e Diag) ToStorageType() storage.Diag { Ui_schema: e.UiSchema, Data: map[string]any{}, Deleted: e.Deleted, + Diagdate: e.Diagdate.AsTime(), } for k, d := range e.Data.GetFields() { @@ -56,6 +58,7 @@ func DiagFromStorageType(diag *storage.Diag) (*Diag, error) { UiSchema: diag.Ui_schema, Data: data, Deleted: diag.Deleted, + Diagdate: timestamppb.New(diag.Diagdate), }, nil } diff --git a/grpcapi/diag.pb.go b/grpcapi/diag.pb.go index f2be223..0497c0f 100644 --- a/grpcapi/diag.pb.go +++ b/grpcapi/diag.pb.go @@ -10,6 +10,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" structpb "google.golang.org/protobuf/types/known/structpb" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" ) @@ -26,13 +27,14 @@ type Diag struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Namespace string `protobuf:"bytes,3,opt,name=namespace,proto3" json:"namespace,omitempty"` - JsonSchema string `protobuf:"bytes,4,opt,name=json_schema,json=jsonSchema,proto3" json:"json_schema,omitempty"` - UiSchema string `protobuf:"bytes,5,opt,name=ui_schema,json=uiSchema,proto3" json:"ui_schema,omitempty"` - Data *structpb.Struct `protobuf:"bytes,6,opt,name=data,proto3" json:"data,omitempty"` - Deleted bool `protobuf:"varint,7,opt,name=deleted,proto3" json:"deleted,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Namespace string `protobuf:"bytes,3,opt,name=namespace,proto3" json:"namespace,omitempty"` + JsonSchema string `protobuf:"bytes,4,opt,name=json_schema,json=jsonSchema,proto3" json:"json_schema,omitempty"` + UiSchema string `protobuf:"bytes,5,opt,name=ui_schema,json=uiSchema,proto3" json:"ui_schema,omitempty"` + Data *structpb.Struct `protobuf:"bytes,6,opt,name=data,proto3" json:"data,omitempty"` + Deleted bool `protobuf:"varint,7,opt,name=deleted,proto3" json:"deleted,omitempty"` + Diagdate *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=diagdate,proto3" json:"diagdate,omitempty"` } func (x *Diag) Reset() { @@ -114,29 +116,41 @@ func (x *Diag) GetDeleted() bool { return false } +func (x *Diag) GetDiagdate() *timestamppb.Timestamp { + if x != nil { + return x.Diagdate + } + return nil +} + var File_diag_proto protoreflect.FileDescriptor var file_diag_proto_rawDesc = []byte{ 0x0a, 0x0a, 0x64, 0x69, 0x61, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, - 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xcd, 0x01, 0x0a, 0x04, 0x44, - 0x69, 0x61, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 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, 0x6e, 0x61, 0x6d, 0x65, 0x73, - 0x70, 0x61, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, - 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x73, 0x63, - 0x68, 0x65, 0x6d, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6a, 0x73, 0x6f, 0x6e, - 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x1b, 0x0a, 0x09, 0x75, 0x69, 0x5f, 0x73, 0x63, 0x68, - 0x65, 0x6d, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x69, 0x53, 0x63, 0x68, - 0x65, 0x6d, 0x61, 0x12, 0x2b, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, - 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x42, 0x2d, 0x5a, 0x2b, 0x67, 0x69, - 0x74, 0x2e, 0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2e, 0x69, 0x6f, 0x2f, 0x63, 0x6f, 0x6f, 0x70, - 0x67, 0x6f, 0x2d, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x2f, 0x64, 0x69, 0x61, 0x67, - 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x85, 0x02, 0x0a, 0x04, + 0x44, 0x69, 0x61, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 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, 0x6e, 0x61, 0x6d, 0x65, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, + 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x73, + 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6a, 0x73, 0x6f, + 0x6e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x1b, 0x0a, 0x09, 0x75, 0x69, 0x5f, 0x73, 0x63, + 0x68, 0x65, 0x6d, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x69, 0x53, 0x63, + 0x68, 0x65, 0x6d, 0x61, 0x12, 0x2b, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x04, 0x64, 0x61, 0x74, + 0x61, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x12, 0x36, 0x0a, 0x08, 0x64, + 0x69, 0x61, 0x67, 0x64, 0x61, 0x74, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x08, 0x64, 0x69, 0x61, 0x67, 0x64, + 0x61, 0x74, 0x65, 0x42, 0x2d, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x2e, 0x63, 0x6f, 0x6f, 0x70, 0x67, + 0x6f, 0x2e, 0x69, 0x6f, 0x2f, 0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2d, 0x70, 0x6c, 0x61, 0x74, + 0x66, 0x6f, 0x72, 0x6d, 0x2f, 0x64, 0x69, 0x61, 0x67, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x61, + 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -153,16 +167,18 @@ func file_diag_proto_rawDescGZIP() []byte { var file_diag_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_diag_proto_goTypes = []any{ - (*Diag)(nil), // 0: Diag - (*structpb.Struct)(nil), // 1: google.protobuf.Struct + (*Diag)(nil), // 0: Diag + (*structpb.Struct)(nil), // 1: google.protobuf.Struct + (*timestamppb.Timestamp)(nil), // 2: google.protobuf.Timestamp } var file_diag_proto_depIdxs = []int32{ 1, // 0: Diag.data:type_name -> google.protobuf.Struct - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 2, // 1: Diag.diagdate:type_name -> google.protobuf.Timestamp + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_diag_proto_init() } diff --git a/grpcapi/diag.proto b/grpcapi/diag.proto index 9d2c8bc..1afabb6 100644 --- a/grpcapi/diag.proto +++ b/grpcapi/diag.proto @@ -3,6 +3,7 @@ syntax = "proto3"; option go_package = "git.coopgo.io/coopgo-platform/diags/grpcapi"; import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; message Diag { string id = 1; @@ -12,4 +13,5 @@ message Diag { string ui_schema = 5; google.protobuf.Struct data = 6; bool deleted = 7; + google.protobuf.Timestamp diagdate = 8; } \ No newline at end of file diff --git a/storage/Diag.go b/storage/Diag.go index e5429c6..c805520 100644 --- a/storage/Diag.go +++ b/storage/Diag.go @@ -1,5 +1,7 @@ package storage +import "time" + type Diag struct { ID string `json:"id" bson:"_id"` Name string `json:"name"` @@ -8,4 +10,5 @@ type Diag struct { Ui_schema string `json:"ui_schema"` Data map[string]any `json:"data"` Deleted bool `json:"deleted"` + Diagdate time.Time `json:"diagdate"` }