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,92 @@
import { ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger';
import {
Controller,
Post,
Body,
Put,
Param,
Delete,
Get,
Query,
} from '@nestjs/common';
import { BillsApplication } from './Bills.application';
import { IBillsFilter } from './Bills.types';
import { CreateBillDto, EditBillDto } from './dtos/Bill.dto';
@Controller('bills')
@ApiTags('bills')
export class BillsController {
constructor(private billsApplication: BillsApplication) {}
@Post()
@ApiOperation({ summary: 'Create a new bill.' })
createBill(@Body() billDTO: CreateBillDto) {
return this.billsApplication.createBill(billDTO);
}
@Put(':id')
@ApiOperation({ summary: 'Edit the given bill.' })
@ApiParam({
name: 'id',
required: true,
type: Number,
description: 'The bill id',
})
editBill(@Param('id') billId: number, @Body() billDTO: EditBillDto) {
return this.billsApplication.editBill(billId, billDTO);
}
@Delete(':id')
@ApiOperation({ summary: 'Delete the given bill.' })
@ApiParam({
name: 'id',
required: true,
type: Number,
description: 'The bill id',
})
deleteBill(@Param('id') billId: number) {
return this.billsApplication.deleteBill(billId);
}
@Get()
@ApiOperation({ summary: 'Retrieves the bills.' })
@ApiParam({
name: 'id',
required: true,
type: Number,
description: 'The bill id',
})
getBills(@Query() filterDTO: IBillsFilter) {
return this.billsApplication.getBills(filterDTO);
}
@Get(':id')
@ApiOperation({ summary: 'Retrieves the bill details.' })
@ApiParam({
name: 'id',
required: true,
type: Number,
description: 'The bill id',
})
getBill(@Param('id') billId: number) {
return this.billsApplication.getBill(billId);
}
@Post(':id/open')
@ApiOperation({ summary: 'Open the given bill.' })
@ApiParam({
name: 'id',
required: true,
type: Number,
description: 'The bill id',
})
openBill(@Param('id') billId: number) {
return this.billsApplication.openBill(billId);
}
@Get('due')
@ApiOperation({ summary: 'Retrieves the due bills.' })
getDueBills(@Body('vendorId') vendorId?: number) {
return this.billsApplication.getDueBills(vendorId);
}
}