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.
42 lines
1.0 KiB
Go
42 lines
1.0 KiB
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
type Order struct {
|
|
ID int
|
|
RequestID string
|
|
OrderNo string
|
|
OrderSn string
|
|
Token string
|
|
Status string
|
|
PayUrl string
|
|
User *User `gorm:"foreignKey:OrderNo;references:OrderNo"`
|
|
Project *Project `gorm:"foreignKey:OrderNo;references:OrderNo"`
|
|
Applicant *Applicant `gorm:"foreignKey:OrderNo;references:OrderNo"`
|
|
Assured *Assured `gorm:"foreignKey:OrderNo;references:OrderNo"`
|
|
OrderResult *OrderResult `gorm:"foreignKey:OrderNo;references:OrderNo"`
|
|
Invoice *Invoice `gorm:"foreignKey:OrderNo;references:OrderNo"`
|
|
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),
|
|
})
|
|
}
|