Commit 77123080 authored by nanahira's avatar nanahira

renew

parent b8168cdb
Pipeline #11419 passed with stages
in 1 minute and 12 seconds
#!/bin/bash #!/bin/bash
npm install --save-exact typeorm@0.2.45
npm install --save \ npm install --save \
class-validator \ class-validator \
class-transformer \ class-transformer \
@nestjs/swagger \ @nestjs/swagger \
swagger-ui-express \ swagger-ui-express \
typeorm \
@nestjs/typeorm \ @nestjs/typeorm \
@nestjs/config \ @nestjs/config \
pg \ pg \
......
import { ConsoleLogger } from '@nestjs/common'; import { ConsoleLogger } from '@nestjs/common';
import { ClassConstructor } from 'class-transformer'; import { ClassConstructor } from 'class-transformer';
import { import {
DeepPartial,
DeleteResult, DeleteResult,
FindConditions, FindConditions,
In, In,
...@@ -103,7 +104,7 @@ export class CrudBase< ...@@ -103,7 +104,7 @@ export class CrudBase<
await beforeCreate(repo); await beforeCreate(repo);
} }
try { try {
const results = await repo.save(ents); const results = await repo.save(ents as DeepPartial<T>[]);
return { return {
results, results,
skipped, skipped,
...@@ -142,7 +143,7 @@ export class CrudBase< ...@@ -142,7 +143,7 @@ export class CrudBase<
await beforeCreate(repo); await beforeCreate(repo);
} }
try { try {
return await repo.save(ent); return await repo.save(ent as DeepPartial<T>);
} catch (e) { } catch (e) {
this.error( this.error(
`Failed to create entity ${JSON.stringify(ent)}: ${e.toString()}`, `Failed to create entity ${JSON.stringify(ent)}: ${e.toString()}`,
...@@ -335,7 +336,11 @@ export class CrudBase< ...@@ -335,7 +336,11 @@ export class CrudBase<
); );
await Promise.all(remainingEnts.map((ent) => ent.prepareForSaving())); await Promise.all(remainingEnts.map((ent) => ent.prepareForSaving()));
const { data } = await this.batchCreate(remainingEnts, undefined, true); 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 = [ const results = [
...invalidResults, ...invalidResults,
...data.skipped, ...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