|
|
|
@ -1,5 +1,10 @@
|
|
|
|
|
package types
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"git.noahlan.cn/noahlan/ntool/narr"
|
|
|
|
|
"git.noahlan.cn/noahlan/ntool/nlog"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Status string
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
@ -9,9 +14,26 @@ const (
|
|
|
|
|
StatusLocked Status = "Locked" // 锁定
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func (Status) Values() (kinds []string) {
|
|
|
|
|
for _, s := range []Status{StatusNormal, StatusPending, StatusDisabled, StatusLocked} {
|
|
|
|
|
kinds = append(kinds, string(s))
|
|
|
|
|
var statusVals = []string{
|
|
|
|
|
string(StatusNormal),
|
|
|
|
|
string(StatusPending),
|
|
|
|
|
string(StatusDisabled),
|
|
|
|
|
string(StatusLocked),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (Status) Values() (kinds []string) {
|
|
|
|
|
kinds = statusVals
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s Status) String() string {
|
|
|
|
|
return string(s)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ParseStatus(str string) Status {
|
|
|
|
|
if narr.StringsHas(statusVals, str) {
|
|
|
|
|
return Status(str)
|
|
|
|
|
}
|
|
|
|
|
nlog.Errorf("转换 %s 到 Status类型 失败,使用 Pending 替代", str)
|
|
|
|
|
return StatusPending
|
|
|
|
|
}
|
|
|
|
|