65 lines
1.1 KiB
Go
65 lines
1.1 KiB
Go
|
package enum
|
|||
|
|
|||
|
type CompletionStatus int
|
|||
|
|
|||
|
const (
|
|||
|
DRAFTED CompletionStatus = iota
|
|||
|
PENDING
|
|||
|
CANCEL
|
|||
|
PARTIAL
|
|||
|
PAID
|
|||
|
DISPUTED
|
|||
|
OVERDUE
|
|||
|
REFUND
|
|||
|
)
|
|||
|
|
|||
|
func (d CompletionStatus) String() string {
|
|||
|
return [...]string{"drafted", "pending", "cancel", "partial", "paid", "disputed", "overdue", "refund"}[d]
|
|||
|
}
|
|||
|
|
|||
|
func CompletionStatusList() []CompletionStatus {
|
|||
|
return []CompletionStatus{DRAFTED, PENDING, CANCEL, PARTIAL, PAID, DISPUTED, OVERDUE, REFUND}
|
|||
|
}
|
|||
|
|
|||
|
type BookingStatus int
|
|||
|
|
|||
|
const (
|
|||
|
DRAFT BookingStatus = iota
|
|||
|
SCHEDULED
|
|||
|
STARTED
|
|||
|
FAILURE
|
|||
|
SUCCESS
|
|||
|
FORGOTTEN
|
|||
|
DELAYED
|
|||
|
CANCELLED
|
|||
|
)
|
|||
|
|
|||
|
var str = [...]string{
|
|||
|
"draft",
|
|||
|
"scheduled",
|
|||
|
"started",
|
|||
|
"failure",
|
|||
|
"success",
|
|||
|
"forgotten",
|
|||
|
"delayed",
|
|||
|
"cancelled",
|
|||
|
}
|
|||
|
|
|||
|
func FromInt(i int) string {
|
|||
|
return str[i]
|
|||
|
}
|
|||
|
|
|||
|
func (d BookingStatus) String() string {
|
|||
|
return str[d]
|
|||
|
}
|
|||
|
|
|||
|
// EnumIndex - Creating common behavior - give the type a EnumIndex functio
|
|||
|
func (d BookingStatus) EnumIndex() int {
|
|||
|
return int(d)
|
|||
|
}
|
|||
|
|
|||
|
// List
|
|||
|
func StatusList() []BookingStatus {
|
|||
|
return []BookingStatus{DRAFT, SCHEDULED, STARTED, FAILURE, SUCCESS, FORGOTTEN, DELAYED, CANCELLED}
|
|||
|
}
|