feat(nestjs): migrate to NestJS

This commit is contained in:
Ahmed Bouhuolia
2025-04-07 11:51:24 +02:00
parent f068218a16
commit 55fcc908ef
3779 changed files with 631 additions and 195332 deletions

View File

@@ -0,0 +1,124 @@
import {
Body,
Controller,
Delete,
Get,
HttpCode,
Param,
ParseIntPipe,
Post,
Put,
} from '@nestjs/common';
import { SaleReceiptApplication } from './SaleReceiptApplication.service';
import { ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger';
import {
CreateSaleReceiptDto,
EditSaleReceiptDto,
} from './dtos/SaleReceipt.dto';
@Controller('sale-receipts')
@ApiTags('sale-receipts')
export class SaleReceiptsController {
constructor(private saleReceiptApplication: SaleReceiptApplication) {}
@Post()
@ApiOperation({ summary: 'Create a new sale receipt.' })
createSaleReceipt(@Body() saleReceiptDTO: CreateSaleReceiptDto) {
return this.saleReceiptApplication.createSaleReceipt(saleReceiptDTO);
}
@Put(':id/mail')
@HttpCode(200)
@ApiOperation({ summary: 'Send the sale receipt mail.' })
@ApiParam({
name: 'id',
required: true,
type: Number,
description: 'The sale receipt id',
})
sendSaleReceiptMail(@Param('id', ParseIntPipe) id: number) {
return this.saleReceiptApplication.getSaleReceiptMail(id);
}
@Get(':id/mail')
@HttpCode(200)
@ApiOperation({ summary: 'Retrieves the sale receipt mail.' })
@ApiParam({
name: 'id',
required: true,
type: Number,
description: 'The sale receipt id',
})
getSaleReceiptMail(@Param('id', ParseIntPipe) id: number) {
return this.saleReceiptApplication.getSaleReceiptMail(id);
}
@Put(':id')
@ApiOperation({ summary: 'Edit the given sale receipt.' })
@ApiParam({
name: 'id',
required: true,
type: Number,
description: 'The sale receipt id',
})
editSaleReceipt(
@Param('id', ParseIntPipe) id: number,
@Body() saleReceiptDTO: EditSaleReceiptDto,
) {
return this.saleReceiptApplication.editSaleReceipt(id, saleReceiptDTO);
}
@Get(':id')
@ApiOperation({ summary: 'Retrieves the sale receipt details.' })
@ApiParam({
name: 'id',
required: true,
type: Number,
description: 'The sale receipt id',
})
getSaleReceipt(@Param('id', ParseIntPipe) id: number) {
return this.saleReceiptApplication.getSaleReceipt(id);
}
@Delete(':id')
@ApiOperation({ summary: 'Delete the given sale receipt.' })
@ApiParam({
name: 'id',
required: true,
type: Number,
description: 'The sale receipt id',
})
deleteSaleReceipt(@Param('id', ParseIntPipe) id: number) {
return this.saleReceiptApplication.deleteSaleReceipt(id);
}
@Post(':id/close')
@ApiOperation({ summary: 'Close the given sale receipt.' })
@ApiParam({
name: 'id',
required: true,
type: Number,
description: 'The sale receipt id',
})
closeSaleReceipt(@Param('id', ParseIntPipe) id: number) {
return this.saleReceiptApplication.closeSaleReceipt(id);
}
@Get(':id/pdf')
@ApiOperation({ summary: 'Retrieves the sale receipt PDF.' })
@ApiParam({
name: 'id',
required: true,
type: Number,
description: 'The sale receipt id',
})
getSaleReceiptPdf(@Param('id', ParseIntPipe) id: number) {
return this.saleReceiptApplication.getSaleReceiptPdf(0, id);
}
@Get('state')
@ApiOperation({ summary: 'Retrieves the sale receipt state.' })
getSaleReceiptState() {
return this.saleReceiptApplication.getSaleReceiptState();
}
}