From 9c48e9ceab02e59fdb9f01629793003bda2ea797 Mon Sep 17 00:00:00 2001 From: anqiansong Date: Fri, 29 Oct 2021 09:55:41 +0800 Subject: [PATCH] Feature add template version (#1152) --- tools/goctl/model/sql/gen/insert.go | 2 ++ tools/goctl/util/file.go | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/goctl/model/sql/gen/insert.go b/tools/goctl/model/sql/gen/insert.go index 7a055afe..ada44819 100644 --- a/tools/goctl/model/sql/gen/insert.go +++ b/tools/goctl/model/sql/gen/insert.go @@ -13,6 +13,8 @@ import ( func genInsert(table Table, withCache, postgreSql bool) (string, string, error) { keySet := collection.NewSet() keyVariableSet := collection.NewSet() + keySet.AddStr(table.PrimaryCacheKey.DataKeyExpression) + keyVariableSet.AddStr(table.PrimaryCacheKey.KeyLeft) for _, key := range table.UniqueCacheKey { keySet.AddStr(key.DataKeyExpression) keyVariableSet.AddStr(key.KeyLeft) diff --git a/tools/goctl/util/file.go b/tools/goctl/util/file.go index 5b42a51d..af522054 100644 --- a/tools/goctl/util/file.go +++ b/tools/goctl/util/file.go @@ -10,6 +10,7 @@ import ( "strings" "github.com/logrusorgru/aurora" + "github.com/tal-tech/go-zero/tools/goctl/internal/version" ) // NL defines a new line @@ -88,7 +89,7 @@ func GetTemplateDir(category string) (string, error) { return "", err } - return filepath.Join(goctlHome, category), nil + return filepath.Join(goctlHome, version.GetGoctlVersion(), category), nil } // InitTemplates creates template files GoctlHome where could get it by GetGoctlHome