Skip to content

Commit 4ec9eb9

Browse files
committed
【框架优化】优化生成model组件
1 parent 14064dd commit 4ec9eb9

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

cmd/model.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,15 @@ func ModelCmd() *cli.Command {
6464

6565
// generateModel 创建model
6666
func generateModel() error {
67+
modelConfig := &gomodel.ModelConfig{
68+
DB: global.DB,
69+
DbName: global.Cfg.Mysql[0].DbName,
70+
MDir: mDir,
71+
Prefix: prefix,
72+
IsCover: true,
73+
}
6774
if tbName == "all" {
68-
strs, errs := gomodel.GenerateAllModel(global.DB, global.Cfg.Mysql[0].DbName, mDir, prefix)
75+
strs, errs := gomodel.GenerateAllModel(modelConfig)
6976
for i, str := range strs {
7077
if errs[i] != nil {
7178
fmt.Println(fmt.Sprintf("\x1b[31m%s\x1b[0m", str))
@@ -74,7 +81,7 @@ func generateModel() error {
7481
}
7582
}
7683
} else {
77-
str, err := gomodel.GenerateSingleModel(global.DB, global.Cfg.Mysql[0].DbName, tbName, mDir, prefix)
84+
str, err := gomodel.GenerateSingleModel(modelConfig, tbName)
7885
if err != nil {
7986
fmt.Println(fmt.Sprintf("\x1b[31m%s\x1b[0m", str))
8087
return err

go.mod

+6-8
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ go 1.18
44

55
require (
66
github.com/MQEnergy/go-rabbitmq v0.1.0
7-
github.com/MQEnergy/gorm-model v1.1.2
7+
github.com/MQEnergy/gorm-model v1.1.3
88
github.com/bwmarrin/snowflake v0.3.0
9-
github.com/casbin/casbin/v2 v2.52.0
10-
github.com/casbin/gorm-adapter/v3 v3.7.4
9+
github.com/casbin/casbin/v2 v2.52.2
10+
github.com/casbin/gorm-adapter/v3 v3.8.0
1111
github.com/dgrijalva/jwt-go v3.2.0+incompatible
1212
github.com/gin-contrib/cors v1.4.0
1313
github.com/gin-contrib/requestid v0.0.5
@@ -32,7 +32,6 @@ require (
3232
)
3333

3434
require (
35-
github.com/BurntSushi/toml v1.2.0 // indirect
3635
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
3736
github.com/cespare/xxhash/v2 v2.1.2 // indirect
3837
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
@@ -42,8 +41,7 @@ require (
4241
github.com/gin-contrib/sse v0.1.0 // indirect
4342
github.com/glebarez/go-sqlite v1.18.1 // indirect
4443
github.com/glebarez/sqlite v1.4.6 // indirect
45-
github.com/go-bindata/go-bindata v3.1.2+incompatible // indirect
46-
github.com/goccy/go-json v0.9.10 // indirect
44+
github.com/goccy/go-json v0.9.11 // indirect
4745
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
4846
github.com/golang-sql/sqlexp v0.1.0 // indirect
4947
github.com/google/uuid v1.3.0 // indirect
@@ -84,10 +82,10 @@ require (
8482
go.opentelemetry.io/otel v1.9.0 // indirect
8583
go.opentelemetry.io/otel/trace v1.9.0 // indirect
8684
go.uber.org/atomic v1.10.0 // indirect
87-
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
85+
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 // indirect
8886
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
8987
golang.org/x/net v0.0.0-20220812174116-3211cb980234 // indirect
90-
golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2 // indirect
88+
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6 // indirect
9189
golang.org/x/text v0.3.8-0.20211105212822-18b340fc7af2 // indirect
9290
google.golang.org/protobuf v1.28.1 // indirect
9391
gopkg.in/ini.v1 v1.67.0 // indirect

0 commit comments

Comments
 (0)