2025-06-04 02:41:50 +08:00
|
|
|
package serialization
|
2025-06-04 02:40:13 +08:00
|
|
|
|
|
|
|
import (
|
2025-06-04 23:11:32 +08:00
|
|
|
"fmt"
|
2025-06-04 02:40:13 +08:00
|
|
|
"game/common/model/user"
|
|
|
|
"testing"
|
2025-06-04 23:11:32 +08:00
|
|
|
"time"
|
2025-06-04 02:40:13 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func Test_zz(t *testing.T) {
|
2025-06-04 23:11:32 +08:00
|
|
|
us := &user.UserAccount{
|
|
|
|
ID: 17,
|
|
|
|
Username: "test001",
|
|
|
|
Password: "123456",
|
|
|
|
Email: "",
|
|
|
|
Phone: "",
|
|
|
|
DeviceID: "",
|
|
|
|
LastLoginIP: "127.0.0.1",
|
|
|
|
LastLoginTime: time.Now(),
|
|
|
|
Status: 0,
|
|
|
|
RegisterIP: "",
|
|
|
|
RegisterTime: time.Now(),
|
|
|
|
}
|
|
|
|
maps := StructToMap(us)
|
|
|
|
t.Log(maps)
|
|
|
|
mapString := make(map[string]string)
|
|
|
|
for key, value := range maps {
|
|
|
|
mapString[key] = fmt.Sprintf("%v", value)
|
|
|
|
}
|
2025-06-04 02:40:13 +08:00
|
|
|
|
|
|
|
var err error
|
2025-06-04 23:11:32 +08:00
|
|
|
us, err = MapToStruct[user.UserAccount](mapString)
|
2025-06-04 02:40:13 +08:00
|
|
|
t.Log(err)
|
|
|
|
t.Log(us)
|
|
|
|
}
|