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 }