cmd/gf: use automatic generating package names for go files of dao/do/entity instead of constant package names (#3639)

This commit is contained in:
Insua 2024-06-13 21:13:05 +08:00 committed by GitHub
parent 2ccbb02c71
commit 88f188d0f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 7 additions and 3 deletions

View File

@ -118,6 +118,7 @@ generated json tag case for model struct, cases are as follows:
tplVarGroupName = `{TplGroupName}`
tplVarDatetimeStr = `{TplDatetimeStr}`
tplVarCreatedAtDatetimeStr = `{TplCreatedAtDatetimeStr}`
tplVarPackageName = `{TplPackageName}`
)
var (

View File

@ -116,6 +116,7 @@ func generateDaoIndex(in generateDaoIndexInput) {
tplVarTableName: in.TableName,
tplVarTableNameCamelCase: in.TableNameCamelCase,
tplVarTableNameCamelLowerCase: in.TableNameCamelLowerCase,
tplVarPackageName: filepath.Base(in.DaoPath),
})
indexContent = replaceDefaultVar(in.CGenDaoInternalInput, indexContent)
if err := gfile.PutContents(path, strings.TrimSpace(indexContent)); err != nil {

View File

@ -85,6 +85,7 @@ func generateDoContent(
tplVarPackageImports: getImportPartContent(ctx, structDefine, true, nil),
tplVarTableNameCamelCase: tableNameCamelCase,
tplVarStructDefine: structDefine,
tplVarPackageName: filepath.Base(in.DoPath),
},
)
doContent = replaceDefaultVar(in, doContent)

View File

@ -70,6 +70,7 @@ func generateEntityContent(
tplVarPackageImports: getImportPartContent(ctx, structDefine, false, appendImports),
tplVarTableNameCamelCase: tableNameCamelCase,
tplVarStructDefine: structDefine,
tplVarPackageName: filepath.Base(in.EntityPath),
},
)
entityContent = replaceDefaultVar(in, entityContent)

View File

@ -11,7 +11,7 @@ const TemplateGenDaoIndexContent = `
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package dao
package {TplPackageName}
import (
"{TplImportPrefix}/internal"

View File

@ -11,7 +11,7 @@ const TemplateGenDaoDoContent = `
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. {TplCreatedAtDatetimeStr}
// =================================================================================
package do
package {TplPackageName}
{TplPackageImports}

View File

@ -11,7 +11,7 @@ const TemplateGenDaoEntityContent = `
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. {TplCreatedAtDatetimeStr}
// =================================================================================
package entity
package {TplPackageName}
{TplPackageImports}