feat✨ 统一api生成路径

This commit is contained in:
wenjianzhang committed 2021-05-11 08:37:27 +08:00
1 parent e091603bc8
commit 03eaad5b8b
3 files changed
+5 -5

No files matched your search

+2 -2
View File
@@ -218,7 +218,7 @@ func (e Gen) NOActionsGen(c *gin.Context, tab tools.SysTables) {
return return
} }
_ = pkg.PathCreate("./app/" + tab.PackageName + "/apis/" + tab.ModuleName) _ = pkg.PathCreate("./app/" + tab.PackageName + "/apis/")
_ = pkg.PathCreate("./app/" + tab.PackageName + "/models/") _ = pkg.PathCreate("./app/" + tab.PackageName + "/models/")
_ = pkg.PathCreate("./app/" + tab.PackageName + "/router/") _ = pkg.PathCreate("./app/" + tab.PackageName + "/router/")
_ = pkg.PathCreate("./app/" + tab.PackageName + "/service/dto/") _ = pkg.PathCreate("./app/" + tab.PackageName + "/service/dto/")
@@ -240,7 +240,7 @@ func (e Gen) NOActionsGen(c *gin.Context, tab tools.SysTables) {
var b7 bytes.Buffer var b7 bytes.Buffer
err = t7.Execute(&b7, tab) err = t7.Execute(&b7, tab)
pkg.FileCreate(b1, "./app/"+tab.PackageName+"/models/"+tab.BusinessName+".go") pkg.FileCreate(b1, "./app/"+tab.PackageName+"/models/"+tab.BusinessName+".go")
pkg.FileCreate(b2, "./app/"+tab.PackageName+"/apis/"+tab.ModuleName+"/"+tab.BusinessName+".go") pkg.FileCreate(b2, "./app/"+tab.PackageName+"/apis/"+tab.BusinessName+".go")
pkg.FileCreate(b3, "./app/"+tab.PackageName+"/router/"+tab.BusinessName+".go") pkg.FileCreate(b3, "./app/"+tab.PackageName+"/router/"+tab.BusinessName+".go")
pkg.FileCreate(b4, config.GenConfig.FrontPath+"/api/"+tab.BusinessName+".js") pkg.FileCreate(b4, config.GenConfig.FrontPath+"/api/"+tab.BusinessName+".js")
pkg.FileCreate(b5, config.GenConfig.FrontPath+"/views/"+tab.BusinessName+"/index.vue") pkg.FileCreate(b5, config.GenConfig.FrontPath+"/views/"+tab.BusinessName+"/index.vue")
+1 -1
View File
@@ -1,4 +1,4 @@
package {{.ModuleName}} package apis
import ( import (
"net/http" "net/http"
@@ -4,7 +4,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth" jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"
"go-admin/app/{{.PackageName}}/apis/{{.ModuleName}}" "go-admin/app/{{.PackageName}}/apis"
) )
func init() { func init() {
@@ -13,7 +13,7 @@ func init() {
// register{{.ClassName}}Router // register{{.ClassName}}Router
func register{{.ClassName}}Router(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) { func register{{.ClassName}}Router(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
api := &{{.ModuleName}}.{{.ClassName}}{} api := apis.{{.ClassName}}{}
r := v1.Group("/{{.ModuleName}}").Use(authMiddleware.MiddlewareFunc()) r := v1.Group("/{{.ModuleName}}").Use(authMiddleware.MiddlewareFunc())
{ {
r.GET("", api.Get{{.ClassName}}) r.GET("", api.Get{{.ClassName}})