refactor(nestjs): wip dtos validation schema

This commit is contained in:
Ahmed Bouhuolia
2025-05-26 17:04:53 +02:00
parent 24bf3dd06d
commit 83c9392b74
8 changed files with 116 additions and 42 deletions

View File

@@ -15,11 +15,15 @@ import {
EditBillPaymentDto,
} from './dtos/BillPayment.dto';
import { GetBillPaymentsFilterDto } from './dtos/GetBillPaymentsFilter.dto';
import { BillPaymentsPages } from './commands/BillPaymentsPages.service';
@Controller('bill-payments')
@ApiTags('bill-payments')
export class BillPaymentsController {
constructor(private billPaymentsApplication: BillPaymentsApplication) {}
constructor(
private billPaymentsApplication: BillPaymentsApplication,
private billPaymentsPagesService: BillPaymentsPages,
) {}
@Post()
@ApiOperation({ summary: 'Create a new bill payment.' })
@@ -59,6 +63,24 @@ export class BillPaymentsController {
);
}
@Get('/new-page/entries')
@ApiOperation({
summary:
'Retrieves the payable entries of the new page once vendor be selected.',
})
@ApiParam({
name: 'vendorId',
required: true,
type: Number,
description: 'The vendor id',
})
async getBillPaymentNewPageEntries(@Query('vendorId') vendorId: number) {
const entries =
await this.billPaymentsPagesService.getNewPageEntries(vendorId);
return entries;
}
@Get(':billPaymentId/bills')
@ApiOperation({ summary: 'Retrieves the bills of the given bill payment.' })
@ApiParam({
@@ -71,6 +93,25 @@ export class BillPaymentsController {
return this.billPaymentsApplication.getPaymentBills(Number(billPaymentId));
}
@Get('/:billPaymentId/edit-page')
@ApiOperation({
summary: 'Retrieves the edit page of the given bill payment.',
})
@ApiParam({
name: 'billPaymentId',
required: true,
type: Number,
description: 'The bill payment id',
})
public async getBillPaymentEditPage(
@Param('billPaymentId') billPaymentId: number,
) {
const billPaymentsWithEditEntries =
await this.billPaymentsPagesService.getBillPaymentEditPage(billPaymentId);
return billPaymentsWithEditEntries;
}
@Get(':billPaymentId')
@ApiOperation({ summary: 'Retrieves the bill payment details.' })
@ApiParam({
@@ -83,8 +124,14 @@ export class BillPaymentsController {
return this.billPaymentsApplication.getBillPayment(Number(billPaymentId));
}
@Get('')
@Get()
@ApiOperation({ summary: 'Retrieves the bill payments list.' })
@ApiParam({
name: 'filterDTO',
required: true,
type: GetBillPaymentsFilterDto,
description: 'The bill payments filter dto',
})
public getBillPayments(@Query() filterDTO: GetBillPaymentsFilterDto) {
return this.billPaymentsApplication.getBillPayments(filterDTO);
}