代码生成进一步完善

This commit is contained in:
yxh
2020-08-13 17:24:29 +08:00
parent 7c85e49905
commit 854fc00099
13 changed files with 445 additions and 39 deletions
+25 -6
View File
@@ -8,6 +8,8 @@ import (
"github.com/gogf/gf/encoding/gjson" "github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g" "github.com/gogf/gf/frame/g"
"github.com/gogf/gf/net/ghttp" "github.com/gogf/gf/net/ghttp"
"github.com/gogf/gf/os/gview"
"github.com/gogf/gf/text/gregex"
"github.com/gogf/gf/text/gstr" "github.com/gogf/gf/text/gstr"
"github.com/gogf/gf/util/gconv" "github.com/gogf/gf/util/gconv"
"github.com/gogf/gf/util/gvalid" "github.com/gogf/gf/util/gvalid"
@@ -200,25 +202,42 @@ func (c *Gen) Preview(r *ghttp.Request) {
vueKey := "vm/html/" + entity.BusinessName + "_vue.js.vm" vueKey := "vm/html/" + entity.BusinessName + "_vue.js.vm"
vueValue := "" vueValue := ""
g.View().BindFuncMap(g.Map{ view := gview.New()
view.BindFuncMap(g.Map{
"UcFirst": func(str string) string { "UcFirst": func(str string) string {
return gstr.UcFirst(str) return gstr.UcFirst(str)
}, },
}) })
if tmpController, err := r.Response.ParseTpl("vm/go/controller.template", g.Map{"table": entity}); err == nil { view.SetConfigWithMap(g.Map{
"Paths": []string{"template"},
"Delimiters": []string{"{{", "}}"},
})
//树形菜单选项
var options g.Map
if entity.TplCategory == "tree" {
options = gjson.New(entity.Options).ToMap()
}
g.Log().Debug(options)
if tmpController, err := view.Parse("vm/go/"+entity.TplCategory+"/controller.template", g.Map{"table": entity}); err == nil {
controllerValue = tmpController controllerValue = tmpController
} }
if tmpService, err := r.Response.ParseTpl("vm/go/service.template", g.Map{"table": entity}); err == nil { if tmpService, err := view.Parse("vm/go/"+entity.TplCategory+"/service.template", g.Map{"table": entity, "options": options}); err == nil {
serviceValue = tmpService serviceValue = tmpService
} }
if tmpExtend, err := r.Response.ParseTpl("vm/go/extend.template", g.Map{"table": entity}); err == nil { if tmpExtend, err := view.Parse("vm/go/"+entity.TplCategory+"/extend.template", g.Map{"table": entity}); err == nil {
extendValue = tmpExtend extendValue = tmpExtend
if extendByte, err := gregex.Replace("(([\\s\t]*)\r?\n){2,}", []byte("$2\n"), []byte(extendValue)); err == nil {
extendValue = gconv.String(extendByte)
}
} }
if tmpExtend, err := r.Response.ParseTpl("vm/html/js.template", g.Map{"table": entity}); err == nil { if tmpExtend, err := view.Parse("vm/html/js.template", g.Map{"table": entity}); err == nil {
apiJsValue = tmpExtend apiJsValue = tmpExtend
} }
if tmpExtend, err := r.Response.ParseTpl("vm/html/vue.template", g.Map{"table": entity}); err == nil { if tmpExtend, err := view.Parse("vm/html/vue.template", g.Map{"table": entity}); err == nil {
vueValue = tmpExtend vueValue = tmpExtend
if vueByte, err := gregex.Replace("(([\\s\t]*)\r?\n){2,}", []byte("$2\n"), []byte(vueValue)); err == nil {
vueValue = gconv.String(vueByte)
}
} }
response.SusJson(true, r, "ok", g.Map{ response.SusJson(true, r, "ok", g.Map{
+3
View File
@@ -145,6 +145,8 @@ func InitColumnField(column *gen_table_column.Entity, table *gen_table.Entity) {
columnName := column.ColumnName columnName := column.ColumnName
column.TableId = table.TableId column.TableId = table.TableId
column.CreateBy = table.CreateBy column.CreateBy = table.CreateBy
column.CreateTime = gtime.Now()
column.UpdateTime = column.CreateTime
//设置字段名 //设置字段名
column.GoField = ConvertToCamelCase(columnName) column.GoField = ConvertToCamelCase(columnName)
column.HtmlField = ConvertToCamelCase1(columnName) column.HtmlField = ConvertToCamelCase1(columnName)
@@ -316,6 +318,7 @@ func InitTable(table *gen_table.Entity, operName string) {
table.CreateBy = operName table.CreateBy = operName
table.TplCategory = "crud" table.TplCategory = "crud"
table.CreateTime = gtime.Now() table.CreateTime = gtime.Now()
table.UpdateTime = table.CreateTime
} }
//表名转换成类名 //表名转换成类名
+8 -1
View File
@@ -5,13 +5,20 @@ require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/casbin/casbin/v2 v2.1.2 github.com/casbin/casbin/v2 v2.1.2
github.com/go-ole/go-ole v1.2.4 // indirect github.com/go-ole/go-ole v1.2.4 // indirect
github.com/go-openapi/spec v0.19.8 // indirect
github.com/go-openapi/swag v0.19.9 // indirect
github.com/goflyfox/gtoken v1.3.17 github.com/goflyfox/gtoken v1.3.17
github.com/gogf/gf v1.13.1 github.com/gogf/gf v1.13.3
github.com/mailru/easyjson v0.7.1 // indirect
github.com/mojocn/base64Captcha v1.3.1 github.com/mojocn/base64Captcha v1.3.1
github.com/mssola/user_agent v0.5.1 github.com/mssola/user_agent v0.5.1
github.com/shirou/gopsutil v2.20.2+incompatible github.com/shirou/gopsutil v2.20.2+incompatible
github.com/stretchr/testify v1.5.1 // indirect github.com/stretchr/testify v1.5.1 // indirect
github.com/swaggo/swag v1.6.7 github.com/swaggo/swag v1.6.7
golang.org/x/net v0.0.0-20200707034311-ab3426394381 // indirect
golang.org/x/text v0.3.3 // indirect
golang.org/x/tools v0.0.0-20200716225003-58eba7e7502e // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
) )
go 1.14 go 1.14
+43 -4
View File
@@ -17,6 +17,8 @@ github.com/casbin/casbin/v2 v2.1.2 h1:bTwon/ECRx9dwBy2ewRVr5OiqjeXSGiTUY74sDPQi/
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I= github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I=
github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng= github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng=
github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28 h1:LdXxtjzvZYhhUaonAaAKArG3pyC67kGL3YY+6hGG8G4=
github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -49,23 +51,28 @@ github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL9
github.com/go-openapi/spec v0.19.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= github.com/go-openapi/spec v0.19.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI=
github.com/go-openapi/spec v0.19.4 h1:ixzUSnHTd6hCemgtAJgluaTSGYpLNpJY4mA2DIkdOAo= github.com/go-openapi/spec v0.19.4 h1:ixzUSnHTd6hCemgtAJgluaTSGYpLNpJY4mA2DIkdOAo=
github.com/go-openapi/spec v0.19.4/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= github.com/go-openapi/spec v0.19.4/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo=
github.com/go-openapi/spec v0.19.8 h1:qAdZLh1r6QF/hI/gTq+TJTvsQUodZsM7KLqkAJdiJNg=
github.com/go-openapi/spec v0.19.8/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk=
github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg=
github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY= github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY=
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
github.com/go-openapi/swag v0.19.9 h1:1IxuqvBUU3S2Bi4YC7tlP9SJF1gVpCvqN0T2Qof4azE=
github.com/go-openapi/swag v0.19.9/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/goflyfox/gtoken v1.3.17 h1:/HgPG7iArkJMn8SVXcDya5+6xXvWJEpR0bxnjigq2u8= github.com/goflyfox/gtoken v1.3.17 h1:/HgPG7iArkJMn8SVXcDya5+6xXvWJEpR0bxnjigq2u8=
github.com/goflyfox/gtoken v1.3.17/go.mod h1:a9Q08qaHzoS+ko/AFrCBnq4KCesnRFZ/3eLIiERRhtU= github.com/goflyfox/gtoken v1.3.17/go.mod h1:a9Q08qaHzoS+ko/AFrCBnq4KCesnRFZ/3eLIiERRhtU=
github.com/gogf/gf v1.12.1/go.mod h1:5ItmC5B/St8P4hp0/waKmnvHwAfAJ1uspMvR2wUD4UA= github.com/gogf/gf v1.12.1/go.mod h1:5ItmC5B/St8P4hp0/waKmnvHwAfAJ1uspMvR2wUD4UA=
github.com/gogf/gf v1.13.1 h1:jwIUJ3rqhHkOBfdS9FfZzcW/cqlokSyTT/6u3E/x8TU= github.com/gogf/gf v1.13.3 h1:wdyNAzOSztDkabTEqRmPeJJT93p2qBK/jPK5x+8CRSE=
github.com/gogf/gf v1.13.1/go.mod h1:Ho7d+9F8dHe5LpEnIH+bky0aCtjwc8Gm82rUiCYnk/k= github.com/gogf/gf v1.13.3/go.mod h1:dGX0/BElXDBYbdJGascqfrWScj8IMeOietDjVD6/5Fc=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0= github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0=
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
@@ -76,6 +83,8 @@ github.com/grokify/html-strip-tags-go v0.0.0-20190921062105-daaa06bf1aaf h1:wIOA
github.com/grokify/html-strip-tags-go v0.0.0-20190921062105-daaa06bf1aaf/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78= github.com/grokify/html-strip-tags-go v0.0.0-20190921062105-daaa06bf1aaf/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78=
github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@@ -86,6 +95,8 @@ github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e h1:hB2xlXdHp/pmPZq0y3QnmWAArdw9PqbmotexnWx/FU8= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e h1:hB2xlXdHp/pmPZq0y3QnmWAArdw9PqbmotexnWx/FU8=
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.7.1 h1:mdxE1MF9o53iCb2Ghj1VfWvh7ZOwHpnVG/xwXrV90U8=
github.com/mailru/easyjson v0.7.1/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
@@ -93,7 +104,11 @@ github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+tw
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/mojocn/base64Captcha v1.3.1 h1:2Wbkt8Oc8qjmNJ5GyOfSo4tgVQPsbKMftqASnq8GlT0= github.com/mojocn/base64Captcha v1.3.1 h1:2Wbkt8Oc8qjmNJ5GyOfSo4tgVQPsbKMftqASnq8GlT0=
github.com/mojocn/base64Captcha v1.3.1/go.mod h1:wAQCKEc5bDujxKRmbT6/vTnTt5CjStQ8bRfPWUuz/iY= github.com/mojocn/base64Captcha v1.3.1/go.mod h1:wAQCKEc5bDujxKRmbT6/vTnTt5CjStQ8bRfPWUuz/iY=
@@ -127,10 +142,15 @@ github.com/ugorji/go/codec v0.0.0-20181022190402-e5e69e061d4f/go.mod h1:VFNgLljT
github.com/ugorji/go/codec v1.1.5-pre/go.mod h1:tULtS6Gy1AE1yCENaw4Vb//HLH5njI2tfCQDUqRd8fI= github.com/ugorji/go/codec v1.1.5-pre/go.mod h1:tULtS6Gy1AE1yCENaw4Vb//HLH5njI2tfCQDUqRd8fI=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/image v0.0.0-20190501045829-6d32002ffd75 h1:TbGuee8sSq15Iguxu4deQ7+Bqq/d2rsQejGcEtADAMQ= golang.org/x/image v0.0.0-20190501045829-6d32002ffd75 h1:TbGuee8sSq15Iguxu4deQ7+Bqq/d2rsQejGcEtADAMQ=
golang.org/x/image v0.0.0-20190501045829-6d32002ffd75/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190501045829-6d32002ffd75/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -138,10 +158,16 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190611141213-3f473d35a33a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190611141213-3f473d35a33a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM=
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU=
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -150,16 +176,26 @@ golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e h1:9vRrk9YW2BTzLP0VCB9ZDjU4cPqkg+IDWL7XgxA1yxQ= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e h1:9vRrk9YW2BTzLP0VCB9ZDjU4cPqkg+IDWL7XgxA1yxQ=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9 h1:YTzHMGlqJu67/uEo1lBv0n3wBXhXNeUbB1XfN2vmTm0= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59 h1:QjA/9ArTfVTLfEhClDCG7SGrZkZixxWpwNCDiwJfh88= golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59 h1:QjA/9ArTfVTLfEhClDCG7SGrZkZixxWpwNCDiwJfh88=
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200716225003-58eba7e7502e h1:WaR4d3kbnTlsdn8Ms1b6r8HwNloW6f8WKxiDu+C5J48=
golang.org/x/tools v0.0.0-20200716225003-58eba7e7502e/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
@@ -169,5 +205,8 @@ gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/R
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+3 -8
View File
@@ -41,7 +41,7 @@ func GetVerifyImgString() (idKeyC string, base64stringC string) {
NoiseCount: 50, NoiseCount: 50,
ShowLineOptions: 20, ShowLineOptions: 20,
Length: 4, Length: 4,
Source: "abcdefghijklmnopqrstuvwxyz0123456789", Source: "abcdefghjkmnpqrstuvwxyz23456789",
Fonts: []string{"chromohv.ttf"}, Fonts: []string{"chromohv.ttf"},
} }
driver = driver.ConvertFonts() driver = driver.ConvertFonts()
@@ -63,12 +63,7 @@ func VerifyString(id, answer string) bool {
return c.Verify(id, answer, true) return c.Verify(id, answer, true)
} }
func FrontLogin(r *ghttp.Request) (string, interface{}) { // 登录返回方法
g.Log().Println("front login test...")
return "test", nil
}
// 后台登录返回方法
func LoginAfter(r *ghttp.Request, respData gtoken.Resp) { func LoginAfter(r *ghttp.Request, respData gtoken.Resp) {
if !respData.Success() { if !respData.Success() {
r.Response.WriteJson(respData) r.Response.WriteJson(respData)
@@ -153,7 +148,7 @@ func signIn(username, password string, r *ghttp.Request) (error, *user.User) {
} }
//登录日志记录 //登录日志记录
func loginLog(status int, username, ip, userAgent, msg string, module string) { func loginLog(status int, username, ip, userAgent, msg, module string) {
var log sys_login_log.Entity var log sys_login_log.Entity
log.LoginName = username log.LoginName = username
log.Ipaddr = ip log.Ipaddr = ip
@@ -2,13 +2,13 @@
// 生成日期:{{.table.CreateTime}} // 生成日期:{{.table.CreateTime}}
// 生成人:{{.table.FunctionAuthor}} // 生成人:{{.table.FunctionAuthor}}
// ========================================================================== // ==========================================================================
package {{.table.BusinessName}} package {{.table.ModuleName}}
import ( import (
"github.com/gogf/gf/frame/g" "github.com/gogf/gf/frame/g"
"github.com/gogf/gf/net/ghttp" "github.com/gogf/gf/net/ghttp"
{{.table.BusinessName}}Model "{{.table.PackageName}}/app/model/{{.table.ModuleName}}/{{.table.BusinessName}}" {{.table.BusinessName}}Model "{{.table.PackageName}}/app/model/{{.table.ModuleName}}/{{.table.BusinessName}}"
{{.table.BusinessName}}Service "{{.table.PackageName}}/app/service/{{.table.ModuleName}}/{{.table.BusinessName}}" {{.table.BusinessName}}Service "{{.table.PackageName}}/app/service/{{.table.ModuleName}}/{{.table.BusinessName}}_service"
"{{.table.PackageName}}/library/response" "{{.table.PackageName}}/library/response"
) )
@@ -52,6 +52,7 @@ func (c *{{.table.BusinessName|UcFirst}}) Add(r *ghttp.Request) {
if err != nil { if err != nil {
response.FailJson(true, r, err.Error()) response.FailJson(true, r, err.Error())
} }
response.SusJson(true, r, "添加成功")
} }
} }
@@ -2,7 +2,7 @@
// 生成日期:{{.table.CreateTime}} // 生成日期:{{.table.CreateTime}}
// 生成人:{{.table.FunctionAuthor}} // 生成人:{{.table.FunctionAuthor}}
// ========================================================================== // ==========================================================================
package {{.table.BusinessName}} package {{.table.BusinessName}}_service
import ( import (
{{.table.BusinessName}}Model "{{.table.PackageName}}/app/model/{{.table.ModuleName}}/{{.table.BusinessName}}" {{.table.BusinessName}}Model "{{.table.PackageName}}/app/model/{{.table.ModuleName}}/{{.table.BusinessName}}"
+121
View File
@@ -0,0 +1,121 @@
// ==========================================================================
// 生成日期:{{.table.CreateTime}}
// 生成人:{{.table.FunctionAuthor}}
// ==========================================================================
package {{.table.ModuleName}}
import (
"{{.table.PackageName}}/app/service/cache_service"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/net/ghttp"
{{.table.BusinessName}}Model "{{.table.PackageName}}/app/model/{{.table.ModuleName}}/{{.table.BusinessName}}"
{{.table.BusinessName}}Service "{{.table.PackageName}}/app/service/{{.table.ModuleName}}/{{.table.BusinessName}}_service"
"{{.table.PackageName}}/library/response"
"github.com/gogf/gf/util/gvalid"
)
//控制器
type {{.table.BusinessName|UcFirst}} struct{}
//列表页
func (c *{{.table.BusinessName|UcFirst}}) List(r *ghttp.Request) {
// 定义一个结构体存储请求参数
var req *{{.table.BusinessName}}Model.ReqSearchList
// 获取参数
err := r.Parse(&req)
if err != nil {
response.FailJson(true, r, err.(*gvalid.Error).FirstString())
}
list, err := {{.table.BusinessName}}Service.GetListSearch(req)
if err != nil {
response.FailJson(true, r, err.Error())
}
result := g.Map{
"list": list,
}
response.SusJson(true, r, "获取列表数据成功", result)
}
// 新增
func (c *{{.table.BusinessName|UcFirst}}) Add(r *ghttp.Request) {
if r.Method == "POST" {
var req *{{.table.BusinessName}}Model.ReqAdd
// 通过Parse方法解析获取参数
err := r.Parse(&req)
if err != nil {
response.FailJson(true, r, err.(*gvalid.Error).FirstString())
}
// 调用service中的添加函数添加
err = {{.table.BusinessName}}Service.AddSave(req)
if err != nil {
response.FailJson(true, r, err.Error())
}
cache_service.New().RemoveByTag("{{.table.ModuleName}}_{{.table.BusinessName}}_tag")
response.SusJson(true, r, "添加成功")
}
//获取上级分类
cates, err := {{.table.BusinessName}}Service.GetList()
if err != nil {
response.FailJson(true, r, err.Error())
}
response.SusJson(true, r, "ok", g.Map{
"parentList": cates,
})
}
// 修改
func (c *{{.table.BusinessName|UcFirst}}) Edit(r *ghttp.Request) {
// 如果是post提交的请求就执行修改操作
if r.Method == "POST" {
var editReq *{{.table.BusinessName}}Model.ReqEdit
// 通过Parse方法解析获取参数
err := r.Parse(&editReq)
if err != nil {
response.FailJson(true, r, err.(*gvalid.Error).FirstString())
}
err = {{.table.BusinessName}}Service.EditSave(editReq)
if err != nil {
response.FailJson(true, r, err.Error())
}
cache_service.New().RemoveByTag("{{.table.ModuleName}}_{{.table.BusinessName}}_tag")
response.SusJson(true, r, "修改成功")
}
// 不是post提交的请求就到修改页面后查询出要修改的记录
//获取上级
cates, err := {{.table.BusinessName}}Service.GetList()
if err != nil {
response.FailJson(true, r, err.Error())
}
//获取信息
id := r.GetUint("id")
menuInfo, err := {{.table.BusinessName}}Service.GetInfoById(id)
if err != nil {
response.FailJson(true, r, err.Error())
}
if menuInfo == nil {
response.FailJson(true, r, "参数错误")
}
response.SusJson(true, r, "ok", g.Map{
"parentList": cates,
"menuInfo": menuInfo,
})
}
// 删除
func (c *{{.table.BusinessName|UcFirst}}) Delete(r *ghttp.Request) {
var req *{{.table.BusinessName}}Model.RemoveReq
//获取参数
if err := r.Parse(&req); err != nil {
response.FailJson(true, r, err.(*gvalid.Error).FirstString())
}
err := {{.table.BusinessName}}Service.DeleteByIds(req.Ids)
if err != nil {
response.FailJson(true, r, "删除失败")
}
cache_service.New().RemoveByTag("{{.table.ModuleName}}_{{.table.BusinessName}}_tag")
response.SusJson(true, r, "删除成功")
}
+155
View File
@@ -0,0 +1,155 @@
// ==========================================================================
// 生成日期:{{.table.CreateTime}}
// 生成人:{{.table.FunctionAuthor}}
// ==========================================================================
package {{.table.BusinessName}}
import (
"{{.table.PackageName}}/app/service/cache_service"
"github.com/gogf/gf/container/gset"
"github.com/gogf/gf/errors/gerror"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/util/gconv"
)
{{$pk:=""}}
{{$pkGoField:=""}}
{{range $index, $column := .table.Columns}} {{if eq $column.IsPk "1"}}
{{$pk = $column.ColumnName}}
{{$pkGoField = $column.GoField}}
{{end}}{{end}}
// ReqAdd 用于存储新增请求的请求参数
type ReqAdd struct {
{{range $index, $column := .table.Columns}}
{{if and (eq $column.IsInsert "1") (ne $column.IsPk "1")}} {{$column.GoField}} {{if eq $column.GoType "Time"}} *gtime.Time {{else}} {{$column.GoType}} {{end}} `p:"{{$column.HtmlField}}" {{if eq $column.IsRequired "1"}}v:"required#{{$column.ColumnComment}}不能为空"{{end}}` {{end}} {{end}}
}
// ReqEdit 用于存储修改请求参数
type ReqEdit struct {
{{.table.PkColumn.GoField}} {{.table.PkColumn.GoType}} `p:"{{.table.PkColumn.HtmlField}}" v:"required#主键ID不能为空"` {{range $index, $column := .table.Columns}} {{if eq $column.IsEdit "1"}}
{{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else}}{{$column.GoType}}{{end}} `p:"{{$column.HtmlField}}" {{if eq $column.IsRequired "1"}}v:"required#{{$column.ColumnComment}}不能为空"{{end}}` {{end}} {{end}}
}
type RemoveReq struct {
Ids []int `p:"ids"` //删除id
}
// ReqSearchList 用于存储查询的请求参数
type ReqSearchList struct { {{range $index, $column := .table.Columns}} {{if eq $column.IsQuery "1"}}
{{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else}}{{$column.GoType}}{{end}} `p:"{{$column.HtmlField}}"` //{{$column.ColumnComment}} {{end}} {{end}}
}
// GetPlugAdByID 根据ID查询记录
func GetByID(id int64) (*Entity, error) {
entity, err := Model.FindOne(id)
if err != nil {
g.Log().Error(err)
err = gerror.New("根据ID查询记录出错")
}
if entity == nil {
err = gerror.New("根据ID未能查询到记录")
}
return entity, nil
}
// AddSave 添加
func AddSave(req *ReqAdd) error {
entity:= new(Entity)
{{range $index, $column := .table.Columns}}
{{if and (eq $column.IsInsert "1") (ne $column.IsPk "1")}}
entity.{{$column.GoField}} = req.{{$column.GoField}}
{{end}}
{{end}}
result, err := entity.Insert()
if err != nil {
return err
}
_, err = result.LastInsertId()
if err != nil {
return err
}
return nil
}
// 删除
func DeleteByIds(Ids []int) error {
_, err := Model.Delete("{{.table.PkColumn.ColumnName}} in(?)", Ids)
if err != nil {
g.Log().Error(err)
return gerror.New("删除失败")
}
return nil
}
// 根据ID来修改信息
func EditSave(req *ReqEdit) error {
// 先根据ID来查询要修改的记录
entity, err := GetByID(req.{{$pkGoField}})
if err != nil {
return err
}
// 修改实体
{{range $index, $column := .table.Columns}} {{if eq $column.IsEdit "1"}}
entity.{{$column.GoField}} = req.{{$column.GoField}}{{end}} {{end}}
_, err = entity.Update()
if err != nil {
g.Log().Error(err)
return gerror.New("修改失败")
}
return nil
}
// 列表查询
func GetListSearch(req *ReqSearchList) (list []*Entity, err error) {
list, err = GetList()
if req !=nil{
filterKey := gset.New(false)
tagWhere := true
for key, entity := range list {
{{range $index, $column := .table.Columns}}
{{if eq $column.IsQuery "1" }}
if tagWhere && gconv.String(req.{{$column.GoField}}) != "" && entity.{{$column.GoField}}!= req.{{$column.GoField}} {
tagWhere = true
}else{
tagWhere = false
}
{{end}}
{{end}}
if tagWhere{
filterKey.Add(key)
}
}
searchList := make([]*Entity, 0, len(list))
for key, entity := range list {
if !filterKey.Contains(key) {
searchList = append(searchList, entity)
}
}
list = searchList
}
return
}
func GetList() (list []*Entity, err error) {
cache := cache_service.New()
//从缓存获取数据
iList := cache.Get("{{.table.ModuleName}}_{{.table.BusinessName}}_{{.table.TableId}}")
if iList != nil {
list = iList.([]*Entity)
return
}
list, err = Model.Order(Columns.{{$pkGoField}}+" ASC").All()
if err != nil {
g.Log().Error()
err = gerror.New("获取数据失败")
return
}
//缓存数据
cache.Set("{{.table.ModuleName}}_{{.table.BusinessName}}_{{.table.TableId}}", list, 0, "{{.table.ModuleName}}_{{.table.BusinessName}}_tag")
return
}
+66
View File
@@ -0,0 +1,66 @@
// ==========================================================================
// 生成日期:{{.table.CreateTime}}
// 生成人:{{.table.FunctionAuthor}}
// ==========================================================================
package {{.table.BusinessName}}_service
import (
{{.table.BusinessName}}Model "{{.table.PackageName}}/app/model/{{.table.ModuleName}}/{{.table.BusinessName}}"
)
// 添加
func AddSave(req *{{.table.BusinessName}}Model.ReqAdd) error {
return {{.table.BusinessName}}Model.AddSave(req)
}
// 删除
func DeleteByIds(ids []int) (err error) {
ids, err = GetChildrenIds(ids)
if err != nil {
return
}
return {{.table.BusinessName}}Model.DeleteByIds(ids)
}
//修改
func EditSave(ReqEdit *{{.table.BusinessName}}Model.ReqEdit) error {
return {{.table.BusinessName}}Model.EditSave(ReqEdit)
}
// 根据ID查询
func GetInfoById(id int64) (*{{.table.BusinessName}}Model.Entity, error) {
return {{.table.BusinessName}}Model.GetByID(id)
}
// 列表查询
func GetListSearch(req *{{.table.BusinessName}}Model.ReqSearchList) (list []*{{.table.BusinessName}}Model.Entity, err error) {
return {{.table.BusinessName}}Model.GetListSearch(req)
}
//通过ID获取子级ID
func GetChildrenIds(ids []int) ([]int, error) {
//获取所有
menus, err := GetList()
if err != nil {
return nil, err
}
menuList := make(g.List, len(menus))
for k, menu := range menus {
menuList[k] = gconv.Map(menu)
}
for _, id := range ids {
children := utils.FindSonByParentId(menuList, id, "{{index .options "tree_code"}}", "{{index .options "tree_parent_code"}}")
for _, cid := range children {
ids = append(ids, gconv.Int(cid["{{index .options "tree_code"}}"]))
}
}
return ids, nil
}
//获取所有数据列表
func GetList() (list []*{{.table.BusinessName}}Model.Entity, err error) {
return {{.table.BusinessName}}Model.GetList()
}
+1 -1
View File
@@ -40,7 +40,7 @@ export function update{{.table.BusinessName|UcFirst}}(data) {
export function del{{.table.BusinessName|UcFirst}}(ids) { export function del{{.table.BusinessName|UcFirst}}(ids) {
return request({ return request({
url: '/{{.table.ModuleName}}/{{.table.BusinessName}}/delete', url: '/{{.table.ModuleName}}/{{.table.BusinessName}}/delete',
method: 'delete' method: 'delete',
data:{ids:ids} data:{ids:ids}
}) })
} }
+16 -16
View File
@@ -53,8 +53,8 @@
{{ $x := $column.IsList }} {{ $x := $column.IsList }}
{{ if eq $x "1"}} {{ if eq $x "1"}}
<el-table-column label="{{$column.ColumnComment}}" align="center" prop="{{$column.GoField}}" :show-overflow-tooltip="true" /> <el-table-column label="{{$column.ColumnComment}}" align="center" prop="{{$column.GoField}}" :show-overflow-tooltip="true" />
{{- end }} {{end }}
{{- end }} {{end }}
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@@ -90,12 +90,12 @@
default-expand-all default-expand-all
:tree-props="{children: 'children', hasChildren: 'hasChildren'}" :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
> >
{{range $index,$column:=.table.Columns}} {{range $index,$column:=.table.Columns}}
{{ $x := $column.IsList }} {{ $x := $column.IsList }}
{{ if eq $x "1"}} {{ if eq $x "1"}}
<el-table-column label="{{$column.ColumnComment}}" align="center" prop="{{$column.GoField}}" :show-overflow-tooltip="true" /> <el-table-column label="{{$column.ColumnComment}}" align="center" prop="{{$column.GoField}}" :show-overflow-tooltip="true" />
{{- end }} {{ end }}
{{- end }} {{ end }}
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@@ -173,7 +173,7 @@
import { list{{.table.BusinessName|UcFirst}}, get{{.table.BusinessName|UcFirst}}, del{{.table.BusinessName|UcFirst}}, add{{.table.BusinessName|UcFirst}}, update{{.table.BusinessName|UcFirst}} } from '@/api/{{.table.ModuleName}}/{{.table.BusinessName}}' import { list{{.table.BusinessName|UcFirst}}, get{{.table.BusinessName|UcFirst}}, del{{.table.BusinessName|UcFirst}}, add{{.table.BusinessName|UcFirst}}, update{{.table.BusinessName|UcFirst}} } from '@/api/{{.table.ModuleName}}/{{.table.BusinessName}}'
export default { export default {
name: 'Config', name: '{{.table.BusinessName|UcFirst}}',
data() { data() {
return { return {
// 遮罩层 // 遮罩层
@@ -235,7 +235,7 @@
/** 查询参数列表 */ /** 查询参数列表 */
getList() { getList() {
this.loading = true this.loading = true
list{{.table.ModuleName|UcFirst}}(this.addDateRange(this.queryParams, this.dateRange)).then(response => { list{{.table.BusinessName|UcFirst}}(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.{{.table.ModuleName}}List = response.data.list this.{{.table.ModuleName}}List = response.data.list
this.total = response.data.count this.total = response.data.count
this.loading = false this.loading = false
@@ -298,7 +298,7 @@
}, },
// 多选框选中数据 // 多选框选中数据
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.{{$pk}} this.ids = selection.map(item => item.{{$pk}})
this.single = selection.length !== 1 this.single = selection.length !== 1
this.multiple = !selection.length this.multiple = !selection.length
}, },
@@ -306,7 +306,7 @@
handleUpdate(row) { handleUpdate(row) {
this.reset() this.reset()
const {{$pk}} = row.{{$pk}} || this.ids const {{$pk}} = row.{{$pk}} || this.ids
get{{.table.ModuleName|UcFirst}}({{$pk}}).then(response => { get{{.table.BusinessName|UcFirst}}({{$pk}}).then(response => {
this.form = response.data this.form = response.data
this.open = true this.open = true
this.title = '修改{{.table.TableComment}}' this.title = '修改{{.table.TableComment}}'
@@ -318,7 +318,7 @@
this.$refs['form'].validate(valid => { this.$refs['form'].validate(valid => {
if (valid) { if (valid) {
if (this.form.{{$pk}} !== undefined) { if (this.form.{{$pk}} !== undefined) {
update{{.table.ModuleName|UcFirst}}(this.form).then(response => { update{{.table.BusinessName|UcFirst}}(this.form).then(response => {
if (response.code === 200) { if (response.code === 200) {
this.msgSuccess('修改成功') this.msgSuccess('修改成功')
this.open = false this.open = false
@@ -328,7 +328,7 @@
} }
}) })
} else { } else {
add{{.table.ModuleName|UcFirst}}(this.form).then(response => { add{{.table.BusinessName|UcFirst}}(this.form).then(response => {
if (response.code === 200) { if (response.code === 200) {
this.msgSuccess('新增成功') this.msgSuccess('新增成功')
this.open = false this.open = false
@@ -343,13 +343,13 @@
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const Ids = row.{{.PkJsonField}} || this.ids const Ids = row.{{$pk}} || this.ids
this.$confirm('是否确认删除编号为"' + Ids + '"的数据项?', '警告', { this.$confirm('是否确认删除编号为"' + Ids + '"的数据项?', '警告', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(function() { }).then(function() {
return del{{.table.ModuleName|UcFirst}}(Ids) return del{{.table.BusinessName|UcFirst}}(Ids)
}).then(() => { }).then(() => {
this.getList() this.getList()
this.msgSuccess('删除成功') this.msgSuccess('删除成功')