package utils import jsoniter "github.com/json-iterator/go" func Convertion(dest map[string]interface{}, source string) { s := make(map[string]string) err := jsoniter.UnmarshalFromString(source, &s) if err != nil { return } for k, v := range s { // TODO 字段检查是否合规 // 判断是否非生产环境,非生产环境检查 if value, ok := dest[k]; ok { if _, ok = value.(string); ok && value.(string) == "" { dest[k] = v } /*if value == "" { dest[k] = v }*/ } else { dest[k] = v } } return } // 覆盖 func ConvertionCover(dest map[string]interface{}, source string) { s := make(map[string]string) err := jsoniter.UnmarshalFromString(source, &s) if err != nil { return } for k, v := range s { dest[k] = v } return } func GetInterfaceString(dest map[string]interface{}, key string) string { if value, ok := dest[key]; ok { if ret, ok := value.(string); ok { return ret } /*if value == "" { dest[k] = v }*/ } return "" }