no message
parent
0c8de11e3e
commit
c11a88e9f2
|
@ -1,5 +1,7 @@
|
||||||
package model
|
package model
|
||||||
|
|
||||||
import "background/utils"
|
import "background/utils"
|
||||||
|
|
||||||
// Book sss
|
// Book sss
|
||||||
type Book struct {
|
type Book struct {
|
||||||
ID int64 `gorm:"column:id;primaryKey;default:0" sql:"id" json:"id"`
|
ID int64 `gorm:"column:id;primaryKey;default:0" sql:"id" json:"id"`
|
||||||
|
|
|
@ -3,6 +3,7 @@ package utils
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -18,7 +19,8 @@ func (t OrmTime) MarshalJSON() ([]byte, error) {
|
||||||
}
|
}
|
||||||
//JSON中解析到程序中
|
//JSON中解析到程序中
|
||||||
func (t *OrmTime) UnmarshalJSON(data []byte) (err error) {
|
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}
|
*t = OrmTime{Time: now}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue