package model import ( "encoding/json" "time" ) type Claim struct { ID int PolicyNo string BankName string AccountName string ContactName string ContactPhone string FileList string BankCardNum string BackPremium string Reason string Status string Msg string CreatedAt time.Time UpdatedAt time.Time `json:"-"` } func (Claim) TableName() string { return "claim" } func (a Claim) MarshalJSON() ([]byte, error) { type Alias Claim 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), }) }