From c11a88e9f2fd3bd0a6c12c71c21f0a5f74e11a04 Mon Sep 17 00:00:00 2001 From: "DESKTOP-4RNDQIC\\29019" <290198252@qq.com> Date: Wed, 10 Feb 2021 23:57:22 +0800 Subject: [PATCH] no message --- model/book.go | 2 ++ utils/OrmTimeHook.go | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/model/book.go b/model/book.go index 3df70b5..c0938ca 100644 --- a/model/book.go +++ b/model/book.go @@ -1,5 +1,7 @@ package model + import "background/utils" + // Book sss type Book struct { ID int64 `gorm:"column:id;primaryKey;default:0" sql:"id" json:"id"` diff --git a/utils/OrmTimeHook.go b/utils/OrmTimeHook.go index ad1c0a2..f7b8474 100644 --- a/utils/OrmTimeHook.go +++ b/utils/OrmTimeHook.go @@ -3,6 +3,7 @@ package utils import ( "database/sql/driver" "fmt" + "log" "reflect" "time" ) @@ -18,7 +19,8 @@ func (t OrmTime) MarshalJSON() ([]byte, error) { } //JSON中解析到程序中 func (t *OrmTime) UnmarshalJSON(data []byte) (err error) { - now, err := time.ParseInLocation(`"`+"2006-01-02 15:04:05"+`"`, string(data), time.Local) + log.Print(string(data)) + now, err := time.ParseInLocation(`"2006-01-02 15:04:05"`, string(data), time.Local) *t = OrmTime{Time: now} return }