From bbb9639b0999baa272420475fe1f5d8c7117d7bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Wed, 1 Feb 2023 14:41:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=93=E6=9E=84=E4=BD=93?= =?UTF-8?q?=E5=8F=8D=E5=B0=84=E7=9A=84=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- define.go | 20 ++++++++++++++++++-- reflect.go | 25 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 reflect.go diff --git a/define.go b/define.go index f3e5667..c201cc6 100644 --- a/define.go +++ b/define.go @@ -7,6 +7,8 @@ // Date : 2023-02-01 14:23 package event +import "reflect" + const ( // OutputKeyTag 事件数据输出key的标签 OutputKeyTag = "event" @@ -37,6 +39,20 @@ const ( // // Date : 14:24 2023/2/1 type MappingRule struct { - Location string `json:"location"` // 数据所在位置, header-请求头 param-参数获取 response-响应数据获取 extension-扩展数据读取 all-自动按照header/param/response/extension的顺序查询 - Field string `json:"field"` // 查询的字段名称 + Location string `json:"location"` // 数据所在位置, header-请求头 param-参数获取 response-响应数据获取 extension-扩展数据读取 all-自动按照header/param/response/extension的顺序查询 + Field []string `json:"field"` // 查询的字段名称, 列表, 按照优先级诸葛查询 + Priority string `json:"priority"` // 查找优先级 : location - 位置优先 field - 字段优先 +} + +// StructField 结构体字段信息 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 14:35 2023/2/1 +type StructField struct { + Name string // 字段名 + Type reflect.Kind // 字段类型 + JsonTag string // json标签 + EventTag string // 事件标签 + MappingRule *MappingRule // 数据映射规则 } diff --git a/reflect.go b/reflect.go new file mode 100644 index 0000000..839093a --- /dev/null +++ b/reflect.go @@ -0,0 +1,25 @@ +// Package event ... +// +// Description : event ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 2023-02-01 14:30 +package event + +// ReflectType 反射数据类型 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 14:31 2023/2/1 +type ReflectType struct { +} + +// Do 反射获取数据类型 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 14:34 2023/2/1 +func (rt *ReflectType) Do(data interface{}) { + +}