后端搭建起来
This commit is contained in:
@@ -10,7 +10,7 @@ module.exports = () => async function errorHandler(ctx, next) {
|
||||
? 'Internal Server Error'
|
||||
: err.message;
|
||||
// 从 error 对象上读出各个属性,设置到响应中
|
||||
ctx.body = {error};
|
||||
ctx.body = {code: 1, error};
|
||||
if (status === 422) {
|
||||
ctx.body.detail = err.errors;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -22,7 +22,8 @@ module.exports = {
|
||||
},
|
||||
security: {
|
||||
csrf: {
|
||||
enable: false
|
||||
queryName: "token",
|
||||
ignore: ctx => ctx.headers.passport == "c799f2d92de34b97"//md5编码:kubbo&flora
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user