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.

34 lines
617 B
Go

4 months ago
package model
import (
"encoding/json"
"time"
)
type Invoice struct {
ID int
OrderNo string
Header string
TaxNumber string
Order *Order `gorm:"foreignKey:OrderNo;references:OrderNo"`
CreatedAt time.Time
UpdatedAt time.Time `json:"-"`
}
func (Invoice) TableName() string {
return "invoice"
}
func (a Invoice) MarshalJSON() ([]byte, error) {
type Alias Invoice
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),
})
}