diff --git a/tool/diff.go b/tool/diff.go index 1b47618..3d2783a 100644 --- a/tool/diff.go +++ b/tool/diff.go @@ -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) + } +}