Compare commits
No commits in common. "5a2df69ffe6bf05279dbd9328667bca5893021c0" and "a87a97b0e8d48ea643998e0aaab1eaca9a6ba5d5" have entirely different histories.
5a2df69ffe
...
a87a97b0e8
@ -41,6 +41,4 @@ type EasyMap interface {
|
|||||||
ToStruct(receiver interface{}) error
|
ToStruct(receiver interface{}) error
|
||||||
// ToString 转为字符串
|
// ToString 转为字符串
|
||||||
ToString() string
|
ToString() string
|
||||||
// Filter 过滤数据
|
|
||||||
Filter(ignoreFieldList []string, rewriteFieldTable map[string]interface{}) map[string]interface{}
|
|
||||||
}
|
}
|
||||||
|
25
common.go
25
common.go
@ -374,28 +374,3 @@ func (c *common) ToString() string {
|
|||||||
mapData := c.GetAllForMapKeyString()
|
mapData := c.GetAllForMapKeyString()
|
||||||
return serialize.JSON.MarshalForString(mapData)
|
return serialize.JSON.MarshalForString(mapData)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter 对数据进行过滤
|
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 16:25 2024/3/8
|
|
||||||
func (c *common) Filter(ignoreFieldList []string, rewriteFieldTable map[string]string) map[string]interface{} {
|
|
||||||
result := make(map[string]interface{})
|
|
||||||
ignoreFieldTable := make(map[string]bool)
|
|
||||||
for _, item := range ignoreFieldList {
|
|
||||||
ignoreFieldTable[item] = true
|
|
||||||
}
|
|
||||||
data := c.GetAllForMapKeyString()
|
|
||||||
for field, val := range data {
|
|
||||||
if _, exist := ignoreFieldTable[field]; exist {
|
|
||||||
// 忽略当前字段
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if rewriteField, exist := rewriteFieldTable[field]; exist && len(rewriteField) > 0 {
|
|
||||||
field = rewriteField
|
|
||||||
}
|
|
||||||
result[field] = val
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user