From 77cab55402b3717bdd924a683317521022bd3479 Mon Sep 17 00:00:00 2001 From: HuangJiaLuo <1820799930@qq.com> Date: Tue, 21 Sep 2021 10:44:27 +0800 Subject: [PATCH] fix(gen): fix gen-interface --- makefile | 8 ++---- pkg/structure/generate/inteerface.template | 28 --------------------- pkg/structure/generate/interface.template | 29 ++++++++++++++++++++++ pkg/structure/interface.go | 27 -------------------- shell/make-struct.py | 4 +-- 5 files changed, 32 insertions(+), 64 deletions(-) delete mode 100644 pkg/structure/generate/inteerface.template create mode 100644 pkg/structure/generate/interface.template delete mode 100644 pkg/structure/interface.go diff --git a/makefile b/makefile index 1932289..a27866a 100644 --- a/makefile +++ b/makefile @@ -17,14 +17,10 @@ install: dev: @./bin/storage storage -.PHONY: gen-struct-const -gen-struct-const: +.PHONY: gen-struct +gen-struct: @python3 ./shell/make-struct.py .PHONY: gen-protobuf gen-protobuf: @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/inteerface.template b/pkg/structure/generate/inteerface.template deleted file mode 100644 index 1b08892..0000000 --- a/pkg/structure/generate/inteerface.template +++ /dev/null @@ -1,28 +0,0 @@ -package structure - -import "gitee.com/timedb/wheatCache/pkg/proto" - -type KeyBaseInterface interface { - SizeByte() int64 - - // TODO RollBack 事务相关, V2 实现 - RollBack() error - // Begin 事务相关, V2 实现 - Begin() error - // Comment 事务相关, V2 实现 - Comment() error - - Encode() ([]byte, error) -} - - -type StringXInterface interface { - KeyBaseInterface - Set(*proto.SetRequest) ([]string, error) - Get(*proto.GetRequest) ([]string, error) -} - -type ListXInterface interface { - KeyBaseInterface - LSet(*proto.SetRequest) ([]string, error) -} diff --git a/pkg/structure/generate/interface.template b/pkg/structure/generate/interface.template new file mode 100644 index 0000000..97c0780 --- /dev/null +++ b/pkg/structure/generate/interface.template @@ -0,0 +1,29 @@ +// Code generated by gen-struct-const. DO NOT EDIT. +// make gen-struct generated + +package structure + +import "gitee.com/timedb/wheatCache/pkg/proto" + +type KeyBaseInterface interface { + SizeByte() int64 + + // TODO RollBack 事务相关, V2 实现 + RollBack() error + // Begin 事务相关, V2 实现 + Begin() error + // Comment 事务相关, V2 实现 + Comment() error + + Encode() ([]byte, error) +} +{% for dict_item in Data %} +{% for key, value in dict_item.items() %} +type {{key}}Interface interface{ + KeyBaseInterface + {% for val in value -%} + {{val}}(*proto.{{val}}Request) ([]string, error) + {% endfor %} +} + {% endfor -%} +{%- endfor %} diff --git a/pkg/structure/interface.go b/pkg/structure/interface.go deleted file mode 100644 index 61d498f..0000000 --- a/pkg/structure/interface.go +++ /dev/null @@ -1,27 +0,0 @@ -package structure - -import "gitee.com/timedb/wheatCache/pkg/proto" - -type KeyBaseInterface interface { - SizeByte() int64 - - // TODO RollBack 事务相关, V2 实现 - RollBack() error - // Begin 事务相关, V2 实现 - Begin() error - // Comment 事务相关, V2 实现 - Comment() error - - Encode() ([]byte, error) -} - -type StringXInterface interface { - KeyBaseInterface - Set(*proto.SetRequest) ([]string, error) - Get(*proto.GetRequest) ([]string, error) -} - -type ListXInterface interface { - KeyBaseInterface - LSet(*proto.SetRequest) ([]string, error) -} diff --git a/shell/make-struct.py b/shell/make-struct.py index bd06602..994c094 100644 --- a/shell/make-struct.py +++ b/shell/make-struct.py @@ -1,5 +1,4 @@ import os -from typing import Dict, List from jinja2 import Template import yaml @@ -80,6 +79,5 @@ def set_structure_interface(conf): if __name__ == "__main__": conf, cfg_camel = load_conf() - # set_structure_const_template(conf) - # set_structure_interface(conf) + set_structure_const_template(conf) set_structure_interface(cfg_camel)