update: set orm log
This commit is contained in:
1 parent
c210d2301c
commit
55496078f0
5 files changed
+18
-20
No files matched your search
+2
-2
@@ -289,7 +289,7 @@ func GenMenuAndApi(c *gin.Context) {
|
|||||||
AList.MenuName = ""
|
AList.MenuName = ""
|
||||||
AList.Title = "分页获取" + tab.TableComment
|
AList.Title = "分页获取" + tab.TableComment
|
||||||
AList.Icon = "bug"
|
AList.Icon = "bug"
|
||||||
AList.Path = "/api/v1/" + tab.ModuleName + "List"
|
AList.Path = "/api/v1/" + tab.ModuleName
|
||||||
AList.MenuType = "A"
|
AList.MenuType = "A"
|
||||||
AList.Action = "GET"
|
AList.Action = "GET"
|
||||||
AList.ParentId = Amenu.MenuId
|
AList.ParentId = Amenu.MenuId
|
||||||
@@ -343,7 +343,7 @@ func GenMenuAndApi(c *gin.Context) {
|
|||||||
AUpdate.MenuName = ""
|
AUpdate.MenuName = ""
|
||||||
AUpdate.Title = "修改" + tab.TableComment
|
AUpdate.Title = "修改" + tab.TableComment
|
||||||
AUpdate.Icon = "bug"
|
AUpdate.Icon = "bug"
|
||||||
AUpdate.Path = "/api/v1/" + tab.ModuleName
|
AUpdate.Path = "/api/v1/" + tab.ModuleName + "/:id"
|
||||||
AUpdate.MenuType = "A"
|
AUpdate.MenuType = "A"
|
||||||
AUpdate.Action = "PUT"
|
AUpdate.Action = "PUT"
|
||||||
AUpdate.ParentId = Amenu.MenuId
|
AUpdate.ParentId = Amenu.MenuId
|
||||||
|
|||||||
@@ -3,7 +3,11 @@ package database
|
|||||||
import (
|
import (
|
||||||
"gorm.io/driver/mysql"
|
"gorm.io/driver/mysql"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
"gorm.io/gorm/logger"
|
||||||
"gorm.io/gorm/schema"
|
"gorm.io/gorm/schema"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"go-admin/global"
|
"go-admin/global"
|
||||||
"go-admin/tools"
|
"go-admin/tools"
|
||||||
@@ -34,11 +38,11 @@ func (e *Mysql) Setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if config.LoggerConfig.EnabledDB {
|
if config.LoggerConfig.EnabledDB {
|
||||||
//global.Eloquent.Logger = logger.New(log.New(os.Stdout, "\r\n", log.LstdFlags), logger.Config{
|
global.Eloquent.Logger = logger.New(log.New(os.Stdout, "\r\n", log.LstdFlags), logger.Config{
|
||||||
// SlowThreshold: time.Second,
|
SlowThreshold: time.Second,
|
||||||
// Colorful: true,
|
Colorful: true,
|
||||||
// LogLevel: logger.Info,
|
LogLevel: logger.Info,
|
||||||
//})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ type {{.ClassName}}Search struct {
|
|||||||
{{ range .Columns -}}
|
{{ range .Columns -}}
|
||||||
{{$z := .IsQuery}}
|
{{$z := .IsQuery}}
|
||||||
{{- if ($z) -}}
|
{{- if ($z) -}}
|
||||||
{{.GoField}} {{.GoType}} `form:"{{.JsonField}}" gorm:"type:{{if eq .QueryType "EQ"}}exact{{ else if eq .QueryType "NE"}}iexact{{ else if eq .QueryType "LIKE"}}contains{{ else if eq .QueryType "GT"}}gt{{ else if eq .QueryType "GTE"}}gte{{ else if eq .QueryType "LT"}}lt{{ else if eq .QueryType "LTE"}}lte{{- end }};column:{{.ColumnName}};table:{{$tablename}}"` // {{.ColumnComment}}
|
{{.GoField}} {{.GoType}} `form:"{{.JsonField}}" search:"type:{{if eq .QueryType "EQ"}}exact{{ else if eq .QueryType "NE"}}iexact{{ else if eq .QueryType "LIKE"}}contains{{ else if eq .QueryType "GT"}}gt{{ else if eq .QueryType "GTE"}}gte{{ else if eq .QueryType "LT"}}lt{{ else if eq .QueryType "LTE"}}lte{{- end }};column:{{.ColumnName}};table:{{$tablename}}"` // {{.ColumnComment}}
|
||||||
|
|
||||||
{{end -}}
|
{{end -}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package router
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
"go-admin/middleware"
|
"go-admin/middleware"
|
||||||
"go-admin/apis/{{.ModuleName}}"
|
"go-admin/apis/{{.ModuleName}}"
|
||||||
jwt "go-admin/pkg/jwtauth"
|
jwt "go-admin/pkg/jwtauth"
|
||||||
@@ -9,18 +10,12 @@ jwt "go-admin/pkg/jwtauth"
|
|||||||
|
|
||||||
// 需认证的路由代码
|
// 需认证的路由代码
|
||||||
func register{{.ClassName}}Router(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
func register{{.ClassName}}Router(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||||
|
|
||||||
r := v1.Group("/{{.ModuleName}}").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
|
r := v1.Group("/{{.ModuleName}}").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
|
||||||
{
|
{
|
||||||
r.GET("/:{{.PkJsonField}}", {{.ModuleName}}.Get{{.ClassName}})
|
r.GET("/:{{.PkJsonField}}", {{.ModuleName}}.Get{{.ClassName}})
|
||||||
r.POST("", {{.ModuleName}}.Insert{{.ClassName}})
|
r.POST("", {{.ModuleName}}.Insert{{.ClassName}})
|
||||||
r.PUT("", {{.ModuleName}}.Update{{.ClassName}})
|
r.PUT("/:{{.PkJsonField}}", {{.ModuleName}}.Update{{.ClassName}})
|
||||||
r.DELETE("/:{{.PkJsonField}}", {{.ModuleName}}.Delete{{.ClassName}})
|
r.DELETE("/:{{.PkJsonField}}", {{.ModuleName}}.Delete{{.ClassName}})
|
||||||
|
l.GET("",{{.ModuleName}}.Get{{.ClassName}}List)
|
||||||
}
|
}
|
||||||
|
|
||||||
l := v1.Group("").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
|
|
||||||
{
|
|
||||||
l.GET("/{{.ModuleName}}List",{{.ModuleName}}.Get{{.ClassName}}List)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,19 +2,18 @@ package router
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
"go-admin/apis/{{.ModuleName}}"
|
"go-admin/apis/{{.ModuleName}}"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 无需认证的路由代码
|
// 无需认证的路由代码
|
||||||
func register{{.ClassName}}Router(v1 *gin.RouterGroup) {
|
func register{{.ClassName}}Router(v1 *gin.RouterGroup) {
|
||||||
|
|
||||||
v1.GET("/{{.ModuleName}}List",{{.ModuleName}}.Get{{.ClassName}}List)
|
|
||||||
|
|
||||||
r := v1.Group("/{{.ModuleName}}")
|
r := v1.Group("/{{.ModuleName}}")
|
||||||
{
|
{
|
||||||
r.GET("/:{{.PkJsonField}}", {{.ModuleName}}.Get{{.ClassName}})
|
r.GET("/:{{.PkJsonField}}", {{.ModuleName}}.Get{{.ClassName}})
|
||||||
r.POST("", {{.ModuleName}}.Insert{{.ClassName}})
|
r.POST("", {{.ModuleName}}.Insert{{.ClassName}})
|
||||||
r.PUT("", {{.ModuleName}}.Update{{.ClassName}})
|
r.PUT("/:{{.PkJsonField}}", {{.ModuleName}}.Update{{.ClassName}})
|
||||||
r.DELETE("/:{{.PkJsonField}}", {{.ModuleName}}.Delete{{.ClassName}})
|
r.DELETE("/:{{.PkJsonField}}", {{.ModuleName}}.Delete{{.ClassName}})
|
||||||
|
r.GET("",{{.ModuleName}}.Get{{.ClassName}}List)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user