From c6ccd844f52835bfae81b9679c47ebaa6ca81b25 Mon Sep 17 00:00:00 2001 From: wenjianzhang Date: Fri, 7 May 2021 18:54:11 +0800 Subject: [PATCH] =?UTF-8?q?feat=E2=9C=A8=20=E5=8E=BB=E9=99=A4=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=96=B9=E6=B3=95=E7=89=88=E6=9C=AC=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/apis/tools/gen.go | 10 +++++----- app/admin/router/sys_router.go | 7 +++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/admin/apis/tools/gen.go b/app/admin/apis/tools/gen.go index 44c58bc6..de448333 100644 --- a/app/admin/apis/tools/gen.go +++ b/app/admin/apis/tools/gen.go @@ -109,7 +109,7 @@ func (e *Gen) Preview(c *gin.Context) { e.OK(mp, "") } -func (e *Gen) GenCodeV3(c *gin.Context) { +func (e *Gen) GenCode(c *gin.Context) { e.Context = c log := e.GetLogger() table := tools.SysTables{} @@ -131,9 +131,9 @@ func (e *Gen) GenCodeV3(c *gin.Context) { tab, _ := table.Get(db) if tab.IsActions == 1 { - e.ActionsGenV3(c, tab) + e.ActionsGen(c, tab) } else { - e.NOActionsGenV3(c, tab) + e.NOActionsGen(c, tab) } e.OK("", "Code generated successfully!") @@ -164,7 +164,7 @@ func (e *Gen) GenApiToFile(c *gin.Context) { e.OK("", "Code generated successfully!") } -func (e *Gen) NOActionsGenV3(c *gin.Context, tab tools.SysTables) { +func (e *Gen) NOActionsGen(c *gin.Context, tab tools.SysTables) { e.Context = c log := e.GetLogger() @@ -272,7 +272,7 @@ func (e *Gen) genApiToFile(c *gin.Context, tab tools.SysTables) { } -func (e *Gen) ActionsGenV3(c *gin.Context, tab tools.SysTables) { +func (e *Gen) ActionsGen(c *gin.Context, tab tools.SysTables) { log := api.GetRequestLogger(c) basePath := "template/v4/" routerFile := basePath + "actions/router_check_role.go.template" diff --git a/app/admin/router/sys_router.go b/app/admin/router/sys_router.go index b059f7f0..ee4addff 100644 --- a/app/admin/router/sys_router.go +++ b/app/admin/router/sys_router.go @@ -46,7 +46,10 @@ func sysBaseRouter(r *gin.RouterGroup) { } func sysStaticFileRouter(r *gin.RouterGroup) { - mime.AddExtensionType(".js", "application/javascript") + err := mime.AddExtensionType(".js", "application/javascript") + if err != nil { + return + } r.Static("/static", "./static") r.Static("/form-generator", "./static/form-generator") } @@ -64,7 +67,7 @@ func sysNoCheckRoleRouter(r *gin.RouterGroup) { v1.GET("/getCaptcha", sys.GenerateCaptchaHandler) gen := tools.Gen{} v1.GET("/gen/preview/:tableId", gen.Preview) - v1.GET("/gen/toproject/:tableId", gen.GenCodeV3) + v1.GET("/gen/toproject/:tableId", gen.GenCode) v1.GET("/gen/apitofile/:tableId", gen.GenApiToFile) v1.GET("/gen/todb/:tableId", gen.GenMenuAndApi)