diff --git a/core/package.json b/core/package.json index f8c0a71..9c3bd50 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@cool-midway/core", - "version": "7.0.3", + "version": "7.0.4", "description": "", "main": "dist/index.js", "typings": "index.d.ts", diff --git a/core/src/interface.ts b/core/src/interface.ts index 76d7922..caf24b1 100644 --- a/core/src/interface.ts +++ b/core/src/interface.ts @@ -37,6 +37,8 @@ export interface CoolConfig { softDelete: boolean; /** 分页查询每页条数 */ pageSize: number; + /** 插入方式 */ + upsert : 'normal' | 'save' // 多租户 // tenant: boolean; }; diff --git a/core/src/package.json b/core/src/package.json index fd0a452..4dcf6f2 100644 --- a/core/src/package.json +++ b/core/src/package.json @@ -1,6 +1,6 @@ { "name": "@cool-midway/core", - "version": "7.0.3", + "version": "7.0.4", "description": "", "main": "index.js", "typings": "index.d.ts", diff --git a/core/src/rest/eps.ts b/core/src/rest/eps.ts index 0d41f92..8def106 100644 --- a/core/src/rest/eps.ts +++ b/core/src/rest/eps.ts @@ -138,6 +138,7 @@ export class CoolEps { for (const entityMetadata of entityMetadatas) { const commColums = []; let columns = entityMetadata.columns; + if(entityMetadata.tableType != 'regular') continue; columns = _.filter( columns.map((e) => { return { diff --git a/core/src/service/base.ts b/core/src/service/base.ts index c0678c1..2affdef 100644 --- a/core/src/service/base.ts +++ b/core/src/service/base.ts @@ -338,14 +338,15 @@ export abstract class BaseService { }); await this.entity.save(param); } else{ + const upsert = this._coolConfig.crud?.upsert || 'normal'; if (type == 'update') { param.updateTime = new Date(); - await this.entity.update(param.id, param); + upsert == 'normal'? await this.entity.update(param.id, param): await this.entity.save(param); } if(type =='add'){ param.createTime = new Date(); param.updateTime = new Date(); - await this.entity.insert(param); + upsert == 'normal'? await this.entity.insert(param): await this.entity.save(param); } } await this.modifyAfter(param, type);