save code
This commit is contained in:
parent
cbde9c3707
commit
4ed5891065
44
filter.go
44
filter.go
@ -54,8 +54,11 @@ func (f *filter) Deal() error {
|
||||
)
|
||||
|
||||
for _, rule := range f.filterRuleList {
|
||||
if strings.Contains(rule.SourcePath, "[]") {
|
||||
if f.IsArray(rule) {
|
||||
// 对于list的处理
|
||||
if err = f.handleArray(rule); nil != err {
|
||||
return err
|
||||
}
|
||||
continue
|
||||
}
|
||||
sourceResult := gjson.Get(f.sourceData, rule.SourcePath)
|
||||
@ -79,6 +82,45 @@ func (f *filter) Deal() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsArray 判断是否为数组
|
||||
//
|
||||
// Author : zhangdeman001@ke.com<张德满>
|
||||
//
|
||||
// Date : 17:48 2023/1/1
|
||||
func (f *filter) IsArray(rule MapRule) bool {
|
||||
return strings.Contains(rule.SourcePath, "[]")
|
||||
}
|
||||
|
||||
// handleArray 处理数组(最复杂的场景)
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 17:41 2023/1/1
|
||||
func (f *filter) handleArray(rule MapRule) error {
|
||||
sourcePathArray := strings.Split(rule.SourcePath, "[]")
|
||||
mapPathArray := strings.Split(rule.MapPath, "[]")
|
||||
if len(sourcePathArray) != len(mapPathArray) {
|
||||
if len(mapPathArray) != 1 {
|
||||
return errors.New("map rule is invalid")
|
||||
}
|
||||
// 提取某一个list下的字段, 组成一个list
|
||||
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// getAllFinalData ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:42 2023/1/1
|
||||
func (f *filter) getAllFinalData(pathArr []string) []string {
|
||||
res := make([]string, 0)
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
// String 获取格式化之后的字符串
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
|
Loading…
Reference in New Issue
Block a user