diff --git a/models/shared.go b/models/shared.go index 2cde688..ecd6b94 100644 --- a/models/shared.go +++ b/models/shared.go @@ -2,6 +2,7 @@ package models import ( "database/sql/driver" + "encoding/json" "errors" "fmt" "gorm.io/gorm" @@ -31,6 +32,10 @@ type Interval struct { type CustomTime time.Time +func (j *CustomTime) MarshalJSON() ([]byte, error) { + return json.Marshal(j.String()) +} + func (j *CustomTime) UnmarshalJSON(b []byte) error { s := strings.Replace(strings.Trim(string(b), "\""), ".", "", 1) i, err := strconv.ParseInt(s, 10, 64) diff --git a/models/user.go b/models/user.go index 17e3dd3..81fee75 100644 --- a/models/user.go +++ b/models/user.go @@ -34,7 +34,7 @@ type CredentialsReset struct { type TimeByUser struct { User string - Time CustomTime `swaggertype:"string" format:"date" example:"2006-01-02 15:04:05.000"` + Time CustomTime } func (c *CredentialsReset) IsValid() bool {