forked from ebhomengo/niki
43 lines
931 B
Go
43 lines
931 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]
|
|
}
|
|
|
|
func (s AdminStatus) IsValid() bool {
|
|
return s > 0 && int(s) <= len(AdminStatusStrings)
|
|
}
|
|
|
|
// 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)
|
|
}
|