no message

master
DESKTOP-4RNDQIC\29019 2021-02-10 23:57:22 +08:00
parent 0c8de11e3e
commit c11a88e9f2
2 changed files with 5 additions and 1 deletions

View File

@ -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"`

View File

@ -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
}