refactor(nestjs): export module

This commit is contained in:
Ahmed Bouhuolia
2025-04-08 16:19:35 +02:00
parent 6287f8b6e3
commit 04c25bd31a
60 changed files with 748 additions and 504 deletions

View File

@@ -14,6 +14,7 @@ import { TenancyContext } from '../Tenancy/TenancyContext.service';
import { VendorsController } from './Vendors.controller';
import { GetVendorsService } from './queries/GetVendors.service';
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
import { VendorsExportable } from './VendorsExportable';
@Module({
imports: [TenancyDatabaseModule, DynamicListModule],
@@ -31,6 +32,7 @@ import { DynamicListModule } from '../DynamicListing/DynamicList.module';
VendorsApplication,
TransformerInjectable,
TenancyContext,
VendorsExportable
],
})
export class VendorsModule {}

View File

@@ -1,30 +1,34 @@
// import { Inject, Service } from 'typedi';
// import { IItemsFilter } from '@/interfaces';
// import { Exportable } from '@/services/Export/Exportable';
// import { VendorsApplication } from './VendorsApplication';
// import { EXPORT_SIZE_LIMIT } from '@/services/Export/constants';
import { Injectable } from '@nestjs/common';
import { VendorsApplication } from './VendorsApplication.service';
import { Exportable } from '../Export/Exportable';
import { IVendorsFilter } from './types/Vendors.types';
import { EXPORT_SIZE_LIMIT } from '../Export/constants';
import { ExportableService } from '../Export/decorators/ExportableModel.decorator';
import { Vendor } from './models/Vendor';
// @Service()
// export class VendorsExportable extends Exportable {
// @Inject()
// private vendorsApplication: VendorsApplication;
@Injectable()
@ExportableService({ name: Vendor.name })
export class VendorsExportable extends Exportable {
constructor(
private readonly vendorsApplication: VendorsApplication,
) {
super();
}
// /**
// * Retrieves the accounts data to exportable sheet.
// * @param {number} tenantId
// * @returns
// */
// public exportable(tenantId: number, query: IItemsFilter) {
// const parsedQuery = {
// sortOrder: 'DESC',
// columnSortBy: 'created_at',
// ...query,
// page: 1,
// pageSize: EXPORT_SIZE_LIMIT,
// } as IItemsFilter;
/**
* Retrieves the vendors data to exportable sheet.
*/
public exportable(query: IVendorsFilter) {
const parsedQuery = {
sortOrder: 'DESC',
columnSortBy: 'created_at',
...query,
page: 1,
pageSize: EXPORT_SIZE_LIMIT,
} as IVendorsFilter;
// return this.vendorsApplication
// .getVendors(tenantId, parsedQuery)
// .then((output) => output.vendors);
// }
// }
return this.vendorsApplication
.getVendors(parsedQuery)
.then((output) => output.vendors);
}
}

View File

@@ -8,6 +8,7 @@ import { Model, mixin } from 'objection';
// import ModelSearchable from './ModelSearchable';
import { BaseModel } from '@/models/Model';
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
// class VendorQueryBuilder extends PaginationQueryBuilder {
// constructor(...args) {
@@ -21,6 +22,7 @@ import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
// }
// }
@ExportableModel()
export class Vendor extends TenantBaseModel {
contactService: string;
contactType: string;