73 lines
2.6 KiB
Go
73 lines
2.6 KiB
Go
package stock
|
|
|
|
// CapacityUnitLength 长度单位枚举
|
|
type CapacityUnitLength string
|
|
|
|
const (
|
|
CapacityUnitLengthM CapacityUnitLength = "M" // 米
|
|
CapacityUnitLengthCM CapacityUnitLength = "CM" // 厘米
|
|
CapacityUnitLengthMM CapacityUnitLength = "MM" // 毫米
|
|
CapacityUnitLengthKM CapacityUnitLength = "KM" // 千米
|
|
CapacityUnitLengthFT CapacityUnitLength = "FT" // 英尺
|
|
CapacityUnitLengthIN CapacityUnitLength = "IN" // 英寸
|
|
CapacityUnitLengthYD CapacityUnitLength = "YD" // 码
|
|
)
|
|
|
|
// GetAllCapacityUnitLengths 获取所有长度单位
|
|
func GetAllCapacityUnitLengths() []CapacityUnitLength {
|
|
return []CapacityUnitLength{
|
|
CapacityUnitLengthM,
|
|
CapacityUnitLengthCM,
|
|
CapacityUnitLengthMM,
|
|
CapacityUnitLengthKM,
|
|
CapacityUnitLengthFT,
|
|
CapacityUnitLengthIN,
|
|
CapacityUnitLengthYD,
|
|
}
|
|
}
|
|
|
|
type CapacityUnitLengthKeyValue struct {
|
|
Key CapacityUnitLength
|
|
Value string
|
|
}
|
|
|
|
var (
|
|
CapacityUnitLengthMKeyValue = CapacityUnitLengthKeyValue{Key: CapacityUnitLengthM, Value: "米"}
|
|
CapacityUnitLengthCMKeyValue = CapacityUnitLengthKeyValue{Key: CapacityUnitLengthCM, Value: "厘米"}
|
|
CapacityUnitLengthMMKeyValue = CapacityUnitLengthKeyValue{Key: CapacityUnitLengthMM, Value: "毫米"}
|
|
CapacityUnitLengthKMKeyValue = CapacityUnitLengthKeyValue{Key: CapacityUnitLengthKM, Value: "千米"}
|
|
CapacityUnitLengthFTKeyValue = CapacityUnitLengthKeyValue{Key: CapacityUnitLengthFT, Value: "英尺"}
|
|
CapacityUnitLengthINKeyValue = CapacityUnitLengthKeyValue{Key: CapacityUnitLengthIN, Value: "英寸"}
|
|
CapacityUnitLengthYDKeyValue = CapacityUnitLengthKeyValue{Key: CapacityUnitLengthYD, Value: "码"}
|
|
)
|
|
|
|
func GetAllCapacityUnitLengthKeyValue() []CapacityUnitLengthKeyValue {
|
|
return []CapacityUnitLengthKeyValue{
|
|
CapacityUnitLengthMKeyValue,
|
|
CapacityUnitLengthCMKeyValue,
|
|
CapacityUnitLengthMMKeyValue,
|
|
CapacityUnitLengthKMKeyValue,
|
|
CapacityUnitLengthFTKeyValue,
|
|
CapacityUnitLengthINKeyValue,
|
|
CapacityUnitLengthYDKeyValue,
|
|
}
|
|
}
|
|
|
|
var capacityUnitLengthValueMap = map[CapacityUnitLength]string{
|
|
CapacityUnitLengthM: CapacityUnitLengthMKeyValue.Value,
|
|
CapacityUnitLengthCM: CapacityUnitLengthCMKeyValue.Value,
|
|
CapacityUnitLengthMM: CapacityUnitLengthMMKeyValue.Value,
|
|
CapacityUnitLengthKM: CapacityUnitLengthKMKeyValue.Value,
|
|
CapacityUnitLengthFT: CapacityUnitLengthFTKeyValue.Value,
|
|
CapacityUnitLengthIN: CapacityUnitLengthINKeyValue.Value,
|
|
CapacityUnitLengthYD: CapacityUnitLengthYDKeyValue.Value,
|
|
}
|
|
|
|
func GetCapacityUnitLengthValueByKey(key CapacityUnitLength) (value string) {
|
|
value, exists := capacityUnitLengthValueMap[key]
|
|
if !exists {
|
|
value = "未知单位"
|
|
}
|
|
return
|
|
}
|