2020-07-29 17:11:41 +08:00
|
|
|
package util
|
|
|
|
|
2020-09-01 11:46:10 +08:00
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
|
|
|
|
)
|
2020-07-29 17:11:41 +08:00
|
|
|
|
|
|
|
func GetAnnotationValue(annos []spec.Annotation, key, field string) (string, bool) {
|
|
|
|
for _, anno := range annos {
|
2020-10-16 19:35:18 +08:00
|
|
|
if anno.Name == field && len(anno.Value) > 0 {
|
|
|
|
return anno.Value, true
|
|
|
|
}
|
2020-07-29 17:11:41 +08:00
|
|
|
if anno.Name == key {
|
|
|
|
value, ok := anno.Properties[field]
|
2020-09-01 11:46:10 +08:00
|
|
|
return strings.TrimSpace(value), ok
|
2020-07-29 17:11:41 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return "", false
|
|
|
|
}
|