@@ -15,9 +15,9 @@ import (
|
|||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
var gloabIsRelated bool // 全局预加载
|
var globalIsRelated bool // 全局预加载
|
||||||
|
|
||||||
// prepare for outher
|
// prepare for other
|
||||||
type _BaseMgr struct {
|
type _BaseMgr struct {
|
||||||
*gorm.DB
|
*gorm.DB
|
||||||
ctx *context.Context
|
ctx *context.Context
|
||||||
@@ -67,12 +67,12 @@ func (f optionFunc) apply(o *options) {
|
|||||||
|
|
||||||
// OpenRelated 打开全局预加载
|
// OpenRelated 打开全局预加载
|
||||||
func OpenRelated() {
|
func OpenRelated() {
|
||||||
gloabIsRelated = true
|
globalIsRelated = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// CloseRelated 关闭全局预加载
|
// CloseRelated 关闭全局预加载
|
||||||
func CloseRelated() {
|
func CloseRelated() {
|
||||||
gloabIsRelated = true
|
globalIsRelated = true
|
||||||
}
|
}
|
||||||
|
|
||||||
`
|
`
|
||||||
@@ -87,7 +87,7 @@ func {{$obj.StructName}}Mgr(db *gorm.DB) *_{{$obj.StructName}}Mgr {
|
|||||||
if db == nil {
|
if db == nil {
|
||||||
panic(fmt.Errorf("{{$obj.StructName}}Mgr need init by db"))
|
panic(fmt.Errorf("{{$obj.StructName}}Mgr need init by db"))
|
||||||
}
|
}
|
||||||
return &_{{$obj.StructName}}Mgr{_BaseMgr: &_BaseMgr{DB: db, isRelated: gloabIsRelated}}
|
return &_{{$obj.StructName}}Mgr{_BaseMgr: &_BaseMgr{DB: db, isRelated: globalIsRelated}}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTableName get sql table name.获取数据库名字
|
// GetTableName get sql table name.获取数据库名字
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import (
|
|||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
var gloabIsRelated bool // 全局预加载
|
var globalIsRelated bool // 全局预加载
|
||||||
|
|
||||||
// prepare for outher
|
// prepare for other
|
||||||
type _BaseMgr struct {
|
type _BaseMgr struct {
|
||||||
*gorm.DB
|
*gorm.DB
|
||||||
ctx *context.Context
|
ctx *context.Context
|
||||||
@@ -57,10 +57,10 @@ func (f optionFunc) apply(o *options) {
|
|||||||
|
|
||||||
// OpenRelated 打开全局预加载
|
// OpenRelated 打开全局预加载
|
||||||
func OpenRelated() {
|
func OpenRelated() {
|
||||||
gloabIsRelated = true
|
globalIsRelated = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// CloseRelated 关闭全局预加载
|
// CloseRelated 关闭全局预加载
|
||||||
func CloseRelated() {
|
func CloseRelated() {
|
||||||
gloabIsRelated = true
|
globalIsRelated = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ func AccountMgr(db *gorm.DB) *_AccountMgr {
|
|||||||
if db == nil {
|
if db == nil {
|
||||||
panic(fmt.Errorf("AccountMgr need init by db"))
|
panic(fmt.Errorf("AccountMgr need init by db"))
|
||||||
}
|
}
|
||||||
return &_AccountMgr{_BaseMgr: &_BaseMgr{DB: db, isRelated: gloabIsRelated}}
|
return &_AccountMgr{_BaseMgr: &_BaseMgr{DB: db, isRelated: globalIsRelated}}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTableName get sql table name.获取数据库名字
|
// GetTableName get sql table name.获取数据库名字
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ func UserMgr(db *gorm.DB) *_UserMgr {
|
|||||||
if db == nil {
|
if db == nil {
|
||||||
panic(fmt.Errorf("UserMgr need init by db"))
|
panic(fmt.Errorf("UserMgr need init by db"))
|
||||||
}
|
}
|
||||||
return &_UserMgr{_BaseMgr: &_BaseMgr{DB: db, isRelated: gloabIsRelated}}
|
return &_UserMgr{_BaseMgr: &_BaseMgr{DB: db, isRelated: globalIsRelated}}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTableName get sql table name.获取数据库名字
|
// GetTableName get sql table name.获取数据库名字
|
||||||
|
|||||||
@@ -16,6 +16,6 @@ func TestTools(t *testing.T) {
|
|||||||
// out, _ := json.Marshal(pkg)
|
// out, _ := json.Marshal(pkg)
|
||||||
// tools.WriteFile("test.txt", []string{string(out)}, true)
|
// tools.WriteFile("test.txt", []string{string(out)}, true)
|
||||||
|
|
||||||
list := model.Generate(pkg)
|
list, _ := model.Generate(pkg)
|
||||||
fmt.Println(list)
|
fmt.Println(list)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ func getGormModelElement() []EmInfo {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildFList(list *[]FList, key ColumusKey, keyName, tp, colName string) {
|
func buildFList(list *[]FList, key ColumnsKey, keyName, tp, colName string) {
|
||||||
for i := 0; i < len(*list); i++ {
|
for i := 0; i < len(*list); i++ {
|
||||||
if (*list)[i].KeyName == keyName {
|
if (*list)[i].KeyName == keyName {
|
||||||
(*list)[i].Kem = append((*list)[i].Kem, FEm{
|
(*list)[i].Kem = append((*list)[i].Kem, FEm{
|
||||||
@@ -171,14 +171,14 @@ func GenFListIndex(info FList, status int) string {
|
|||||||
|
|
||||||
func widthFunctionName(info FList) string {
|
func widthFunctionName(info FList) string {
|
||||||
switch info.Key {
|
switch info.Key {
|
||||||
// case ColumusKeyDefault:
|
// case ColumnsKeyDefault:
|
||||||
case ColumusKeyPrimary: // primary key.主键
|
case ColumnsKeyPrimary: // primary key.主键
|
||||||
return "FetchByPrimaryKey"
|
return "FetchByPrimaryKey"
|
||||||
case ColumusKeyUnique: // unique key.唯一索引
|
case ColumnsKeyUnique: // unique key.唯一索引
|
||||||
return "FetchByUnique"
|
return "FetchByUnique"
|
||||||
case ColumusKeyIndex: // index key.复合索引
|
case ColumnsKeyIndex: // index key.复合索引
|
||||||
return "FetchBy" + getCamelName(info.KeyName) + "Index"
|
return "FetchBy" + getCamelName(info.KeyName) + "Index"
|
||||||
case ColumusKeyUniqueIndex: // unique index key.唯一复合索引
|
case ColumnsKeyUniqueIndex: // unique index key.唯一复合索引
|
||||||
return "FetchBy" + getCamelName(info.KeyName) + "UniqueIndex"
|
return "FetchBy" + getCamelName(info.KeyName) + "UniqueIndex"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,20 +5,20 @@ const (
|
|||||||
// _tagJSON = "json"
|
// _tagJSON = "json"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ColumusKey Columus type elem. 类型枚举
|
// ColumnsKey Columns type elem. 类型枚举
|
||||||
type ColumusKey int
|
type ColumnsKey int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// ColumusKeyDefault default
|
// ColumnsKeyDefault default
|
||||||
ColumusKeyDefault = iota
|
ColumnsKeyDefault = iota
|
||||||
// ColumusKeyPrimary primary key.主键
|
// ColumnsKeyPrimary primary key.主键
|
||||||
ColumusKeyPrimary
|
ColumnsKeyPrimary
|
||||||
// ColumusKeyUnique unique key.唯一索引
|
// ColumnsKeyUnique unique key.唯一索引
|
||||||
ColumusKeyUnique
|
ColumnsKeyUnique
|
||||||
// ColumusKeyIndex index key.复合索引
|
// ColumnsKeyIndex index key.复合索引
|
||||||
ColumusKeyIndex
|
ColumnsKeyIndex
|
||||||
// ColumusKeyUniqueIndex unique index key.唯一复合索引
|
// ColumnsKeyUniqueIndex unique index key.唯一复合索引
|
||||||
ColumusKeyUniqueIndex
|
ColumnsKeyUniqueIndex
|
||||||
)
|
)
|
||||||
|
|
||||||
// DBInfo database default info
|
// DBInfo database default info
|
||||||
@@ -32,11 +32,11 @@ type DBInfo struct {
|
|||||||
type TabInfo struct {
|
type TabInfo struct {
|
||||||
BaseInfo
|
BaseInfo
|
||||||
SQLBuildStr string // Create SQL statements.创建sql语句
|
SQLBuildStr string // Create SQL statements.创建sql语句
|
||||||
Em []ColumusInfo // Columus list .表列表组合
|
Em []ColumnsInfo // Columns list .表列表组合
|
||||||
}
|
}
|
||||||
|
|
||||||
// ColumusInfo Columus list .表列信息
|
// ColumnsInfo Columns list .表列信息
|
||||||
type ColumusInfo struct {
|
type ColumnsInfo struct {
|
||||||
BaseInfo
|
BaseInfo
|
||||||
Type string // Type.类型标记
|
Type string // Type.类型标记
|
||||||
Index []KList // index list.index列表
|
Index []KList // index list.index列表
|
||||||
@@ -52,7 +52,7 @@ type ForeignKey struct {
|
|||||||
|
|
||||||
// KList database index /unique_index list.数据库index /unique_index 列表
|
// KList database index /unique_index list.数据库index /unique_index 列表
|
||||||
type KList struct {
|
type KList struct {
|
||||||
Key ColumusKey // non_unique of (show keys from [table])
|
Key ColumnsKey // non_unique of (show keys from [table])
|
||||||
KeyName string // key_name of (show keys from [table])
|
KeyName string // key_name of (show keys from [table])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ type FEm struct {
|
|||||||
|
|
||||||
// FList index of list
|
// FList index of list
|
||||||
type FList struct {
|
type FList struct {
|
||||||
Key ColumusKey // non_unique of (show keys from [table])
|
Key ColumnsKey // non_unique of (show keys from [table])
|
||||||
KeyName string // key_name of (show keys from [table])
|
KeyName string // key_name of (show keys from [table])
|
||||||
Kem []FEm
|
Kem []FEm
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package genmysql
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/xxjwxc/gormt/data/config"
|
"github.com/xxjwxc/gormt/data/config"
|
||||||
@@ -98,10 +99,14 @@ func getPackageInfo(orm *mysqldb.MySqlDB, info *model.DBInfo) {
|
|||||||
|
|
||||||
info.TabList = append(info.TabList, tab)
|
info.TabList = append(info.TabList, tab)
|
||||||
}
|
}
|
||||||
|
// sort tables
|
||||||
|
sort.Slice(info.TabList, func(i, j int) bool {
|
||||||
|
return info.TabList[i].Name < info.TabList[j].Name
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// getTableElement Get table columns and comments.获取表列及注释
|
// getTableElement Get table columns and comments.获取表列及注释
|
||||||
func getTableElement(orm *mysqldb.MySqlDB, tab string) (el []model.ColumusInfo) {
|
func getTableElement(orm *mysqldb.MySqlDB, tab string) (el []model.ColumnsInfo) {
|
||||||
keyNums := make(map[string]int)
|
keyNums := make(map[string]int)
|
||||||
// get keys
|
// get keys
|
||||||
var Keys []keys
|
var Keys []keys
|
||||||
@@ -116,7 +121,7 @@ func getTableElement(orm *mysqldb.MySqlDB, tab string) (el []model.ColumusInfo)
|
|||||||
orm.Raw("show FULL COLUMNS from " + tab).Scan(&list)
|
orm.Raw("show FULL COLUMNS from " + tab).Scan(&list)
|
||||||
// filter gorm.Model.过滤 gorm.Model
|
// filter gorm.Model.过滤 gorm.Model
|
||||||
if filterModel(&list) {
|
if filterModel(&list) {
|
||||||
el = append(el, model.ColumusInfo{
|
el = append(el, model.ColumnsInfo{
|
||||||
Type: "gorm.Model",
|
Type: "gorm.Model",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -131,7 +136,7 @@ func getTableElement(orm *mysqldb.MySqlDB, tab string) (el []model.ColumusInfo)
|
|||||||
// ------------------end
|
// ------------------end
|
||||||
|
|
||||||
for _, v := range list {
|
for _, v := range list {
|
||||||
var tmp model.ColumusInfo
|
var tmp model.ColumnsInfo
|
||||||
tmp.Name = v.Field
|
tmp.Name = v.Field
|
||||||
tmp.Notes = v.Desc
|
tmp.Notes = v.Desc
|
||||||
tmp.Type = v.Type
|
tmp.Type = v.Type
|
||||||
@@ -139,20 +144,20 @@ func getTableElement(orm *mysqldb.MySqlDB, tab string) (el []model.ColumusInfo)
|
|||||||
// keys
|
// keys
|
||||||
if strings.EqualFold(v.Key, "PRI") { // Set primary key.设置主键
|
if strings.EqualFold(v.Key, "PRI") { // Set primary key.设置主键
|
||||||
tmp.Index = append(tmp.Index, model.KList{
|
tmp.Index = append(tmp.Index, model.KList{
|
||||||
Key: model.ColumusKeyPrimary,
|
Key: model.ColumnsKeyPrimary,
|
||||||
})
|
})
|
||||||
} else if strings.EqualFold(v.Key, "UNI") { // unique
|
} else if strings.EqualFold(v.Key, "UNI") { // unique
|
||||||
tmp.Index = append(tmp.Index, model.KList{
|
tmp.Index = append(tmp.Index, model.KList{
|
||||||
Key: model.ColumusKeyUnique,
|
Key: model.ColumnsKeyUnique,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
for _, v1 := range Keys {
|
for _, v1 := range Keys {
|
||||||
if strings.EqualFold(v1.ColumnName, v.Field) {
|
if strings.EqualFold(v1.ColumnName, v.Field) {
|
||||||
var k model.KList
|
var k model.KList
|
||||||
if v1.NonUnique == 1 { // index
|
if v1.NonUnique == 1 { // index
|
||||||
k.Key = model.ColumusKeyIndex
|
k.Key = model.ColumnsKeyIndex
|
||||||
} else {
|
} else {
|
||||||
k.Key = model.ColumusKeyUniqueIndex
|
k.Key = model.ColumnsKeyUniqueIndex
|
||||||
}
|
}
|
||||||
if keyNums[v1.KeyName] > 1 { // Composite index.复合索引
|
if keyNums[v1.KeyName] > 1 { // Composite index.复合索引
|
||||||
k.KeyName = v1.KeyName
|
k.KeyName = v1.KeyName
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ func Generate(info DBInfo) (out []GenOutInfo, m _Model) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPackage gen sturct on table
|
// GetPackage gen struct on table
|
||||||
func (m *_Model) GetPackage() genstruct.GenPackage {
|
func (m *_Model) GetPackage() genstruct.GenPackage {
|
||||||
if m.pkg == nil {
|
if m.pkg == nil {
|
||||||
var pkg genstruct.GenPackage
|
var pkg genstruct.GenPackage
|
||||||
@@ -69,7 +69,7 @@ func (m *_Model) generate() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// genTableElement Get table columns and comments.获取表列及注释
|
// genTableElement Get table columns and comments.获取表列及注释
|
||||||
func (m *_Model) genTableElement(cols []ColumusInfo) (el []genstruct.GenElement) {
|
func (m *_Model) genTableElement(cols []ColumnsInfo) (el []genstruct.GenElement) {
|
||||||
_tagGorm := config.GetDBTag()
|
_tagGorm := config.GetDBTag()
|
||||||
_tagJSON := config.GetURLTag()
|
_tagJSON := config.GetURLTag()
|
||||||
|
|
||||||
@@ -83,14 +83,14 @@ func (m *_Model) genTableElement(cols []ColumusInfo) (el []genstruct.GenElement)
|
|||||||
tmp.SetType(getTypeName(v.Type))
|
tmp.SetType(getTypeName(v.Type))
|
||||||
for _, v1 := range v.Index {
|
for _, v1 := range v.Index {
|
||||||
switch v1.Key {
|
switch v1.Key {
|
||||||
// case ColumusKeyDefault:
|
// case ColumnsKeyDefault:
|
||||||
case ColumusKeyPrimary: // primary key.主键
|
case ColumnsKeyPrimary: // primary key.主键
|
||||||
tmp.AddTag(_tagGorm, "primary_key")
|
tmp.AddTag(_tagGorm, "primary_key")
|
||||||
case ColumusKeyUnique: // unique key.唯一索引
|
case ColumnsKeyUnique: // unique key.唯一索引
|
||||||
tmp.AddTag(_tagGorm, "unique")
|
tmp.AddTag(_tagGorm, "unique")
|
||||||
case ColumusKeyIndex: // index key.复合索引
|
case ColumnsKeyIndex: // index key.复合索引
|
||||||
tmp.AddTag(_tagGorm, getUninStr("index", ":", v1.KeyName))
|
tmp.AddTag(_tagGorm, getUninStr("index", ":", v1.KeyName))
|
||||||
case ColumusKeyUniqueIndex: // unique index key.唯一复合索引
|
case ColumnsKeyUniqueIndex: // unique index key.唯一复合索引
|
||||||
tmp.AddTag(_tagGorm, getUninStr("unique_index", ":", v1.KeyName))
|
tmp.AddTag(_tagGorm, getUninStr("unique_index", ":", v1.KeyName))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,12 +130,12 @@ func (m *_Model) genTableElement(cols []ColumusInfo) (el []genstruct.GenElement)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// genForeignKey Get information about foreign key of table column.获取表列外键相关信息
|
// genForeignKey Get information about foreign key of table column.获取表列外键相关信息
|
||||||
func (m *_Model) genForeignKey(col ColumusInfo) (fklist []genstruct.GenElement) {
|
func (m *_Model) genForeignKey(col ColumnsInfo) (fklist []genstruct.GenElement) {
|
||||||
_tagGorm := config.GetDBTag()
|
_tagGorm := config.GetDBTag()
|
||||||
_tagJSON := config.GetURLTag()
|
_tagJSON := config.GetURLTag()
|
||||||
|
|
||||||
for _, v := range col.ForeignKeyList {
|
for _, v := range col.ForeignKeyList {
|
||||||
isMulti, isFind, notes := m.getColumusKeyMulti(v.TableName, v.ColumnName)
|
isMulti, isFind, notes := m.getColumnsKeyMulti(v.TableName, v.ColumnName)
|
||||||
if isFind {
|
if isFind {
|
||||||
var tmp genstruct.GenElement
|
var tmp genstruct.GenElement
|
||||||
tmp.SetNotes(notes)
|
tmp.SetNotes(notes)
|
||||||
@@ -162,7 +162,7 @@ func (m *_Model) genForeignKey(col ColumusInfo) (fklist []genstruct.GenElement)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *_Model) getColumusKeyMulti(tableName, col string) (isMulti bool, isFind bool, notes string) {
|
func (m *_Model) getColumnsKeyMulti(tableName, col string) (isMulti bool, isFind bool, notes string) {
|
||||||
var haveGomod bool
|
var haveGomod bool
|
||||||
for _, v := range m.info.TabList {
|
for _, v := range m.info.TabList {
|
||||||
if strings.EqualFold(v.Name, tableName) {
|
if strings.EqualFold(v.Name, tableName) {
|
||||||
@@ -170,11 +170,11 @@ func (m *_Model) getColumusKeyMulti(tableName, col string) (isMulti bool, isFind
|
|||||||
if strings.EqualFold(v1.Name, col) {
|
if strings.EqualFold(v1.Name, col) {
|
||||||
for _, v2 := range v1.Index {
|
for _, v2 := range v1.Index {
|
||||||
switch v2.Key {
|
switch v2.Key {
|
||||||
case ColumusKeyPrimary, ColumusKeyUnique, ColumusKeyUniqueIndex: // primary key unique key . 主键,唯一索引
|
case ColumnsKeyPrimary, ColumnsKeyUnique, ColumnsKeyUniqueIndex: // primary key unique key . 主键,唯一索引
|
||||||
{
|
{
|
||||||
return false, true, v.Notes
|
return false, true, v.Notes
|
||||||
}
|
}
|
||||||
// case ColumusKeyIndex: // index key. 复合索引
|
// case ColumnsKeyIndex: // index key. 复合索引
|
||||||
// {
|
// {
|
||||||
// isMulti = true
|
// isMulti = true
|
||||||
// }
|
// }
|
||||||
@@ -239,24 +239,24 @@ func (m *_Model) generateFunc() (genOut []GenOutInfo) {
|
|||||||
if strings.EqualFold(el.Type, "gorm.Model") {
|
if strings.EqualFold(el.Type, "gorm.Model") {
|
||||||
data.Em = append(data.Em, getGormModelElement()...)
|
data.Em = append(data.Em, getGormModelElement()...)
|
||||||
pkg.AddImport(`"time"`)
|
pkg.AddImport(`"time"`)
|
||||||
buildFList(&primary, ColumusKeyPrimary, "", "int64", "id")
|
buildFList(&primary, ColumnsKeyPrimary, "", "int64", "id")
|
||||||
} else {
|
} else {
|
||||||
typeName := getTypeName(el.Type)
|
typeName := getTypeName(el.Type)
|
||||||
isMulti := true
|
isMulti := true
|
||||||
for _, v1 := range el.Index {
|
for _, v1 := range el.Index {
|
||||||
switch v1.Key {
|
switch v1.Key {
|
||||||
// case ColumusKeyDefault:
|
// case ColumnsKeyDefault:
|
||||||
case ColumusKeyPrimary: // primary key.主键
|
case ColumnsKeyPrimary: // primary key.主键
|
||||||
isMulti = false
|
isMulti = false
|
||||||
buildFList(&primary, ColumusKeyPrimary, "", typeName, el.Name)
|
buildFList(&primary, ColumnsKeyPrimary, "", typeName, el.Name)
|
||||||
case ColumusKeyUnique: // unique key.唯一索引
|
case ColumnsKeyUnique: // unique key.唯一索引
|
||||||
isMulti = false
|
isMulti = false
|
||||||
buildFList(&unique, ColumusKeyUnique, "", typeName, el.Name)
|
buildFList(&unique, ColumnsKeyUnique, "", typeName, el.Name)
|
||||||
case ColumusKeyIndex: // index key.复合索引
|
case ColumnsKeyIndex: // index key.复合索引
|
||||||
buildFList(&index, ColumusKeyIndex, v1.KeyName, typeName, el.Name)
|
buildFList(&index, ColumnsKeyIndex, v1.KeyName, typeName, el.Name)
|
||||||
case ColumusKeyUniqueIndex: // unique index key.唯一复合索引
|
case ColumnsKeyUniqueIndex: // unique index key.唯一复合索引
|
||||||
isMulti = false
|
isMulti = false
|
||||||
buildFList(&uniqueIndex, ColumusKeyUniqueIndex, v1.KeyName, typeName, el.Name)
|
buildFList(&uniqueIndex, ColumnsKeyUniqueIndex, v1.KeyName, typeName, el.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,7 +276,7 @@ func (m *_Model) generateFunc() (genOut []GenOutInfo) {
|
|||||||
|
|
||||||
// 外键列表
|
// 外键列表
|
||||||
for _, v := range el.ForeignKeyList {
|
for _, v := range el.ForeignKeyList {
|
||||||
isMulti, isFind, notes := m.getColumusKeyMulti(v.TableName, v.ColumnName)
|
isMulti, isFind, notes := m.getColumnsKeyMulti(v.TableName, v.ColumnName)
|
||||||
if isFind {
|
if isFind {
|
||||||
var info PreloadInfo
|
var info PreloadInfo
|
||||||
info.IsMulti = isMulti
|
info.IsMulti = isMulti
|
||||||
|
|||||||
Reference in New Issue
Block a user