diff --git a/data/view/model/common.go b/data/view/model/common.go index ff1ae60..e92f849 100644 --- a/data/view/model/common.go +++ b/data/view/model/common.go @@ -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) +} diff --git a/data/view/model/model.go b/data/view/model/model.go index 2d899c1..2ae9a11 100644 --- a/data/view/model/model.go +++ b/data/view/model/model.go @@ -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) diff --git a/doc/func.md b/doc/func.md index caca622..3c8550c 100644 --- a/doc/func.md +++ b/doc/func.md @@ -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) \ No newline at end of file diff --git a/doc/func_cn.md b/doc/func_cn.md index 8f97e05..7f5934e 100644 --- a/doc/func_cn.md +++ b/doc/func_cn.md @@ -53,6 +53,6 @@ ### 索引方式获取 `FetchByPrimaryKey` : 主键获取 - `FetchByUnique` : 唯一索引方式获取 + `FetchUniqueBy[xxx]` : 唯一索引方式获取 `FetchIndexBy[xxx]` : 复合索引获取(返回多个) `FetchUniqueIndexBy[xxx]` : 唯一复合索引获取(返回一个) \ No newline at end of file