mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
refactor(nestjs): list resources
This commit is contained in:
@@ -6,9 +6,13 @@ import {
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { CustomersApplication } from './CustomersApplication.service';
|
||||
import { ICustomerOpeningBalanceEditDTO } from './types/Customers.types';
|
||||
import {
|
||||
ICustomerOpeningBalanceEditDTO,
|
||||
ICustomersFilter,
|
||||
} from './types/Customers.types';
|
||||
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { CreateCustomerDto } from './dtos/CreateCustomer.dto';
|
||||
import { EditCustomerDto } from './dtos/EditCustomer.dto';
|
||||
@@ -24,6 +28,12 @@ export class CustomersController {
|
||||
return this.customersApplication.getCustomer(customerId);
|
||||
}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'Retrieves the customers paginated list.' })
|
||||
getCustomers(@Query() filterDTO: Partial<ICustomersFilter>) {
|
||||
return this.customersApplication.getCustomers(filterDTO);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@ApiOperation({ summary: 'Create a new customer.' })
|
||||
createCustomer(@Body() customerDTO: CreateCustomerDto) {
|
||||
|
||||
@@ -76,7 +76,7 @@ export class CustomersApplication {
|
||||
* Retrieve customers paginated list.
|
||||
* @param {ICustomersFilter} filter - Cusotmers filter.
|
||||
*/
|
||||
public getCustomers = (filterDTO: ICustomersFilter) => {
|
||||
public getCustomers = (filterDTO: Partial<ICustomersFilter>) => {
|
||||
return this.getCustomersService.getCustomersList(filterDTO);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -34,10 +34,18 @@ export class GetCustomers {
|
||||
* @returns {Promise<GetCustomersResponse>}
|
||||
*/
|
||||
public async getCustomersList(
|
||||
filterDTO: ICustomersFilter,
|
||||
filterDto: Partial<ICustomersFilter>,
|
||||
): Promise<GetCustomersResponse> {
|
||||
const _filterDto = {
|
||||
inactiveMode: false,
|
||||
sortOrder: 'desc',
|
||||
columnSortBy: 'created_at',
|
||||
page: 1,
|
||||
pageSize: 12,
|
||||
...filterDto,
|
||||
};
|
||||
// Parses customers list filter DTO.
|
||||
const filter = this.parseCustomersListFilterDTO(filterDTO);
|
||||
const filter = this.parseCustomersListFilterDTO(_filterDto);
|
||||
|
||||
const dynamicList = await this.dynamicListService.dynamicList(
|
||||
this.customerModel(),
|
||||
|
||||
Reference in New Issue
Block a user