2023-02-01 14:29:27 +08:00
|
|
|
// Package event ...
|
|
|
|
//
|
|
|
|
// Description : 各种常量定义
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 2023-02-01 14:23
|
|
|
|
package event
|
|
|
|
|
2023-02-01 14:41:09 +08:00
|
|
|
import "reflect"
|
|
|
|
|
2023-02-01 14:29:27 +08:00
|
|
|
const (
|
2023-02-01 18:46:18 +08:00
|
|
|
// OutEventTag 事件数据输出key的标签
|
|
|
|
OutEventTag = "event"
|
2023-02-01 14:29:27 +08:00
|
|
|
// JsonTag json输出的标签
|
|
|
|
JsonTag = "json"
|
|
|
|
// IgnoreTagValue 不做输出的标签值
|
|
|
|
IgnoreTagValue = "-"
|
|
|
|
// MappingTag 参数映射标签
|
|
|
|
MappingTag = "mapping"
|
2023-02-01 18:46:18 +08:00
|
|
|
// PriorityTag 处理数据时, mapping数据查找的优先级, 默认值 : field
|
|
|
|
PriorityTag = "priority"
|
|
|
|
// OmitemptyTag ...
|
|
|
|
OmitemptyTag = "omitempty"
|
2023-02-01 14:29:27 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
// MappingLocationAll 自动探测所有路径
|
|
|
|
MappingLocationAll = "all"
|
|
|
|
// MappingLocationParam 从参数读取
|
|
|
|
MappingLocationParam = "param"
|
|
|
|
// MappingLocationHeader 从请求header读取
|
|
|
|
MappingLocationHeader = "header"
|
|
|
|
// MappingLocationResponse 从响应数据读取
|
|
|
|
MappingLocationResponse = "response"
|
|
|
|
// MappingLocationExtension 从扩展数据读取
|
|
|
|
MappingLocationExtension = "extension"
|
|
|
|
)
|
|
|
|
|
2023-02-01 18:46:18 +08:00
|
|
|
var (
|
|
|
|
mappingLocationList = []string{
|
|
|
|
MappingLocationHeader,
|
|
|
|
MappingLocationParam,
|
|
|
|
MappingLocationResponse,
|
|
|
|
MappingLocationExtension,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
// SetMappingLocationList 只持续该默认的查找优先级
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 18:17 2023/2/1
|
|
|
|
func SetMappingLocationList(locationList []string) {
|
|
|
|
if len(locationList) > 0 {
|
|
|
|
mappingLocationList = locationList
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MappingRuleItem 规则
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 17:36 2023/2/1
|
|
|
|
type MappingRuleItem struct {
|
|
|
|
Location string `json:"location"` // 数据所在位置, header-请求头 param-参数获取 response-响应数据获取 extension-扩展数据读取 all-自动按照header/param/response/extension的顺序查询
|
|
|
|
Field string `json:"field"` // 查询的字段名称
|
|
|
|
}
|
|
|
|
|
2023-02-01 14:41:09 +08:00
|
|
|
// StructField 结构体字段信息
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 14:35 2023/2/1
|
|
|
|
type StructField struct {
|
2023-02-01 20:30:32 +08:00
|
|
|
Idx int // 字段在结构体的索引
|
|
|
|
Name string // 字段名
|
|
|
|
Type reflect.Kind // 字段类型
|
|
|
|
JsonTag string // json标签
|
|
|
|
EventTag string // 事件标签
|
|
|
|
MappingRuleList []MappingRuleItem // 规则列表
|
2023-02-01 14:29:27 +08:00
|
|
|
}
|
2023-02-01 18:46:18 +08:00
|
|
|
|
|
|
|
// StructInfo 结构体信息
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 16:17 2023/2/1
|
|
|
|
type StructInfo struct {
|
|
|
|
Flag string // 结构体标识
|
|
|
|
IsStruct bool // 是否为结构体
|
|
|
|
StructFieldList []*StructField // 结构体字段列表
|
|
|
|
}
|