diff --git a/server/app/middleware/errorHandler.js b/server/app/middleware/errorHandler.js index 0bacc2e..d906b37 100644 --- a/server/app/middleware/errorHandler.js +++ b/server/app/middleware/errorHandler.js @@ -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; } diff --git a/server/app/service/db.js b/server/app/service/db.js index f1f83b5..aebdb10 100644 --- a/server/app/service/db.js +++ b/server/app/service/db.js @@ -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 diff --git a/server/config/config.default.js b/server/config/config.default.js index 59c1f34..da8788f 100644 --- a/server/config/config.default.js +++ b/server/config/config.default.js @@ -22,7 +22,8 @@ module.exports = { }, security: { csrf: { - enable: false + queryName: "token", + ignore: ctx => ctx.headers.passport == "c799f2d92de34b97"//md5编码:kubbo&flora } } }