路由支持设置前缀
This commit is contained in:
parent
9ec9d2e807
commit
07f91dfdfc
@ -174,14 +174,14 @@ func (g *Generate) AddApi(baseCfg *define.UriBaseConfig, paramList []*define.Par
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 14:22 2025/2/9
|
||||
func (g *Generate) AddApiFromInAndOut(paramType reflect.Type, resultType reflect.Type) error {
|
||||
func (g *Generate) AddApiFromInAndOut(uriPrefix string, paramType reflect.Type, resultType reflect.Type) error {
|
||||
if paramType.Kind() == reflect.Ptr {
|
||||
paramType = paramType.Elem()
|
||||
}
|
||||
if resultType.Kind() == reflect.Ptr {
|
||||
resultType = resultType.Elem()
|
||||
}
|
||||
baseCfg, err := g.parseBaseUriConfig(paramType)
|
||||
baseCfg, err := g.parseBaseUriConfig(uriPrefix, paramType)
|
||||
if nil != err {
|
||||
return err
|
||||
}
|
||||
@ -616,7 +616,7 @@ func (g *Generate) setStructFieldProperty(schemaName string, structField reflect
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 15:13 2025/2/14
|
||||
func (g *Generate) parseBaseUriConfig(paramType reflect.Type) (*define.UriBaseConfig, error) {
|
||||
func (g *Generate) parseBaseUriConfig(uriPrefix string, paramType reflect.Type) (*define.UriBaseConfig, error) {
|
||||
// 解析meta信息
|
||||
metaField, metaFieldExist := paramType.FieldByName("Meta")
|
||||
if !metaFieldExist {
|
||||
@ -635,6 +635,9 @@ func (g *Generate) parseBaseUriConfig(paramType reflect.Type) (*define.UriBaseCo
|
||||
Deprecated: false,
|
||||
}
|
||||
res.Uri = metaField.Tag.Get(define.TagPath)
|
||||
if len(uriPrefix) > 0 {
|
||||
res.Uri = strings.TrimRight(uriPrefix, "/") + strings.TrimLeft(res.Uri, "/")
|
||||
}
|
||||
res.Method = strings.ToUpper(metaField.Tag.Get(define.TagMethod))
|
||||
res.Description = metaField.Tag.Get(define.TagDesc)
|
||||
res.TagList = strings.Split(metaField.Tag.Get(define.TagUriTag), ",")
|
||||
|
Loading…
x
Reference in New Issue
Block a user