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 54 55 56 57 58 59 60 61 62 63 | import { Controller, Post, Body, Req, UseGuards, Ip } from '@nestjs/common'; import { CaptureService } from '../../../domains/hr/attendance/capture/capture.service'; import { JwtAuthGuard } from '../../../platform/auth/jwt-auth.guard'; import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger'; @Controller('api/v1/mobile/attendance') @ApiTags('MobileAttendance') @UseGuards(JwtAuthGuard) export class MobileAttendanceController { constructor(private readonly captureService: CaptureService) {} @Post('punch') @ApiOperation({ summary: 'Log employee punch in/out via mobile with GPS coordinates', }) @ApiResponse({ status: 201, description: 'Punch logged successfully' }) async mobilePunch( @Req() req: any, @Ip() ipAddress: string, @Body() body: { type: string; latitude?: number; longitude?: number; accuracy?: number; photoUrl?: string; idempotencyKey?: string; }, ) { const tenantId = req.user?.tenantId || req.headers['x-tenant-id'] || 'SYSTEM'; const userId = req.user?.id || 'SYSTEM'; const employeeId = req.user?.employeeId || req.user?.id || 'SYSTEM'; const punchDto = { punchType: body.type, timestamp: new Date(), deviceType: 'MOBILE', latitude: body.latitude, longitude: body.longitude, accuracy: body.accuracy, ipAddress, idempotencyKey: body.idempotencyKey, }; const record = await this.captureService.recordPunch( tenantId, employeeId, punchDto as any, userId, ipAddress, ); // Return compact DTO return { id: record._id, punchType: record.punchType, timestamp: record.timestamp, geofenceStatus: record.geofenceStatus || 'inside', }; } } |