Commit a2162e3f authored by nanahira's avatar nanahira

removes

parent 2d216a78
Pipeline #10496 passed with stages
in 58 seconds
......@@ -17,10 +17,8 @@ import { QueryWise } from '../entities/interfaces/QueryWise';
import { camelCase } from 'typeorm/util/StringUtils';
import { DeletionWise, ImportWise } from '../entities/bases/TimeBase.entity';
import { PageSettingsFactory } from '../dto/PageSettings.dto';
import { generateEntityFromRaw } from '../utility/generateEntityFromRaw';
import { ImportEntry } from 'src/dto/import-entry.dto';
import _ from 'lodash';
import { CsvParseService } from 'src/csv-parse/csv-parse/csv-parse.service';
export type EntityId<T extends { id: any }> = T['id'];
export interface RelationDef {
......@@ -312,28 +310,6 @@ export class CrudBase<
return new BlankReturnMessageDto(204, 'success');
}
async importCsv(
csvService: CsvParseService,
data: Buffer,
encoding = 'utf8',
extraChecking?: (ent: T) => string | Promise<string>,
) {
try {
const raw = await csvService.parseCsv<any>(data, {
targetEncoding: encoding,
columns: true,
cast: false,
});
const ents = raw.map((d) => generateEntityFromRaw(this.entityClass, d));
return this.importEntities(ents, extraChecking);
} catch (e) {
throw new BlankReturnMessageDto(
400,
'文件解析失败,请检查文件格式。',
).toException();
}
}
async importEntities(
ents: T[],
extraChecking?: (ent: T) => string | Promise<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