Merge pull request #106 from nanfangstation/master

tablePrefix
This commit is contained in:
xxj
2021-01-14 19:51:10 -06:00
committed by GitHub
2 changed files with 15 additions and 1 deletions

View File

@@ -218,6 +218,11 @@ func (m *mysqlModel) getTables(orm *mysqldb.MySqlDB) map[string]string {
for rows.Next() {
var table string
rows.Scan(&table)
tablePrefix := config.GetTablePrefix()
if tablePrefix != "" && !strings.Contains(table, tablePrefix) {
// 不包含前缀则跳过
continue
}
tables = append(tables, table)
tbDesc[table] = ""
}

View File

@@ -57,7 +57,11 @@ func (m *_Model) GetPackage() genstruct.GenPackage {
//如果设置了表前缀
if tablePrefix != "" {
tab.Name = strings.TrimLeft(tab.Name, tablePrefix)
var hasPrefix = strings.Contains(tab.Name, tablePrefix)
if !hasPrefix {
// 不包含前缀则跳过
continue
}
}
sct.SetStructName(getCamelName(tab.Name)) // Big hump.大驼峰
@@ -248,6 +252,11 @@ func (m *_Model) generateFunc() (genOut []GenOutInfo) {
// -------end------
for _, tab := range m.info.TabList {
tablePrefix := config.GetTablePrefix()
if tablePrefix != "" && !strings.Contains(tab.Name, tablePrefix) {
// 不包含前缀则跳过
continue
}
var pkg genstruct.GenPackage
pkg.SetPackage(m.info.PackageName) //package name
pkg.AddImport(`"fmt"`)