From 4b27125092d482ad690113bf9159d37aa6616b30 Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Mon, 20 Sep 2021 16:36:47 +0800 Subject: [PATCH] fix(gen-struct): add struct --- makefile | 6 +++++- pkg/structure/generate/tem.yaml | 10 +--------- protobuf/base.proto | 6 +++--- protobuf/listx.proto | 22 ---------------------- protobuf/stringx.proto | 21 +++++++++------------ shell/gen_protobuf.py | 4 ++-- 6 files changed, 20 insertions(+), 49 deletions(-) delete mode 100644 protobuf/listx.proto diff --git a/makefile b/makefile index 93c6893..6380d3c 100644 --- a/makefile +++ b/makefile @@ -23,4 +23,8 @@ gen-struct: .PHONY: gen-protobuf gen-protobuf: - @python3 ./shell/gen_protobuf.py \ No newline at end of file + @python3 ./shell/gen_protobuf.py + +.PHONY: gen-structure-interface +gen-structure-interface: + @python3 ./shell/gen_struct_interface.py \ No newline at end of file diff --git a/pkg/structure/generate/tem.yaml b/pkg/structure/generate/tem.yaml index 95156c6..9aae05e 100644 --- a/pkg/structure/generate/tem.yaml +++ b/pkg/structure/generate/tem.yaml @@ -6,12 +6,4 @@ STRING_X: - add - reduce - setbit - - getbit - -LIST_X: - - l_set - - l_get - - l_add - - l_queue - - l_setbit - - l_getbit + - getbit \ No newline at end of file diff --git a/protobuf/base.proto b/protobuf/base.proto index 85ebaa6..451bcb2 100644 --- a/protobuf/base.proto +++ b/protobuf/base.proto @@ -4,7 +4,7 @@ option go_package = "pkg/proto"; import "google/protobuf/timestamp.proto"; message BaseKey { - string key = 1; - int64 ttl = 2; - google.protobuf.Timestamp expire = 3; + string key = 1; + int64 ttl = 2; + google.protobuf.Timestamp expire = 3; } \ No newline at end of file diff --git a/protobuf/listx.proto b/protobuf/listx.proto deleted file mode 100644 index cc2733b..0000000 --- a/protobuf/listx.proto +++ /dev/null @@ -1,22 +0,0 @@ -syntax = "proto3"; -import "base.proto"; -option go_package = "pkg/proto"; - -message LSetRequest { - BaseKey key = 1; -} -message LGetRequest { - BaseKey key = 1; -} -message LAddRequest { - BaseKey key = 1; -} -message LQueueRequest { - BaseKey key = 1; -} -message LSetbitRequest { - BaseKey key = 1; -} -message LGetbitRequest { - BaseKey key = 1; -} \ No newline at end of file diff --git a/protobuf/stringx.proto b/protobuf/stringx.proto index 9499847..f6ac035 100644 --- a/protobuf/stringx.proto +++ b/protobuf/stringx.proto @@ -1,31 +1,28 @@ syntax = "proto3"; - import "base.proto"; - option go_package = "pkg/proto"; - message SetRequest { - BaseKey key = 1; - string value = 2; + BaseKey key = 1; + string value = 2; } message GetRequest { - BaseKey key = 1; + BaseKey key = 1; } message AddRequest { - BaseKey key = 1; - int64 value = 2; + BaseKey key = 1; } message ReduceRequest { - BaseKey key = 1; + BaseKey key = 1; } message SetbitRequest { - BaseKey key = 1; + BaseKey key = 1; } + message GetbitRequest { - BaseKey key = 1; -} \ No newline at end of file + BaseKey key = 1; +} diff --git a/shell/gen_protobuf.py b/shell/gen_protobuf.py index 077e013..f60b99d 100644 --- a/shell/gen_protobuf.py +++ b/shell/gen_protobuf.py @@ -48,7 +48,7 @@ def mkdir(cfg_camel): file = open(proto_path,'w') file.write('syntax = "proto3";\nimport "base.proto";\noption go_package = "pkg/proto";\n') for v in value: - file.write('\nmessage ' + v +'Request '+'{\n\tBaseKey key = 1;\n}') + file.write('\nmessage ' + v +'Request '+'{\n BaseKey key = 1;\n}\n') file.close() else: # 如果这个文件存在 with open(proto_path) as f: @@ -64,7 +64,7 @@ def mkdir(cfg_camel): break if flag == 0: file = open(proto_path,'a') - file.write('\nmessage ' + v +'Request '+'{\n\tBaseKey key = 1;\n}') + file.write('\nmessage ' + v +'Request '+'{\n BaseKey key = 1;\n}\n') file.close() flag = 0