parent
cb3eaeb425
commit
be0f01bc1a
2 changed files with 38 additions and 8 deletions
@ -1,13 +1,17 @@ |
|||||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; |
import { Controller, Get, Post, Body, Patch, Param, Delete } from "@nestjs/common"; |
||||||
import { InvoiceService } from './invoice.service'; |
import { InvoiceService } from "./invoice.service"; |
||||||
import { Invoice } from './entities/invoice.entity'; |
import { Invoice } from "./entities/invoice.entity"; |
||||||
|
|
||||||
@Controller('invoice') |
@Controller("invoice") |
||||||
export class InvoiceController { |
export class InvoiceController { |
||||||
constructor(private readonly invoiceService: InvoiceService) {} |
constructor(private readonly invoiceService: InvoiceService) {} |
||||||
@Post('create') |
@Post("create") |
||||||
async createInvoice(@Body() body:{userId:number, totalAmount:number}):Promise<Invoice>{ |
async createInvoice(@Body() body: { userId: number; totalAmount: number }): Promise<Invoice> { |
||||||
const { userId, totalAmount} = body |
const { userId, totalAmount } = body; |
||||||
return this.invoiceService.createInvoice(userId, totalAmount) |
return this.invoiceService.createInvoice(userId, totalAmount); |
||||||
|
} |
||||||
|
@Get(":userId") |
||||||
|
async getInvoices(@Param("userId") userId: number): Promise<any> { |
||||||
|
return this.invoiceService.getInvoicesByUser(userId); |
||||||
} |
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue