diff --git a/core/package.json b/core/package.json index 629af0e..8586570 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@cool-midway/core", - "version": "7.1.20", + "version": "7.1.21", "description": "", "main": "dist/index.js", "typings": "index.d.ts", diff --git a/core/src/controller/base.ts b/core/src/controller/base.ts index a1e91b0..da76d52 100644 --- a/core/src/controller/base.ts +++ b/core/src/controller/base.ts @@ -65,11 +65,25 @@ export abstract class BaseController { if (!curdOption?.insertParam) { return; } - this.baseCtx.request.body = { - // @ts-ignore - ...this.baseCtx.request.body, - ...(await curdOption.insertParam(this.baseCtx, this.baseApp)), - }; + const body = this.baseCtx.request.body; + if (body) { + // 判断body是否是数组 + if (Array.isArray(body)) { + for (let i = 0; i < body.length; i++) { + body[i] = { + ...body[i], + ...(await curdOption.insertParam(this.baseCtx, this.baseApp)), + }; + } + this.baseCtx.request.body = body; + return; + } + this.baseCtx.request.body = { + // @ts-ignore + ...this.baseCtx.request.body, + ...(await curdOption.insertParam(this.baseCtx, this.baseApp)), + }; + } } /** diff --git a/core/src/package.json b/core/src/package.json index 7aef125..1c88b70 100644 --- a/core/src/package.json +++ b/core/src/package.json @@ -1,6 +1,6 @@ { "name": "@cool-midway/core", - "version": "7.1.20", + "version": "7.1.21", "description": "", "main": "index.js", "typings": "index.d.ts",