parent
0359e22e40
commit
7d8998b2f1
3 changed files with 95 additions and 13 deletions
@ -1,11 +1,26 @@ |
|||||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from "@nestjs/common"; |
import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards, Request } from "@nestjs/common"; |
||||||
import { InvoiceService } from "./invoice.service"; |
import { InvoiceService } from "./invoice.service"; |
||||||
|
import { JwtAuthGuard } from "src/guard/auth.guard"; |
||||||
|
import { RoleGuard } from "src/guard/role.guard"; |
||||||
|
|
||||||
@Controller("invoice") |
@Controller("invoice") |
||||||
export class InvoiceController { |
export class InvoiceController { |
||||||
constructor(private readonly invoiceService: InvoiceService) {} |
constructor(private readonly invoiceService: InvoiceService) {} |
||||||
@Get(":userId") |
@UseGuards(JwtAuthGuard) |
||||||
async getInvoices(@Param("userId") userId: number): Promise<any> { |
@Get() |
||||||
|
async getInvoiceByUser(@Request() req) { |
||||||
|
const userId = req.user.id; |
||||||
return this.invoiceService.getInvoiceByUser(userId); |
return this.invoiceService.getInvoiceByUser(userId); |
||||||
} |
} |
||||||
|
@UseGuards(RoleGuard) |
||||||
|
@Get('list') |
||||||
|
async getInvoices() { |
||||||
|
return this.invoiceService.getInvoices(); |
||||||
|
} |
||||||
|
@UseGuards(RoleGuard) |
||||||
|
@Get(':id') |
||||||
|
async getUserInvoice(@Param('id') id:number) { |
||||||
|
return this.invoiceService.getUserInvoices(id); |
||||||
|
} |
||||||
|
|
||||||
} |
} |
||||||
|
Loading…
Reference in new issue