class Base{
constructor(tabName,columns=[]){
this.tabName=tabName,
this.columns=columns
}
/* 查询全部数据 */
async findAll(){
const statement=`select ${this.columns.join()} from ${this.tabName} `
let [rows]=await db.query(statement)
return rows
}
/* 分页查询菜单 */
async findByPage(page = 1, size = 10){
const startId = (page - 1) * size
const statement=`select ${this.columns.join()} from ${this.tabName} where limit ?,?`
let [rows]=await db.query(statement,[parseInt(startId),parseInt(size)])
return rows
}
/* 查询数据总数 */
async findTotal(){
const statement=`select count(1) as cnt