Commit 77123080 authored by nanahira's avatar nanahira

renew

parent b8168cdb
Pipeline #11419 passed with stages
in 1 minute and 12 seconds
#!/bin/bash
npm install --save-exact typeorm@0.2.45
npm install --save \
class-validator \
class-transformer \
@nestjs/swagger \
swagger-ui-express \
typeorm \
@nestjs/typeorm \
@nestjs/config \
pg \
......
import { ConsoleLogger } from '@nestjs/common';
import { ClassConstructor } from 'class-transformer';
import {
DeepPartial,
DeleteResult,
FindConditions,
In,
......@@ -103,7 +104,7 @@ export class CrudBase<
await beforeCreate(repo);
}
try {
const results = await repo.save(ents);
const results = await repo.save(ents as DeepPartial<T>[]);
return {
results,
skipped,
......@@ -142,7 +143,7 @@ export class CrudBase<
await beforeCreate(repo);
}
try {
return await repo.save(ent);
return await repo.save(ent as DeepPartial<T>);
} catch (e) {
this.error(
`Failed to create entity ${JSON.stringify(ent)}: ${e.toString()}`,
......@@ -335,7 +336,11 @@ export class CrudBase<
);
await Promise.all(remainingEnts.map((ent) => ent.prepareForSaving()));
const { data } = await this.batchCreate(remainingEnts, undefined, true);
data.results.forEach((e) => e.afterSaving());
data.results.forEach((e) => {
if (e.afterSaving) {
e.afterSaving();
}
});
const results = [
...invalidResults,
...data.skipped,
......
import { ApiProperty } from '@nestjs/swagger';
export class ImportEntryBaseDto {
@ApiProperty({ description: '导入结果' })
result: string;
}
export interface ImportEntry<T> {
entry: T;
result: string;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment