支持视图,crud支持新增修改支持动态配置,支持配置成save,save不校验字段

This commit is contained in:
cool 2023-12-19 15:12:25 +08:00
parent d15ae19f33
commit 41b886e055
5 changed files with 8 additions and 4 deletions

View File

@ -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",

View File

@ -37,6 +37,8 @@ export interface CoolConfig {
softDelete: boolean;
/** 分页查询每页条数 */
pageSize: number;
/** 插入方式 */
upsert : 'normal' | 'save'
// 多租户
// tenant: boolean;
};

View File

@ -1,6 +1,6 @@
{
"name": "@cool-midway/core",
"version": "7.0.3",
"version": "7.0.4",
"description": "",
"main": "index.js",
"typings": "index.d.ts",

View File

@ -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 {

View File

@ -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);