niki/entity/benefactor_status.go

39 lines
944 B
Go

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