add multi unique support
添加多个unique index支持,调整unique接口名。 FetchUniqueBy[xxx]
This commit is contained in:
@@ -195,7 +195,7 @@ func widthFunctionName(info FList) string {
|
||||
case ColumnsKeyPrimary: // primary key.主键
|
||||
return "FetchByPrimaryKey"
|
||||
case ColumnsKeyUnique: // unique key.唯一索引
|
||||
return "FetchByUnique"
|
||||
return "FetchUniqueBy" + getCamelName(info.KeyName)
|
||||
case ColumnsKeyIndex: // index key.复合索引
|
||||
return "FetchIndexBy" + getCamelName(info.KeyName)
|
||||
case ColumnsKeyUniqueIndex: // unique index key.唯一复合索引
|
||||
@@ -204,3 +204,7 @@ func widthFunctionName(info FList) string {
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func fixNotes(str string) string { // 注释
|
||||
return strings.Replace(str, "\n", "\n//", -1)
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ func (m *_Model) generateFunc() (genOut []GenOutInfo) {
|
||||
for _, tab := range m.info.TabList {
|
||||
var pkg genstruct.GenPackage
|
||||
pkg.SetPackage(m.info.PackageName) //package name
|
||||
pkg.AddImport(`"github.com/jinzhu/gorm"`)
|
||||
pkg.AddImport(cnf.EImportsHead["gorm.Model"])
|
||||
pkg.AddImport(`"fmt"`)
|
||||
|
||||
data := funDef{
|
||||
@@ -265,7 +265,7 @@ func (m *_Model) generateFunc() (genOut []GenOutInfo) {
|
||||
|
||||
data.Em = append(data.Em, EmInfo{
|
||||
IsMulti: isMulti,
|
||||
Notes: el.Notes,
|
||||
Notes: fixNotes(el.Notes),
|
||||
Type: typeName, // Type.类型标记
|
||||
ColName: el.Name,
|
||||
ColStructName: getCamelName(el.Name),
|
||||
@@ -283,7 +283,7 @@ func (m *_Model) generateFunc() (genOut []GenOutInfo) {
|
||||
if isFind {
|
||||
var info PreloadInfo
|
||||
info.IsMulti = isMulti
|
||||
info.Notes = notes
|
||||
info.Notes = fixNotes(notes)
|
||||
info.ForeignkeyTableName = v.TableName
|
||||
info.ForeignkeyCol = v.ColumnName
|
||||
info.ForeignkeyStructName = getCamelName(v.TableName)
|
||||
|
||||
@@ -57,6 +57,6 @@
|
||||
### Index access
|
||||
|
||||
`FetchByPrimaryKey` : Primary key acquisition
|
||||
`FetchByUnique` : Get by unique index
|
||||
`FetchUniqueBy[xxx]` : Get by unique index
|
||||
`FetchIndexBy[xxx]` : Composite index fetch (multiple returned)
|
||||
`FetchUniqueIndexBy[xxx]` : Unique composite index fetch (return one)
|
||||
@@ -53,6 +53,6 @@
|
||||
|
||||
### 索引方式获取
|
||||
`FetchByPrimaryKey` : 主键获取
|
||||
`FetchByUnique` : 唯一索引方式获取
|
||||
`FetchUniqueBy[xxx]` : 唯一索引方式获取
|
||||
`FetchIndexBy[xxx]` : 复合索引获取(返回多个)
|
||||
`FetchUniqueIndexBy[xxx]` : 唯一复合索引获取(返回一个)
|
||||
Reference in New Issue
Block a user