2025-06-19 10:35:26 +08:00

58 lines
1.4 KiB
Go

package schema
import (
"github.com/google/uuid"
"gitlab.guxuan.icu/jinshan_community/pkg/util"
"gorm.io/gorm"
)
// Defining the `Order` struct.
type Order struct {
util.BaseModel
ProductID string `json:"productId" gorm:"type:char(36);index;comment:产品id"`
CustomerID string `json:"customerId" gorm:"type:char(36);index;comment:客户id"`
Num int `json:"num" gorm:"comment:商品个数"`
ShopID string `json:"shopId" gorm:"type:char(36);index;comment:店铺ID"`
Status string `json:"status" gorm:"size:20;index;comment:状态"`
}
func (c *Order) BeforeCreate(tx *gorm.DB) (err error) {
if c.ID == "" {
c.ID = uuid.New().String()
}
return
}
// Defining the query parameters for the `Order` struct.
type OrderQueryParam struct {
util.PaginationParam
}
// Defining the query options for the `Order` struct.
type OrderQueryOptions struct {
util.QueryOptions
}
// Defining the query result for the `Order` struct.
type OrderQueryResult struct {
Data Orders
PageResult *util.PaginationResult
}
// Defining the slice of `Order` struct.
type Orders []*Order
// Defining the data structure for creating a `Order` struct.
type OrderForm struct {
}
// A validation function for the `OrderForm` struct.
func (a *OrderForm) Validate() error {
return nil
}
// Convert `OrderForm` to `Order` object.
func (a *OrderForm) FillTo(order *Order) error {
return nil
}