Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | import { Controller, Get, Post, Body, Param, Req } from '@nestjs/common'; import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger'; import { ProcurementService } from '../../../domains/procurement/services/procurement.service'; @ApiTags('MobileProcurement') @ApiBearerAuth() @Controller('api/v1/mobile/procurement') export class MobileProcurementController { constructor(private readonly procurementService: ProcurementService) {} private getContext(req: any) { const tenantId = req.user?.tenantId || req.headers['x-tenant-id'] || 'SYSTEM'; const userId = req.user?.id || req.headers['x-user-id'] || 'system'; const employeeId = req.user?.employeeId || req.headers['x-employee-id'] || 'SYSTEM'; return { tenantId, userId, employeeId }; } @Get('requisitions') @ApiOperation({ summary: 'Get employee requisitions' }) async getMyRequisitions(@Req() req: any) { const ctx = this.getContext(req); return this.procurementService.requisitionService.getRequisitions(ctx.tenantId, ctx.employeeId); } @Post('requisitions') @ApiOperation({ summary: 'Submit purchase requisition from mobile' }) async createRequisition(@Body() body: any, @Req() req: any) { const ctx = this.getContext(req); return this.procurementService.requisitionService.createRequisition(ctx.tenantId, ctx.employeeId, body, ctx.userId); } @Get('vendors') @ApiOperation({ summary: 'Get suppliers list for mobile options' }) async getVendors(@Req() req: any) { const ctx = this.getContext(req); return this.procurementService.vendorService.getVendors(ctx.tenantId); } @Get('purchase-orders') @ApiOperation({ summary: 'Get purchase orders list for approvals review' }) async getPurchaseOrders(@Req() req: any) { const ctx = this.getContext(req); return this.procurementService.poService.getPurchaseOrders(ctx.tenantId); } @Post('purchase-orders/:id/approve') @ApiOperation({ summary: 'Approve purchase order from mobile app' }) async approvePurchaseOrder(@Param('id') id: string, @Req() req: any) { const ctx = this.getContext(req); return this.procurementService.poService.approvePurchaseOrder(ctx.tenantId, id, ctx.userId); } } |