mirror of
https://github.com/cool-team-official/cool-admin-midway-packages.git
synced 2025-12-14 15:32:51 +00:00
支持视图,crud支持新增修改支持动态配置,支持配置成save,save不校验字段
This commit is contained in:
parent
d15ae19f33
commit
41b886e055
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cool-midway/core",
|
"name": "@cool-midway/core",
|
||||||
"version": "7.0.3",
|
"version": "7.0.4",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "index.d.ts",
|
"typings": "index.d.ts",
|
||||||
|
|||||||
@ -37,6 +37,8 @@ export interface CoolConfig {
|
|||||||
softDelete: boolean;
|
softDelete: boolean;
|
||||||
/** 分页查询每页条数 */
|
/** 分页查询每页条数 */
|
||||||
pageSize: number;
|
pageSize: number;
|
||||||
|
/** 插入方式 */
|
||||||
|
upsert : 'normal' | 'save'
|
||||||
// 多租户
|
// 多租户
|
||||||
// tenant: boolean;
|
// tenant: boolean;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cool-midway/core",
|
"name": "@cool-midway/core",
|
||||||
"version": "7.0.3",
|
"version": "7.0.4",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"typings": "index.d.ts",
|
"typings": "index.d.ts",
|
||||||
|
|||||||
@ -138,6 +138,7 @@ export class CoolEps {
|
|||||||
for (const entityMetadata of entityMetadatas) {
|
for (const entityMetadata of entityMetadatas) {
|
||||||
const commColums = [];
|
const commColums = [];
|
||||||
let columns = entityMetadata.columns;
|
let columns = entityMetadata.columns;
|
||||||
|
if(entityMetadata.tableType != 'regular') continue;
|
||||||
columns = _.filter(
|
columns = _.filter(
|
||||||
columns.map((e) => {
|
columns.map((e) => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -338,14 +338,15 @@ export abstract class BaseService {
|
|||||||
});
|
});
|
||||||
await this.entity.save(param);
|
await this.entity.save(param);
|
||||||
} else{
|
} else{
|
||||||
|
const upsert = this._coolConfig.crud?.upsert || 'normal';
|
||||||
if (type == 'update') {
|
if (type == 'update') {
|
||||||
param.updateTime = new Date();
|
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'){
|
if(type =='add'){
|
||||||
param.createTime = new Date();
|
param.createTime = new Date();
|
||||||
param.updateTime = 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);
|
await this.modifyAfter(param, type);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user