From b540462e7268c4684a8756f203f68f327c451575 Mon Sep 17 00:00:00 2001 From: lxyer <237809796@qq.com> Date: Sun, 16 Jun 2019 17:53:11 +0800 Subject: [PATCH] . --- src/main/resources/tpl/_t.tpl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main/resources/tpl/_t.tpl b/src/main/resources/tpl/_t.tpl index a15cb4f..b2bc05e 100644 --- a/src/main/resources/tpl/_t.tpl +++ b/src/main/resources/tpl/_t.tpl @@ -4,4 +4,27 @@ return JBean.OK; } +#end + +#sql("go.struct") +// #(comment) +type #(name) struct { + #for(x : columns) + #(x.field) #(x.type) + #end +} + +func List(filter *base.Filper) []#(name) { + db, _ := mysql.Db() + + rows, _ := db.Query("select #for(x : columns)#(x.field), #end from #(name) order by createtime desc limit ?,?", filter.Offset, filter.Limit) + var records []#(name) + for rows.Next() { + r := #(name){} + rows.Scan(#for(x : columns)&r.#(x.field), #end) + records = append(records, r) + } + return records +} + #end \ No newline at end of file