refactor: 组件升级、代码优化

This commit is contained in:
meilin.huang
2023-05-24 12:32:17 +08:00
parent 4fa52412c1
commit 9900b236ef
48 changed files with 777 additions and 345 deletions

24
server/pkg/utils/json.go Normal file
View File

@@ -0,0 +1,24 @@
package utils
import (
"encoding/json"
"mayfly-go/pkg/global"
)
func Json2Map(jsonStr string) map[string]interface{} {
var res map[string]interface{}
if jsonStr == "" {
return res
}
_ = json.Unmarshal([]byte(jsonStr), &res)
return res
}
func ToJsonStr(val any) string {
if strBytes, err := json.Marshal(val); err != nil {
global.Log.Error("toJsonStr error: ", err)
return ""
} else {
return string(strBytes)
}
}