mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
refactor(nestjs): export module
This commit is contained in:
36
packages/server/src/modules/Items/ItemsExportable.service.ts
Normal file
36
packages/server/src/modules/Items/ItemsExportable.service.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Global, Injectable } from '@nestjs/common';
|
||||
import { Exportable } from '../Export/Exportable';
|
||||
import { EXPORT_SIZE_LIMIT } from '../Export/constants';
|
||||
import { ItemsApplicationService } from './ItemsApplication.service';
|
||||
import { IItemsFilter } from './types/Items.types';
|
||||
import { ExportableService } from '../Export/decorators/ExportableModel.decorator';
|
||||
import { Item } from './models/Item';
|
||||
|
||||
@Injectable()
|
||||
@ExportableService({ name: Item.name })
|
||||
@Global()
|
||||
export class ItemsExportable extends Exportable {
|
||||
constructor(
|
||||
private readonly itemsApplication: ItemsApplicationService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the accounts data to exportable sheet.
|
||||
* @param {IItemsFilter} query - Items export query.
|
||||
*/
|
||||
public exportable(query: IItemsFilter) {
|
||||
const parsedQuery = {
|
||||
sortOrder: 'DESC',
|
||||
columnSortBy: 'created_at',
|
||||
page: 1,
|
||||
...query,
|
||||
pageSize: EXPORT_SIZE_LIMIT,
|
||||
} as IItemsFilter;
|
||||
|
||||
return this.itemsApplication
|
||||
.getItems(parsedQuery)
|
||||
.then((output) => output.items);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user