feat: added hash to models

This commit is contained in:
Marvin Zhang
2024-08-26 18:33:46 +08:00
parent fdea835d53
commit 08d1acb15e
2 changed files with 14 additions and 0 deletions

12
core/utils/hash.go Normal file
View File

@@ -0,0 +1,12 @@
package utils
import "encoding/json"
func GetObjectHash(obj any) string {
data, _ := json.Marshal(obj)
if data == nil {
// random hash
return EncryptMd5(NewUUIDString())
}
return EncryptMd5(string(data))
}