haibei/internal/mods/customer/schema/product_order.go
2025-06-19 10:33:58 +08:00

60 lines
1.8 KiB
Go

package schema
import (
"github.guxuan/haibei/pkg/util"
)
// Defining the `ProductOrder` struct.
type ProductOrder struct {
util.BaseModel
CustomerID uint `json:"customerId" gorm:"index;comment:用户id"`
ProductID uint `json:"productId" gorm:"index;comment:商品id"`
MentorID string `json:"mentorId" gorm:"index;comment:顾问id"`
Status string `json:"status" gorm:"size:20;index;comment:状态"`
}
// De OrderNo string `json:"orderNo" gorm:"size:128;index;comment:订单号"`fining the query parameters for the `ProductOrder` struct.
type ProductOrderQueryParam struct {
util.PaginationParam
CustomerID uint `form:"customerId" `
ProductID uint `form:"productId" `
MentorID string `form:"mentorId"`
Status string `form:"status"`
}
// Defining the query options for the `ProductOrder` struct.
type ProductOrderQueryOptions struct {
util.QueryOptions
}
// Defining the query result for the `ProductOrder` struct.
type ProductOrderQueryResult struct {
Data ProductOrders
PageResult *util.PaginationResult
}
// Defining the slice of `ProductOrder` struct.
type ProductOrders []*ProductOrder
// Defining the data structure for creating a `ProductOrder` struct.
type ProductOrderForm struct {
CustomerID uint `json:"customerId" `
ProductID uint `json:"productId" `
MentorID string `json:"mentorId"`
Status string `json:"status"`
}
// A validation function for the `ProductOrderForm` struct.
func (a *ProductOrderForm) Validate() error {
return nil
}
// Convert `ProductOrderForm` to `ProductOrder` object.
func (a *ProductOrderForm) FillTo(productOrder *ProductOrder) error {
productOrder.CustomerID = a.CustomerID
productOrder.ProductID = a.ProductID
productOrder.MentorID = a.MentorID
productOrder.Status = a.Status
return nil
}