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.
37 lines
818 B
Go
37 lines
818 B
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
type Order struct {
|
|
ID int
|
|
RequestID string
|
|
OrderSn string
|
|
Token string
|
|
User *User `gorm:"foreignKey:OrderSn;references:OrderSn"`
|
|
Project *Project `gorm:"foreignKey:OrderSn;references:OrderSn"`
|
|
Applicant *Applicant `gorm:"foreignKey:OrderSn;references:OrderSn"`
|
|
Assured *Assured `gorm:"foreignKey:OrderSn;references:OrderSn"`
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time `json:"-"`
|
|
}
|
|
|
|
func (Order) TableName() string {
|
|
return "order"
|
|
}
|
|
|
|
func (a Order) MarshalJSON() ([]byte, error) {
|
|
type Alias Order
|
|
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),
|
|
})
|
|
}
|