parent
5ca627bd1f
commit
33b23ccb75
@ -1,17 +1,39 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"git.noahlan.cn/noahlan/ntool/narr"
|
||||
"git.noahlan.cn/noahlan/ntool/nlog"
|
||||
)
|
||||
|
||||
type Status string
|
||||
|
||||
const (
|
||||
StatusNormal Status = "Normal" // 正常状态
|
||||
StatusPending Status = "Pending" // 等待状态
|
||||
StatusDisabled Status = "Disabled" // 禁用
|
||||
StatusLocked Status = "Locked" // 锁定
|
||||
StatusNormal Status = "Normal" // 正常状态
|
||||
StatusPending Status = "Pending" // 等待状态
|
||||
StatusDisabled Status = "Disabled" // 禁用
|
||||
StatusLocked Status = "Locked" // 锁定
|
||||
)
|
||||
|
||||
var statusVals = []string{
|
||||
string(StatusNormal),
|
||||
string(StatusPending),
|
||||
string(StatusDisabled),
|
||||
string(StatusLocked),
|
||||
}
|
||||
|
||||
func (Status) Values() (kinds []string) {
|
||||
for _, s := range []Status{StatusNormal, StatusPending, StatusDisabled, StatusLocked} {
|
||||
kinds = append(kinds, string(s))
|
||||
}
|
||||
return
|
||||
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue