From 66a81542500c75662c6b6fc06038f4b7f2d4b27a Mon Sep 17 00:00:00 2001 From: rellopn <614046330@qq.com> Date: Tue, 21 Jun 2022 17:11:41 +0800 Subject: [PATCH] =?UTF-8?q?=20support=20custom=20fuzzy=20regular=20matchin?= =?UTF-8?q?g=20=E6=94=AF=E6=8C=81=E6=A8=A1=E7=B3=8A=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.yml | 1 + data/view/model/common.go | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/config.yml b/config.yml index 4c28a57..5a36dcc 100644 --- a/config.yml +++ b/config.yml @@ -32,6 +32,7 @@ db_info: self_type_define: # 自定义数据类型映射 datetime: time.Time time: time.Time + ^(int)[(]\d+[)]: int out_file_name: "" # 自定义生成文件名 web_tag_type: 0 # json tag类型 0: 小驼峰 1: 下划线 diff --git a/data/view/model/common.go b/data/view/model/common.go index 1577638..3b36e86 100755 --- a/data/view/model/common.go +++ b/data/view/model/common.go @@ -73,6 +73,13 @@ func getTypeName(name string, isNull bool) string { return fixNullToPorint(v, isNull) } + // Fuzzy Regular Matching.模糊正则匹配自定义类型 + for selfKey, selfVal := range selfDefineTypeMqlDicMap { + if ok, _ := regexp.MatchString(selfKey, name); ok { + return fixNullToPorint(selfVal, isNull) + } + } + // Precise matching first.先精确匹配 if v, ok := cnf.TypeMysqlDicMp[name]; ok { return fixNullToPorint(v, isNull)