From 4c84e08c182c5df921880ba2c0429a3e813a3336 Mon Sep 17 00:00:00 2001 From: John Guo Date: Thu, 3 Jun 2021 19:12:57 +0800 Subject: [PATCH] improve template for command gen dao --- commands/gen/gen_dao_template_dao.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/commands/gen/gen_dao_template_dao.go b/commands/gen/gen_dao_template_dao.go index 71437c4..e75b35c 100644 --- a/commands/gen/gen_dao_template_dao.go +++ b/commands/gen/gen_dao_template_dao.go @@ -15,7 +15,7 @@ import ( // and custom defined data operations functions management. You can define // methods on it to extend its functionality as you wish. type {TplTableNameCamelLowerCase}Dao struct { - internal.{TplTableNameCamelCase}Dao + *internal.{TplTableNameCamelCase}Dao } var ( @@ -25,7 +25,7 @@ var ( func init() { {TplTableNameCamelCase} = {TplTableNameCamelLowerCase}Dao{ - internal.{TplTableNameCamelCase}, + internal.New{TplTableNameCamelCase}Dao(), } } @@ -60,13 +60,8 @@ type {TplTableNameCamelLowerCase}Columns struct { {TplColumnDefine} } -var ( - // {TplTableNameCamelCase} is globally public accessible object for table {TplTableName} operations. - {TplTableNameCamelCase} {TplTableNameCamelCase}Dao -) - -func init() { - {TplTableNameCamelCase} = {TplTableNameCamelCase}Dao{ +func New{TplTableNameCamelCase}Dao() *{TplTableNameCamelCase}Dao { + return &{TplTableNameCamelCase}Dao{ M: g.DB("{TplGroupName}").Model("{TplTableName}").Safe(), DB: g.DB("{TplGroupName}"), Table: "{TplTableName}",