feat: gen model
This commit is contained in:
@@ -93,21 +93,14 @@ func commandGenModelE(cmd *cobra.Command, args []string) error {
|
|||||||
return defaultTableModelField
|
return defaultTableModelField
|
||||||
}
|
}
|
||||||
|
|
||||||
splits := strings.SplitN(toType, ".", 2)
|
if strings.Contains(toType, "[") && strings.HasSuffix(toType, "]") {
|
||||||
typeName := splits[len(splits)-1]
|
toType = strings.Replace(toType, "[", "[fields.", 1)
|
||||||
|
|
||||||
pkg := splits[0]
|
|
||||||
if strings.HasPrefix(pkg, "~") {
|
|
||||||
pkg = strings.Replace(pkg, "~", gomod.GetModuleName(), 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pkgSplits := strings.Split(splits[0], "/")
|
|
||||||
typePkg := pkgSplits[len(pkgSplits)-1]
|
|
||||||
|
|
||||||
defaultTableModelField = defaultTableModelField.
|
defaultTableModelField = defaultTableModelField.
|
||||||
UseType(template.Type{
|
UseType(template.Type{
|
||||||
Name: fmt.Sprintf("%s.%s", typePkg, typeName),
|
Name: fmt.Sprintf("fields.%s", toType),
|
||||||
ImportPath: pkg,
|
ImportPath: fmt.Sprintf("%s/database/fields", gomod.GetModuleName()),
|
||||||
})
|
})
|
||||||
|
|
||||||
log.Infof("Convert table %s field %s type to : %s", table.Name, column.Name, toType)
|
log.Infof("Convert table %s field %s type to : %s", table.Name, column.Name, toType)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# ignores: [] # ignore tables
|
# ignores: [] # ignore tables
|
||||||
# types:
|
# types:
|
||||||
# users: # table name
|
# users: # table name
|
||||||
# meta: ~/database/fields.UserMeta
|
# meta: UserMeta
|
||||||
|
# meta: Json[UserMeta]
|
||||||
|
|||||||
Reference in New Issue
Block a user