增加合并数据方法
This commit is contained in:
parent
9120cd2c68
commit
e2a2e6a3c2
@ -35,6 +35,10 @@ type EasyMap interface {
|
||||
Count() int
|
||||
GetAll() map[interface{}]interface{}
|
||||
GetAllForMapKeyString() map[string]interface{}
|
||||
// Merge 合并数据
|
||||
Merge(mergeData ...EasyMap)
|
||||
// MergeWithReceiver 合并数据并转换
|
||||
MergeWithReceiver(receiver interface{}, mergeData ...EasyMap) error
|
||||
// Iterator 对数据的迭代
|
||||
Iterator(IteratorFunc)
|
||||
// ToStruct 转换成结构体
|
||||
|
27
common.go
27
common.go
@ -405,3 +405,30 @@ func (c *common) Filter(ignoreFieldList []string, rewriteFieldTable map[string]s
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Merge 合并数据
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 11:01 2024/3/11
|
||||
func (c *common) Merge(mergeData ...EasyMap) {
|
||||
for _, itemData := range mergeData {
|
||||
allData := itemData.GetAll()
|
||||
for k, v := range allData {
|
||||
c.Set(k, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MergeWithReceiver 合并并转换
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 11:06 2024/3/11
|
||||
func (c *common) MergeWithReceiver(receiver interface{}, mergeData ...EasyMap) error {
|
||||
c.Merge(mergeData...)
|
||||
if nil == receiver {
|
||||
return nil
|
||||
}
|
||||
return c.ToStruct(receiver)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user