preorder/orders/models.go
2024-06-19 22:49:55 -04:00

44 lines
1.1 KiB
Go

package orders
import (
"preorder/authors"
"preorder/formats"
"time"
)
type Order struct {
ID uint `json:"id" gorm:"primary_key"`
Title string `json:"title"`
AuthorID uint `json:"author"`
Author authors.Author
ReleaseDate time.Time `json:"release_date" gorm:"column:release_date"`
ISBN13 uint `json:"isbn_13" gorm:"column:isbn_13"`
FormatID uint `json:"format"`
Format formats.Format
}
type CreateOrderInput struct {
ID uint `json:"id" binding:"required"`
Title string `json:"title" binding:"required"`
Author uint `json:"author" binding:"required"`
Format uint `json:"format" binding:"required"`
ReleaseDate time.Time `json:"release_date"`
ISBN13 uint `json:"isbn_13" binding:"required"`
}
type UpdateOrderInput struct {
Title string `json:"title"`
}
func NewOrder(id uint, title string, author uint, format uint, isbn_13 uint, release_date time.Time) Order {
order := Order{
ID: id,
Title: title,
AuthorID: author,
FormatID: format,
ISBN13: isbn_13,
ReleaseDate: release_date,
}
return order
}