package model import ( "encoding/json" "time" ) type Applicant struct { ID int OrderNo string ApplicantName string CreditVld string CreditCode string ContactName string ContactMobile string ComTelArea string Province string City string District string Address string Email string LegalName string LegalNum string ComTelNum string LicenseFiles string InvoiceAcceptEmail string InvoiceType string SignUrl string SignedUrl string Order *Order `gorm:"foreignKey:OrderNo;references:OrderNo"` CreatedAt time.Time UpdatedAt time.Time `json:"-"` } func (Applicant) TableName() string { return "applicant" } func (a Applicant) MarshalJSON() ([]byte, error) { type Alias Applicant 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), }) }