From 89fe63c915188fd356106a177ff8af1eee3995e1 Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Sat, 1 Aug 2020 12:56:19 +0800 Subject: [PATCH] gen : upgrade gen --- apis/tools/systables.go | 9 ++++++++- middleware/customerror.go | 2 +- template/vue.go.template | 26 ++++++++++++++++++++++---- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/apis/tools/systables.go b/apis/tools/systables.go index f28fe97..b2e57ce 100644 --- a/apis/tools/systables.go +++ b/apis/tools/systables.go @@ -168,8 +168,15 @@ func genTableInit(tablesList []string, i int, c *gin.Context) (tools.SysTables, } if strings.Contains(dbcolumn[i].ColumnType, "int") { - column.GoType = "int" + if strings.Contains(dbcolumn[i].ColumnKey, "PR") { + column.GoType = "int" + } else { + column.GoType = "string" + } column.HtmlType = "input" + } else if strings.Contains(dbcolumn[i].ColumnType, "timestamp") { + column.GoType = "time.Time" + column.HtmlType = "datetime" } else { column.GoType = "string" column.HtmlType = "input" diff --git a/middleware/customerror.go b/middleware/customerror.go index 5fbd99d..2dac7bc 100644 --- a/middleware/customerror.go +++ b/middleware/customerror.go @@ -26,7 +26,7 @@ func CustomError(c *gin.Context) { } c.Status(statusCode) fmt.Println( - time.Now().Format("\n 2006-01-02 15:04:05.9999"), + time.Now().Format("2006-01-02 15:04:05.9999"), "[ERROR]", c.Request.Method, c.Request.URL, diff --git a/template/vue.go.template b/template/vue.go.template index 305d1ad..aa179d4 100644 --- a/template/vue.go.template +++ b/template/vue.go.template @@ -132,10 +132,14 @@ {{- else if eq "select" .HtmlType -}} - - - + + {{- else if eq "radio" .HtmlType -}} @@ -145,6 +149,20 @@ :label="dict.dictValue" >{{"{{"}} dict.dictLabel {{"}}"}} + {{- else if eq "datetime" .HtmlType -}} + + + {{- else if eq "textarea" .HtmlType -}} + + {{- end }} {{- end }}