2022-04-01 22:19:52 +08:00
|
|
|
package gen
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/zeromicro/go-zero/tools/goctl/model/sql/template"
|
|
|
|
"github.com/zeromicro/go-zero/tools/goctl/util"
|
|
|
|
"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
|
|
|
|
)
|
|
|
|
|
|
|
|
func genTableName(table Table) (string, error) {
|
|
|
|
text, err := pathx.LoadTemplate(category, tableNameTemplateFile, template.TableName)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
output, err := util.With("tableName").
|
|
|
|
Parse(text).
|
2023-01-24 17:51:03 +08:00
|
|
|
Execute(map[string]any{
|
2022-04-01 22:19:52 +08:00
|
|
|
"tableName": table.Name.Source(),
|
|
|
|
"upperStartCamelObject": table.Name.ToCamel(),
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return "", nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return output.String(), nil
|
|
|
|
}
|