niki/entity/staff_status.go

39 lines
839 B
Go
Raw Normal View History

package entity
type StaffStatus uint
const (
StaffActiveStatus StaffStatus = iota + 1
StaffDeactiveStatus
)
var StaffStatusStrings = map[StaffStatus]string{
StaffActiveStatus: "active",
StaffDeactiveStatus: "deactive",
}
func (s StaffStatus) String() string {
return StaffStatusStrings[s]
}
// AllStaffStatus returns a slice containing all string values of StaffStatus.
func AllStaffStatus() []string {
statusStrings := make([]string, len(StaffStatusStrings))
for status, str := range StaffStatusStrings {
statusStrings[int(status)-1] = str
}
return statusStrings
}
// MapToStaffStatus converts a string to the corresponding StaffStatus value.
func MapToStaffStatus(statusStr string) StaffStatus {
for status, str := range StaffStatusStrings {
if str == statusStr {
return status
}
}
return StaffStatus(0)
}