You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
540 B
Go

7 months ago
package model
import (
"encoding/json"
"time"
)
type Admin struct {
ID int
Username string
PasswordHash string `json:"-"`
CreatedAt time.Time
UpdatedAt time.Time
}
func (Admin) TableName() string {
return "admins"
}
func (a Admin) MarshalJSON() ([]byte, error) {
type Alias Admin
return json.Marshal(&struct {
CreatedAt string
UpdatedAt string
*Alias
}{
CreatedAt: a.CreatedAt.Format("2006-01-02 15:04:05"),
UpdatedAt: a.UpdatedAt.Format("2006-01-02 15:04:05"),
Alias: (*Alias)(&a),
})
}