对外暴露compare方法
This commit is contained in:
25
tool/diff.go
25
tool/diff.go
@ -7,9 +7,34 @@
|
||||
// Date : 2024-03-08 11:03
|
||||
package tool
|
||||
|
||||
import (
|
||||
"git.zhangdeman.cn/zhangdeman/wrapper"
|
||||
"git.zhangdeman.cn/zhangdeman/wrapper/tool/define"
|
||||
)
|
||||
|
||||
var (
|
||||
Diff = &diff{}
|
||||
)
|
||||
|
||||
type diff struct {
|
||||
}
|
||||
|
||||
// Compare 比较两个数据源的指定字段
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 15:53 2024/3/8
|
||||
func (d *diff) Compare(fieldList []string, input wrapper.Map, storage wrapper.Map, option *define.DiffOption) map[string]*define.DiffResult {
|
||||
if nil == option {
|
||||
option = define.NewDiffOption()
|
||||
}
|
||||
res := make(map[string]*define.DiffResult)
|
||||
for _, itemField := range fieldList {
|
||||
if compareFunc, exist := option.CustomDiffFuncTable[itemField]; exist && nil != compareFunc {
|
||||
res[itemField] = compareFunc(itemField, input, storage, option)
|
||||
} else {
|
||||
res[itemField] = define.DefaultDiffFunc(itemField, input, storage, option)
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
Reference in New Issue
Block a user