From 127883199503022551f30c88b094c8b53ed6f934 Mon Sep 17 00:00:00 2001 From: xxj <346944475@qq.com> Date: Tue, 4 Jan 2022 18:16:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0page=20=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.yml | 1 + data/config/MyIni.go | 6 ++++++ data/view/model/model.go | 24 ++++++++++++------------ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/config.yml b/config.yml index b4eaa91..2b293c5 100644 --- a/config.yml +++ b/config.yml @@ -19,6 +19,7 @@ is_null_to_point : false # 数据库默认 'DEFAULT NULL' 时设置结构为指 table_prefix : "" # 表前缀, 如果有则使用, 没有留空(如果表前缀以"-"开头,则表示去掉该前缀,struct、文件名都会去掉该前缀) table_names: "" # 指定表生成,多个表用,隔开 is_out_file_by_table_name: false # 是否根据表名生成多个model +is_out_page: true # 是否输出分页函数 db_info: host : 127.0.0.1 # type=1的时候,host为yml文件全路径 diff --git a/data/config/MyIni.go b/data/config/MyIni.go index cc12dc4..a53b6db 100644 --- a/data/config/MyIni.go +++ b/data/config/MyIni.go @@ -32,6 +32,7 @@ type Config struct { TableNames string `yaml:"table_names"` // 表名(多个表名用","隔开) IsColumnName bool `yaml:"is_column_name"` //是否输出列名 IsOutFileByTableName bool `yaml:"is_out_file_by_table_name"` //是否根据表名生成文件(多个表名生成多个文件) + IsOutPage bool `yaml:"is_out_page"` // 是否输出分页支持 } // DBInfo mysql database information. mysql 数据库信息 @@ -316,3 +317,8 @@ func SetIsColumnName(isColumnName bool) { func GetIsOutFileByTableName() bool { return _map.IsOutFileByTableName } + +// GetIsOutPage 是否输出分页函数支持 +func GetIsOutPage() bool { + return _map.IsOutPage +} diff --git a/data/view/model/model.go b/data/view/model/model.go index 19de35a..da0ac26 100755 --- a/data/view/model/model.go +++ b/data/view/model/model.go @@ -324,21 +324,21 @@ func (m *_Model) generateFunc() (genOut []GenOutInfo) { // -------end------ // gen page 分页查询的基础 - genPage, err := template.New("gen_page").Parse(genfunc.GetGenPageTemp()) - if err != nil { - panic(err) - } - - var bufPage bytes.Buffer - genPage.Execute(&bufPage, m.info) - genOut = append(genOut, GenOutInfo{ - FileName: "gen.page.go", - FileCtx: bufPage.String(), - }) + if config.GetIsOutPage() { + genPage, err := template.New("gen_page").Parse(genfunc.GetGenPageTemp()) + if err != nil { + panic(err) + } + var bufPage bytes.Buffer + genPage.Execute(&bufPage, m.info) + genOut = append(genOut, GenOutInfo{ + FileName: "gen.page.go", + FileCtx: bufPage.String(), + }) + } // -------end------ - for _, tab := range m.info.TabList { var pkg genstruct.GenPackage pkg.SetPackage(m.info.PackageName) //package name