feat: add orders
This commit is contained in:
259
backend/database/fields/orders.gen.go
Normal file
259
backend/database/fields/orders.gen.go
Normal file
@@ -0,0 +1,259 @@
|
||||
// Code generated by go-enum DO NOT EDIT.
|
||||
// Version: -
|
||||
// Revision: -
|
||||
// Build Date: -
|
||||
// Built By: -
|
||||
|
||||
package fields
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
// OrderStatusPending is a OrderStatus of type Pending.
|
||||
OrderStatusPending OrderStatus = iota
|
||||
// OrderStatusPaid is a OrderStatus of type Paid.
|
||||
OrderStatusPaid
|
||||
// OrderStatusRefunding is a OrderStatus of type Refunding.
|
||||
OrderStatusRefunding
|
||||
// OrderStatusRefunded is a OrderStatus of type Refunded.
|
||||
OrderStatusRefunded
|
||||
// OrderStatusCancelled is a OrderStatus of type Cancelled.
|
||||
OrderStatusCancelled
|
||||
// OrderStatusCompleted is a OrderStatus of type Completed.
|
||||
OrderStatusCompleted
|
||||
)
|
||||
|
||||
var ErrInvalidOrderStatus = fmt.Errorf("not a valid OrderStatus, try [%s]", strings.Join(_OrderStatusNames, ", "))
|
||||
|
||||
const _OrderStatusName = "pendingpaidrefundingrefundedcancelledcompleted"
|
||||
|
||||
var _OrderStatusNames = []string{
|
||||
_OrderStatusName[0:7],
|
||||
_OrderStatusName[7:11],
|
||||
_OrderStatusName[11:20],
|
||||
_OrderStatusName[20:28],
|
||||
_OrderStatusName[28:37],
|
||||
_OrderStatusName[37:46],
|
||||
}
|
||||
|
||||
// OrderStatusNames returns a list of possible string values of OrderStatus.
|
||||
func OrderStatusNames() []string {
|
||||
tmp := make([]string, len(_OrderStatusNames))
|
||||
copy(tmp, _OrderStatusNames)
|
||||
return tmp
|
||||
}
|
||||
|
||||
// OrderStatusValues returns a list of the values for OrderStatus
|
||||
func OrderStatusValues() []OrderStatus {
|
||||
return []OrderStatus{
|
||||
OrderStatusPending,
|
||||
OrderStatusPaid,
|
||||
OrderStatusRefunding,
|
||||
OrderStatusRefunded,
|
||||
OrderStatusCancelled,
|
||||
OrderStatusCompleted,
|
||||
}
|
||||
}
|
||||
|
||||
var _OrderStatusMap = map[OrderStatus]string{
|
||||
OrderStatusPending: _OrderStatusName[0:7],
|
||||
OrderStatusPaid: _OrderStatusName[7:11],
|
||||
OrderStatusRefunding: _OrderStatusName[11:20],
|
||||
OrderStatusRefunded: _OrderStatusName[20:28],
|
||||
OrderStatusCancelled: _OrderStatusName[28:37],
|
||||
OrderStatusCompleted: _OrderStatusName[37:46],
|
||||
}
|
||||
|
||||
// String implements the Stringer interface.
|
||||
func (x OrderStatus) String() string {
|
||||
if str, ok := _OrderStatusMap[x]; ok {
|
||||
return str
|
||||
}
|
||||
return fmt.Sprintf("OrderStatus(%d)", x)
|
||||
}
|
||||
|
||||
// IsValid provides a quick way to determine if the typed value is
|
||||
// part of the allowed enumerated values
|
||||
func (x OrderStatus) IsValid() bool {
|
||||
_, ok := _OrderStatusMap[x]
|
||||
return ok
|
||||
}
|
||||
|
||||
var _OrderStatusValue = map[string]OrderStatus{
|
||||
_OrderStatusName[0:7]: OrderStatusPending,
|
||||
_OrderStatusName[7:11]: OrderStatusPaid,
|
||||
_OrderStatusName[11:20]: OrderStatusRefunding,
|
||||
_OrderStatusName[20:28]: OrderStatusRefunded,
|
||||
_OrderStatusName[28:37]: OrderStatusCancelled,
|
||||
_OrderStatusName[37:46]: OrderStatusCompleted,
|
||||
}
|
||||
|
||||
// ParseOrderStatus attempts to convert a string to a OrderStatus.
|
||||
func ParseOrderStatus(name string) (OrderStatus, error) {
|
||||
if x, ok := _OrderStatusValue[name]; ok {
|
||||
return x, nil
|
||||
}
|
||||
return OrderStatus(0), fmt.Errorf("%s is %w", name, ErrInvalidOrderStatus)
|
||||
}
|
||||
|
||||
var errOrderStatusNilPtr = errors.New("value pointer is nil") // one per type for package clashes
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (x *OrderStatus) Scan(value interface{}) (err error) {
|
||||
if value == nil {
|
||||
*x = OrderStatus(0)
|
||||
return
|
||||
}
|
||||
|
||||
// A wider range of scannable types.
|
||||
// driver.Value values at the top of the list for expediency
|
||||
switch v := value.(type) {
|
||||
case int64:
|
||||
*x = OrderStatus(v)
|
||||
case string:
|
||||
*x, err = ParseOrderStatus(v)
|
||||
if err != nil {
|
||||
// try parsing the integer value as a string
|
||||
if val, verr := strconv.Atoi(v); verr == nil {
|
||||
*x, err = OrderStatus(val), nil
|
||||
}
|
||||
}
|
||||
case []byte:
|
||||
*x, err = ParseOrderStatus(string(v))
|
||||
if err != nil {
|
||||
// try parsing the integer value as a string
|
||||
if val, verr := strconv.Atoi(string(v)); verr == nil {
|
||||
*x, err = OrderStatus(val), nil
|
||||
}
|
||||
}
|
||||
case OrderStatus:
|
||||
*x = v
|
||||
case int:
|
||||
*x = OrderStatus(v)
|
||||
case *OrderStatus:
|
||||
if v == nil {
|
||||
return errOrderStatusNilPtr
|
||||
}
|
||||
*x = *v
|
||||
case uint:
|
||||
*x = OrderStatus(v)
|
||||
case uint64:
|
||||
*x = OrderStatus(v)
|
||||
case *int:
|
||||
if v == nil {
|
||||
return errOrderStatusNilPtr
|
||||
}
|
||||
*x = OrderStatus(*v)
|
||||
case *int64:
|
||||
if v == nil {
|
||||
return errOrderStatusNilPtr
|
||||
}
|
||||
*x = OrderStatus(*v)
|
||||
case float64: // json marshals everything as a float64 if it's a number
|
||||
*x = OrderStatus(v)
|
||||
case *float64: // json marshals everything as a float64 if it's a number
|
||||
if v == nil {
|
||||
return errOrderStatusNilPtr
|
||||
}
|
||||
*x = OrderStatus(*v)
|
||||
case *uint:
|
||||
if v == nil {
|
||||
return errOrderStatusNilPtr
|
||||
}
|
||||
*x = OrderStatus(*v)
|
||||
case *uint64:
|
||||
if v == nil {
|
||||
return errOrderStatusNilPtr
|
||||
}
|
||||
*x = OrderStatus(*v)
|
||||
case *string:
|
||||
if v == nil {
|
||||
return errOrderStatusNilPtr
|
||||
}
|
||||
*x, err = ParseOrderStatus(*v)
|
||||
if err != nil {
|
||||
// try parsing the integer value as a string
|
||||
if val, verr := strconv.Atoi(*v); verr == nil {
|
||||
*x, err = OrderStatus(val), nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (x OrderStatus) Value() (driver.Value, error) {
|
||||
return int64(x), nil
|
||||
}
|
||||
|
||||
// Set implements the Golang flag.Value interface func.
|
||||
func (x *OrderStatus) Set(val string) error {
|
||||
v, err := ParseOrderStatus(val)
|
||||
*x = v
|
||||
return err
|
||||
}
|
||||
|
||||
// Get implements the Golang flag.Getter interface func.
|
||||
func (x *OrderStatus) Get() interface{} {
|
||||
return *x
|
||||
}
|
||||
|
||||
// Type implements the github.com/spf13/pFlag Value interface.
|
||||
func (x *OrderStatus) Type() string {
|
||||
return "OrderStatus"
|
||||
}
|
||||
|
||||
type NullOrderStatus struct {
|
||||
OrderStatus OrderStatus
|
||||
Valid bool
|
||||
}
|
||||
|
||||
func NewNullOrderStatus(val interface{}) (x NullOrderStatus) {
|
||||
x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
|
||||
return
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (x *NullOrderStatus) Scan(value interface{}) (err error) {
|
||||
if value == nil {
|
||||
x.OrderStatus, x.Valid = OrderStatus(0), false
|
||||
return
|
||||
}
|
||||
|
||||
err = x.OrderStatus.Scan(value)
|
||||
x.Valid = (err == nil)
|
||||
return
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (x NullOrderStatus) Value() (driver.Value, error) {
|
||||
if !x.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
// driver.Value accepts int64 for int values.
|
||||
return int64(x.OrderStatus), nil
|
||||
}
|
||||
|
||||
type NullOrderStatusStr struct {
|
||||
NullOrderStatus
|
||||
}
|
||||
|
||||
func NewNullOrderStatusStr(val interface{}) (x NullOrderStatusStr) {
|
||||
x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
|
||||
return
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (x NullOrderStatusStr) Value() (driver.Value, error) {
|
||||
if !x.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return x.OrderStatus.String(), nil
|
||||
}
|
||||
7
backend/database/fields/orders.go
Normal file
7
backend/database/fields/orders.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package fields
|
||||
|
||||
// swagger:enum OrderStatus
|
||||
// ENUM( pending, paid, refunding, refunded, cancelled, completed)
|
||||
type OrderStatus int16
|
||||
|
||||
type OrderMeta struct{}
|
||||
Reference in New Issue
Block a user