mirror of
https://gitee.com/johng/gf.git
synced 2024-12-02 04:07:47 +08:00
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:
parent
2ccbb02c71
commit
88f188d0f9
@ -118,6 +118,7 @@ generated json tag case for model struct, cases are as follows:
|
|||||||
tplVarGroupName = `{TplGroupName}`
|
tplVarGroupName = `{TplGroupName}`
|
||||||
tplVarDatetimeStr = `{TplDatetimeStr}`
|
tplVarDatetimeStr = `{TplDatetimeStr}`
|
||||||
tplVarCreatedAtDatetimeStr = `{TplCreatedAtDatetimeStr}`
|
tplVarCreatedAtDatetimeStr = `{TplCreatedAtDatetimeStr}`
|
||||||
|
tplVarPackageName = `{TplPackageName}`
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -116,6 +116,7 @@ func generateDaoIndex(in generateDaoIndexInput) {
|
|||||||
tplVarTableName: in.TableName,
|
tplVarTableName: in.TableName,
|
||||||
tplVarTableNameCamelCase: in.TableNameCamelCase,
|
tplVarTableNameCamelCase: in.TableNameCamelCase,
|
||||||
tplVarTableNameCamelLowerCase: in.TableNameCamelLowerCase,
|
tplVarTableNameCamelLowerCase: in.TableNameCamelLowerCase,
|
||||||
|
tplVarPackageName: filepath.Base(in.DaoPath),
|
||||||
})
|
})
|
||||||
indexContent = replaceDefaultVar(in.CGenDaoInternalInput, indexContent)
|
indexContent = replaceDefaultVar(in.CGenDaoInternalInput, indexContent)
|
||||||
if err := gfile.PutContents(path, strings.TrimSpace(indexContent)); err != nil {
|
if err := gfile.PutContents(path, strings.TrimSpace(indexContent)); err != nil {
|
||||||
|
@ -85,6 +85,7 @@ func generateDoContent(
|
|||||||
tplVarPackageImports: getImportPartContent(ctx, structDefine, true, nil),
|
tplVarPackageImports: getImportPartContent(ctx, structDefine, true, nil),
|
||||||
tplVarTableNameCamelCase: tableNameCamelCase,
|
tplVarTableNameCamelCase: tableNameCamelCase,
|
||||||
tplVarStructDefine: structDefine,
|
tplVarStructDefine: structDefine,
|
||||||
|
tplVarPackageName: filepath.Base(in.DoPath),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
doContent = replaceDefaultVar(in, doContent)
|
doContent = replaceDefaultVar(in, doContent)
|
||||||
|
@ -70,6 +70,7 @@ func generateEntityContent(
|
|||||||
tplVarPackageImports: getImportPartContent(ctx, structDefine, false, appendImports),
|
tplVarPackageImports: getImportPartContent(ctx, structDefine, false, appendImports),
|
||||||
tplVarTableNameCamelCase: tableNameCamelCase,
|
tplVarTableNameCamelCase: tableNameCamelCase,
|
||||||
tplVarStructDefine: structDefine,
|
tplVarStructDefine: structDefine,
|
||||||
|
tplVarPackageName: filepath.Base(in.EntityPath),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
entityContent = replaceDefaultVar(in, entityContent)
|
entityContent = replaceDefaultVar(in, entityContent)
|
||||||
|
@ -11,7 +11,7 @@ const TemplateGenDaoIndexContent = `
|
|||||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||||
// =================================================================================
|
// =================================================================================
|
||||||
|
|
||||||
package dao
|
package {TplPackageName}
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"{TplImportPrefix}/internal"
|
"{TplImportPrefix}/internal"
|
||||||
|
@ -11,7 +11,7 @@ const TemplateGenDaoDoContent = `
|
|||||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. {TplCreatedAtDatetimeStr}
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. {TplCreatedAtDatetimeStr}
|
||||||
// =================================================================================
|
// =================================================================================
|
||||||
|
|
||||||
package do
|
package {TplPackageName}
|
||||||
|
|
||||||
{TplPackageImports}
|
{TplPackageImports}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ const TemplateGenDaoEntityContent = `
|
|||||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. {TplCreatedAtDatetimeStr}
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. {TplCreatedAtDatetimeStr}
|
||||||
// =================================================================================
|
// =================================================================================
|
||||||
|
|
||||||
package entity
|
package {TplPackageName}
|
||||||
|
|
||||||
{TplPackageImports}
|
{TplPackageImports}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user