mirror of
https://github.com/beego/bee.git
synced 2024-11-24 13:30:53 +00:00
move generateCode.Run() to g.go
This commit is contained in:
parent
6894c9bc55
commit
5a2394d76a
25
g_docs.go
25
g_docs.go
@ -103,7 +103,6 @@ var modelsList map[string]map[string]swagger.Model
|
|||||||
var rootapi swagger.ResourceListing
|
var rootapi swagger.ResourceListing
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cmdGenerate.Run = generateCode
|
|
||||||
pkgCache = make(map[string]bool)
|
pkgCache = make(map[string]bool)
|
||||||
controllerComments = make(map[string]string)
|
controllerComments = make(map[string]string)
|
||||||
importlist = make(map[string]string)
|
importlist = make(map[string]string)
|
||||||
@ -383,7 +382,7 @@ func parserComments(comments *ast.CommentGroup, funcName, controllerName, pkgpat
|
|||||||
if _, ok := modelsList[pkgpath+controllerName]; !ok {
|
if _, ok := modelsList[pkgpath+controllerName]; !ok {
|
||||||
modelsList[pkgpath+controllerName] = make(map[string]swagger.Model, 0)
|
modelsList[pkgpath+controllerName] = make(map[string]swagger.Model, 0)
|
||||||
}
|
}
|
||||||
modelsList[pkgpath+controllerName][st[2]] = mod
|
modelsList[pkgpath+controllerName][st[2]] = mod
|
||||||
appendModels(cmpath, pkgpath, controllerName, realTypes)
|
appendModels(cmpath, pkgpath, controllerName, realTypes)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -626,20 +625,20 @@ func grepJsonTag(tag string) string {
|
|||||||
|
|
||||||
// append models
|
// append models
|
||||||
func appendModels(cmpath, pkgpath, controllerName string, realTypes []string) {
|
func appendModels(cmpath, pkgpath, controllerName string, realTypes []string) {
|
||||||
var p string
|
var p string
|
||||||
if cmpath != "" {
|
if cmpath != "" {
|
||||||
p = strings.Join(strings.Split(cmpath, "/"), ".") + "."
|
p = strings.Join(strings.Split(cmpath, "/"), ".") + "."
|
||||||
} else {
|
} else {
|
||||||
p = ""
|
p = ""
|
||||||
}
|
}
|
||||||
for _, realType := range realTypes {
|
for _, realType := range realTypes {
|
||||||
if realType != "" && !isBasicType(strings.TrimLeft(realType, "[]")) &&
|
if realType != "" && !isBasicType(strings.TrimLeft(realType, "[]")) &&
|
||||||
!strings.HasPrefix(realType, "map") && !strings.HasPrefix(realType, "&") {
|
!strings.HasPrefix(realType, "map") && !strings.HasPrefix(realType, "&") {
|
||||||
if _, ok := modelsList[pkgpath+controllerName][p+realType]; ok {
|
if _, ok := modelsList[pkgpath+controllerName][p+realType]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fmt.Printf(pkgpath+":"+controllerName+":"+cmpath+":"+realType+"\n")
|
fmt.Printf(pkgpath + ":" + controllerName + ":" + cmpath + ":" + realType + "\n")
|
||||||
_, _, mod, newRealTypes := getModel(p+realType)
|
_, _, mod, newRealTypes := getModel(p + realType)
|
||||||
modelsList[pkgpath+controllerName][p+realType] = mod
|
modelsList[pkgpath+controllerName][p+realType] = mod
|
||||||
appendModels(cmpath, pkgpath, controllerName, newRealTypes)
|
appendModels(cmpath, pkgpath, controllerName, newRealTypes)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user