48 lines
1.0 KiB
Go
48 lines
1.0 KiB
Go
package stock
|
|
|
|
// ZoneStatus 库区状态枚举
|
|
type ZoneStatus string
|
|
|
|
const (
|
|
ZoneStatusEnabled ZoneStatus = "enable" // 启用
|
|
ZoneStatusDisabled ZoneStatus = "disable" // 停用
|
|
)
|
|
|
|
// GetAllZoneStatuses 获取所有库区状态
|
|
func GetAllZoneStatuses() []ZoneStatus {
|
|
return []ZoneStatus{
|
|
ZoneStatusEnabled,
|
|
ZoneStatusDisabled,
|
|
}
|
|
}
|
|
|
|
type ZoneStatusKeyValue struct {
|
|
Key ZoneStatus
|
|
Value string
|
|
}
|
|
|
|
var (
|
|
ZoneStatusEnabledKeyValue = ZoneStatusKeyValue{Key: ZoneStatusEnabled, Value: "启用"}
|
|
ZoneStatusDisabledKeyValue = ZoneStatusKeyValue{Key: ZoneStatusDisabled, Value: "停用"}
|
|
)
|
|
|
|
func GetAllZoneStatusKeyValue() []ZoneStatusKeyValue {
|
|
return []ZoneStatusKeyValue{
|
|
ZoneStatusEnabledKeyValue,
|
|
ZoneStatusDisabledKeyValue,
|
|
}
|
|
}
|
|
|
|
var zoneStatusValueMap = map[ZoneStatus]string{
|
|
ZoneStatusEnabled: ZoneStatusEnabledKeyValue.Value,
|
|
ZoneStatusDisabled: ZoneStatusDisabledKeyValue.Value,
|
|
}
|
|
|
|
func GetZoneStatusValueByKey(key ZoneStatus) (value string) {
|
|
value, exists := zoneStatusValueMap[key]
|
|
if !exists {
|
|
value = "未知状态"
|
|
}
|
|
return
|
|
}
|