better dto/entity structure for GET/POST
This commit is contained in:
parent
8f846bd253
commit
389ef8c7ce
9 changed files with 106 additions and 77 deletions
|
|
@ -48,6 +48,7 @@ export class ExpensesController {
|
|||
if (!expense) {
|
||||
throw new BadRequestException('Expense name cannot be empty.');
|
||||
}
|
||||
// TODO: Validate date/cents/category exist...
|
||||
|
||||
try {
|
||||
return await this.expensesService.create(expense);
|
||||
|
|
@ -57,15 +58,15 @@ export class ExpensesController {
|
|||
}
|
||||
}
|
||||
|
||||
@Put()
|
||||
@HttpCode(HttpStatus.OK)
|
||||
public async update(@Body() expense: UpdateExpenseDto): Promise<GetExpenseDto> {
|
||||
if (!expense.id) {
|
||||
throw new BadRequestException('Expense ID cannot be empty.');
|
||||
}
|
||||
|
||||
return await this.expensesService.update(expense);
|
||||
}
|
||||
// @Put()
|
||||
// @HttpCode(HttpStatus.OK)
|
||||
// public async update(@Body() expense: UpdateExpenseDto): Promise<GetExpenseDto> {
|
||||
// if (!expense.id) {
|
||||
// throw new BadRequestException('Expense ID cannot be empty.');
|
||||
// }
|
||||
//
|
||||
// return await this.expensesService.update(expense);
|
||||
// }
|
||||
|
||||
@Delete(':id')
|
||||
@HttpCode(HttpStatus.NO_CONTENT)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue