初始化项目
This commit is contained in:
52
digitalhuman/consts/age.go
Normal file
52
digitalhuman/consts/age.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package consts
|
||||
|
||||
// Age 年龄段类型
|
||||
type Age string
|
||||
|
||||
// 年龄段常量
|
||||
const (
|
||||
AgeChild Age = "child" // 儿童
|
||||
AgeTeenager Age = "teenager" // 青少年
|
||||
AgeYoung Age = "young" // 青年
|
||||
AgeMiddle Age = "middle" // 中年
|
||||
AgeSenior Age = "senior" // 老年
|
||||
AgeUnlimited Age = "unlimited" // 不限
|
||||
)
|
||||
|
||||
// GetAgeText 获取年龄段文本
|
||||
func GetAgeText(age string) string {
|
||||
switch age {
|
||||
case string(AgeChild):
|
||||
return "儿童"
|
||||
case string(AgeTeenager):
|
||||
return "青少年"
|
||||
case string(AgeYoung):
|
||||
return "青年"
|
||||
case string(AgeMiddle):
|
||||
return "中年"
|
||||
case string(AgeSenior):
|
||||
return "老年"
|
||||
case string(AgeUnlimited):
|
||||
return "不限"
|
||||
default:
|
||||
return "未知"
|
||||
}
|
||||
}
|
||||
|
||||
// GetAllAgeKeyValue 获取所有年龄段选项
|
||||
func GetAllAgeKeyValue() []AgeKeyValue {
|
||||
return []AgeKeyValue{
|
||||
{Value: string(AgeChild), Label: "儿童"},
|
||||
{Value: string(AgeTeenager), Label: "青少年"},
|
||||
{Value: string(AgeYoung), Label: "青年"},
|
||||
{Value: string(AgeMiddle), Label: "中年"},
|
||||
{Value: string(AgeSenior), Label: "老年"},
|
||||
{Value: string(AgeUnlimited), Label: "不限"},
|
||||
}
|
||||
}
|
||||
|
||||
// AgeKeyValue 年龄段键值对
|
||||
type AgeKeyValue struct {
|
||||
Value string `json:"value"`
|
||||
Label string `json:"label"`
|
||||
}
|
||||
Reference in New Issue
Block a user