后端搭建起来

This commit is contained in:
aixianling
2022-12-30 16:34:57 +08:00
parent b8ac23dcfd
commit d1f2a42f1c
3 changed files with 8 additions and 4 deletions

View File

@@ -24,10 +24,13 @@ class DbService extends Service {
}
async list(table, params = {}) {
let {current = 0} = params
let {current = 0, size = 10} = params
delete params.size
delete params.current
delete params.total
const records = await this.app.mysql.select(table, {
where: params,
limit: params?.size || 10, // 返回数据量
limit: size || 10, // 返回数据量
offset: Math.max(--current, 0), // 数据偏移量
})
const total = (await this.app.mysql.select(table, {where: params}))?.length || 0