feat: import resources from csv/xlsx

This commit is contained in:
Ahmed Bouhuolia
2024-03-11 00:21:36 +02:00
parent 1fc6445123
commit 90b4f3ef6d
16 changed files with 467 additions and 184 deletions

View File

@@ -1,11 +1,24 @@
import { Inject } from 'typedi';
import { ImportFileUploadService } from './ImportFileUpload';
import { ImportFileMapping } from './ImportFileMapping';
import { ImportMappingAttr } from './interfaces';
import { ImportFileProcess } from './ImportFileProcess';
import { ImportFilePreview } from './ImportFilePreview';
@Inject()
export class ImportResourceApplication {
@Inject()
private importFileService: ImportFileUploadService;
@Inject()
private importMappingService: ImportFileMapping;
@Inject()
private importProcessService: ImportFileProcess;
@Inject()
private ImportFilePreviewService: ImportFilePreview;
/**
* Reads the imported file and stores the import file meta under unqiue id.
* @param {number} tenantId -
@@ -26,4 +39,38 @@ export class ImportResourceApplication {
filename
);
}
/**
* Mapping the excel sheet columns with resource columns.
* @param {number} tenantId
* @param {number} importId
* @param {ImportMappingAttr} maps
*/
public async mapping(
tenantId: number,
importId: number,
maps: ImportMappingAttr[]
) {
return this.importMappingService.mapping(tenantId, importId, maps);
}
/**
* Preview the mapped results before process importing.
* @param {number} tenantId
* @param {number} importId
* @returns {}
*/
public async preview(tenantId: number, importId: number) {
return this.ImportFilePreviewService.preview(tenantId, importId);
}
/**
*
* @param {number} tenantId
* @param {number} importId
* @returns
*/
public async process(tenantId: number, importId: number) {
return this.importProcessService.process(tenantId, importId);
}
}