Skip to content

Commit

Permalink
fix(mysqlmd): 修复生成数据表 CURD BUG
Browse files Browse the repository at this point in the history
- 修复当数据表前缀相同时,重复生成的问题,例如 表名:admin、admin_menu
- 修复当字段后缀为数字时,生成错误的问题,例如 字段:test_1、test_2
  • Loading branch information
xinliangnote committed Sep 11, 2021
1 parent f47f57e commit 77e8d58
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions cmd/mysqlmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"log"
"os"
"regexp"
"strings"

"github.com/xinliangnote/go-gin-api/cmd/mysqlmd/mysql"
Expand Down Expand Up @@ -237,7 +236,7 @@ func queryTableColumn(db *gorm.DB, dbName string, tableName string) ([]tableColu
func getTargetIndexMap(tableNameArr []string, item string) map[int]int {
indexMap := make(map[int]int)
for i := 0; i < len(tableNameArr); i++ {
if match, _ := regexp.MatchString(item, tableNameArr[i]); match {
if tableNameArr[i] == item {
if _, ok := indexMap[i]; ok {
continue
}
Expand All @@ -256,8 +255,8 @@ func capitalize(s string) string {
if i == 0 {
if vv[i] >= 97 && vv[i] <= 122 {
vv[i] -= 32
upperStr += string(vv[i])
}
upperStr += string(vv[i])
} else {
upperStr += string(vv[i])
}
Expand Down

0 comments on commit 77e8d58

Please sign in to comment.