增加枚举值描述解析
This commit is contained in:
@ -150,3 +150,31 @@ func (psf parseStructFieldTag) Summary(structField reflect.StructField) string {
|
||||
}
|
||||
return paramName
|
||||
}
|
||||
|
||||
// EnumDescription .枚举值详细描述
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 22:40 2025/2/18
|
||||
func (psf parseStructFieldTag) EnumDescription(structField reflect.StructField) map[string]string {
|
||||
defaultTagList := []string{define.TagNameEnumDescription}
|
||||
res := map[string]string{}
|
||||
for _, tag := range defaultTagList {
|
||||
if tagVal, exist := structField.Tag.Lookup(tag); exist && len(tagVal) > 0 {
|
||||
tagVal = strings.ReplaceAll(tagVal, "###", "`")
|
||||
enumList := strings.Split(tagVal, "||")
|
||||
for _, enum := range enumList {
|
||||
enumArr := strings.Split(enum, ":")
|
||||
if len(enumArr) < 2 {
|
||||
continue
|
||||
}
|
||||
res[enumArr[0]] = strings.Join(enumArr[1:], ":")
|
||||
}
|
||||
return res
|
||||
}
|
||||
}
|
||||
if len(res) == 0 {
|
||||
return nil
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
Reference in New Issue
Block a user