增加仅比较一个字段方法

This commit is contained in:
白茶清欢 2024-03-08 15:58:58 +08:00
parent 4d25a2a650
commit c07adaf249

View File

@ -30,11 +30,23 @@ func (d *diff) Compare(fieldList []string, input wrapper.Map, storage wrapper.Ma
}
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)
}
res[itemField] = d.CompareSingle(itemField, input, storage, option)
}
return res
}
// CompareSingle 比较一个字段
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 15:57 2024/3/8
func (d *diff) CompareSingle(field string, input wrapper.Map, storage wrapper.Map, option *define.DiffOption) *define.DiffResult {
if nil == option {
option = define.NewDiffOption()
}
if compareFunc, exist := option.CustomDiffFuncTable[field]; exist && nil != compareFunc {
return compareFunc(field, input, storage, option)
} else {
return define.DefaultDiffFunc(field, input, storage, option)
}
}