forked from ebhomengo/niki
39 lines
839 B
Go
39 lines
839 B
Go
package entity
|
|
|
|
type AdminStatus uint
|
|
|
|
const (
|
|
AdminActiveStatus AdminStatus = iota + 1
|
|
AdminDeactiveStatus
|
|
)
|
|
|
|
var AdminStatusStrings = map[AdminStatus]string{
|
|
AdminActiveStatus: "active",
|
|
AdminDeactiveStatus: "deactive",
|
|
}
|
|
|
|
func (s AdminStatus) String() string {
|
|
return AdminStatusStrings[s]
|
|
}
|
|
|
|
// AllAdminStatus returns a slice containing all string values of AdminStatus.
|
|
func AllAdminStatus() []string {
|
|
statusStrings := make([]string, len(AdminStatusStrings))
|
|
for status, str := range AdminStatusStrings {
|
|
statusStrings[int(status)-1] = str
|
|
}
|
|
|
|
return statusStrings
|
|
}
|
|
|
|
// MapToAdminStatus converts a string to the corresponding AdminStatus value.
|
|
func MapToAdminStatus(statusStr string) AdminStatus {
|
|
for status, str := range AdminStatusStrings {
|
|
if str == statusStr {
|
|
return status
|
|
}
|
|
}
|
|
|
|
return AdminStatus(0)
|
|
}
|