update
This commit is contained in:
64
define.go
64
define.go
@ -7,63 +7,15 @@
|
||||
// Date : 2022-07-04 18:02
|
||||
package filter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/util"
|
||||
)
|
||||
|
||||
// jsonNode json语法树节点定义
|
||||
// MapRule 映射规则
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:06 2022/7/4
|
||||
type jsonNode struct {
|
||||
Name string // 节点名称
|
||||
Parent *jsonNode // 父节点
|
||||
Son *jsonNode // 子节点
|
||||
PreBrother *jsonNode // 前一个兄弟节点
|
||||
NextBrother *jsonNode // 下一个兄弟节点
|
||||
Val interface{} // 节点的值
|
||||
Type string // 数据类型
|
||||
// Date : 12:21 2022/7/4
|
||||
type MapRule struct {
|
||||
SourcePath string `json:"source_path"` // 原路径
|
||||
MapPath string `json:"map_path"` // 映射路径
|
||||
Required bool `json:"required"` // 必须存在
|
||||
DataType string `json:"data_type"` // 数据类型
|
||||
DefaultValue string `json:"default_value"` // 默认值, 以字符串传入, 会转换成 DataType
|
||||
}
|
||||
|
||||
// lexicalNode 词法分析的节点
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:02 2022/7/4
|
||||
type lexicalNode struct {
|
||||
Val interface{} // 词法分析出来的词
|
||||
Type string // 值得类型
|
||||
Show bool // 这个值是否对外呈现
|
||||
IsToken bool // 是否为关键字
|
||||
OutputFormat string // 对外输出的格式
|
||||
}
|
||||
|
||||
// ValStr 值转为字符串
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 14:10 2022/7/5
|
||||
func (l *lexicalNode) ValStr() string {
|
||||
if l.Type == "number" {
|
||||
var str string
|
||||
_ = util.ConvertAssign(&str, l.Val)
|
||||
return str
|
||||
}
|
||||
return fmt.Sprintf("%v", l.Val)
|
||||
}
|
||||
|
||||
const (
|
||||
// NodeTypeNumber 数据类型
|
||||
NodeTypeNumber = "number"
|
||||
// NodeTypeBool bool 类型
|
||||
NodeTypeBool = "bool"
|
||||
// NodeTypeString 字符串类型
|
||||
NodeTypeString = "string"
|
||||
// NodeTypeObject kv 对象类型
|
||||
NodeTypeObject = "object"
|
||||
// NodeTypeList list类型
|
||||
NodeTypeList = "list"
|
||||
)
|
||||
|
Reference in New Issue
Block a user