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 { JwtAuthGuard } from "src/guard/auth.guard"; |
||||
import { RoleGuard } from "src/guard/role.guard"; |
||||
|
||||
@Controller("invoice") |
||||
export class InvoiceController { |
||||
constructor(private readonly invoiceService: InvoiceService) {} |
||||
@Get(":userId") |
||||
async getInvoices(@Param("userId") userId: number): Promise<any> { |
||||
@UseGuards(JwtAuthGuard) |
||||
@Get() |
||||
async getInvoiceByUser(@Request() req) { |
||||
const userId = req.user.id; |
||||
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