|
@ -95,7 +95,7 @@ func MapStringToInterface(src map[string]string) map[string]interface{} { |
|
|
return target |
|
|
return target |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//将interface转成map[string]interface
|
|
|
|
|
|
|
|
|
// 将interface转成map[string]interface
|
|
|
func InterfaceToMapInterface(data interface{}) (map[string]interface{}, error) { |
|
|
func InterfaceToMapInterface(data interface{}) (map[string]interface{}, error) { |
|
|
dataJson, err := json.Marshal(data) |
|
|
dataJson, err := json.Marshal(data) |
|
|
|
|
|
|
|
@ -109,7 +109,7 @@ func InterfaceToMapInterface(data interface{}) (map[string]interface{}, error) { |
|
|
return returnData, nil |
|
|
return returnData, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//将interface转成map[string]string
|
|
|
|
|
|
|
|
|
// 将interface转成map[string]string
|
|
|
func InterfaceToMapString(data interface{}) (map[string]string, error) { |
|
|
func InterfaceToMapString(data interface{}) (map[string]string, error) { |
|
|
dataJson, err := json.Marshal(data) |
|
|
dataJson, err := json.Marshal(data) |
|
|
|
|
|
|
|
@ -123,7 +123,7 @@ func InterfaceToMapString(data interface{}) (map[string]string, error) { |
|
|
return returnData, nil |
|
|
return returnData, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//将interface转成[]map[string]interface
|
|
|
|
|
|
|
|
|
// 将interface转成[]map[string]interface
|
|
|
func InterfaceToMapInterfaceArr(data interface{}) ([]map[string]interface{}, error) { |
|
|
func InterfaceToMapInterfaceArr(data interface{}) ([]map[string]interface{}, error) { |
|
|
dataJson, err := json.Marshal(data) |
|
|
dataJson, err := json.Marshal(data) |
|
|
|
|
|
|
|
@ -137,7 +137,7 @@ func InterfaceToMapInterfaceArr(data interface{}) ([]map[string]interface{}, err |
|
|
return returnData, nil |
|
|
return returnData, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//将interface转成[]map[string]string
|
|
|
|
|
|
|
|
|
// 将interface转成[]map[string]string
|
|
|
func InterfaceToMapStringArr(data interface{}) ([]map[string]string, error) { |
|
|
func InterfaceToMapStringArr(data interface{}) ([]map[string]string, error) { |
|
|
dataJson, err := json.Marshal(data) |
|
|
dataJson, err := json.Marshal(data) |
|
|
|
|
|
|
|
@ -292,3 +292,29 @@ func SetMapFirstToUpper(info map[string]interface{}) map[string]interface{} { |
|
|
} |
|
|
} |
|
|
return ret |
|
|
return ret |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* MAP合并,相同KEY以最后一个为准 |
|
|
|
|
|
* gz 2023/11/13 |
|
|
|
|
|
*/ |
|
|
|
|
|
func MergeMaps(map1 map[string]string, map2 ...map[string]string) map[string]string { |
|
|
|
|
|
mergedMap := make(map[string]string) |
|
|
|
|
|
|
|
|
|
|
|
if len(map1) > 0 { |
|
|
|
|
|
for key, value := range map1 { |
|
|
|
|
|
mergedMap[key] = value |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if len(map2) > 0 { |
|
|
|
|
|
for _, arr := range map2 { |
|
|
|
|
|
if len(arr) > 0 { |
|
|
|
|
|
for key, value := range arr { |
|
|
|
|
|
mergedMap[key] = value //以后个为准
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return mergedMap |
|
|
|
|
|
} |