feat(documents): full regional doc set (front/back + criminal record) + CS data-entry + DB pool bump
- doc types with side (front/back/single): license, national_id, vehicle_registration (both sides), criminal_record, selfie, vehicle_photo - fields: side, holder_name(encrypted), issue_date, extra jsonb; REQUIRED_DOCS checklist + /requirements - CS/admin: POST /admin/drivers/:id/documents (upload for driver), list, review auto-approves when complete - face-match endpoint stub (Gemini/Face provider later) - DB pool extra.max=30 (raises concurrency ceiling); migration DocumentsFields Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -19,39 +19,73 @@ import { CurrentUser, AuthUser } from '../auth/decorators/current-user.decorator
|
||||
|
||||
@ApiTags('documents')
|
||||
@ApiBearerAuth()
|
||||
@Controller('drivers/documents')
|
||||
@Controller()
|
||||
export class DocumentsController {
|
||||
constructor(private readonly documents: DocumentsService) {}
|
||||
|
||||
// السائق يرفع وثيقة (multipart: file + type + number + expiry_date)
|
||||
// ===== السائق نفسه =====
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post()
|
||||
@Post('drivers/documents')
|
||||
@UseInterceptors(FileInterceptor('file'))
|
||||
upload(
|
||||
@CurrentUser() user: AuthUser,
|
||||
@UploadedFile() file: any,
|
||||
@Body() body: any,
|
||||
) {
|
||||
return this.documents.upload(user.tenantId, user.userId, file, body);
|
||||
upload(@CurrentUser() user: AuthUser, @UploadedFile() file: any, @Body() body: any) {
|
||||
return this.documents.uploadSelf(user.tenantId, user.userId, file, body);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get('mine')
|
||||
@Get('drivers/documents/mine')
|
||||
mine(@CurrentUser() user: AuthUser) {
|
||||
return this.documents.listMine(user.tenantId, user.userId);
|
||||
}
|
||||
|
||||
// مراجعة: خدمة العملاء/الأدمن
|
||||
// قائمة الوثائق المطلوبة وحالتها للسائق الحالي
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get('drivers/documents/requirements')
|
||||
async myRequirements(@CurrentUser() user: AuthUser) {
|
||||
const list = await this.documents.listMine(user.tenantId, user.userId);
|
||||
const driverId = list[0]?.driver_id;
|
||||
return driverId
|
||||
? this.documents.requirements(user.tenantId, driverId)
|
||||
: this.documents.requirements(user.tenantId, '00000000-0000-0000-0000-000000000000');
|
||||
}
|
||||
|
||||
// ===== خدمة العملاء / الأدمن =====
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('admin', 'dispatcher')
|
||||
@Get('pending')
|
||||
@Post('admin/drivers/:driverId/documents')
|
||||
@UseInterceptors(FileInterceptor('file'))
|
||||
uploadForDriver(
|
||||
@Param('driverId') driverId: string,
|
||||
@CurrentUser() user: AuthUser,
|
||||
@UploadedFile() file: any,
|
||||
@Body() body: any,
|
||||
) {
|
||||
return this.documents.uploadForDriver(user.tenantId, driverId, file, body);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('admin', 'dispatcher')
|
||||
@Get('admin/drivers/:driverId/documents')
|
||||
driverDocs(@Param('driverId') driverId: string, @CurrentUser() user: AuthUser) {
|
||||
return this.documents.listByDriver(user.tenantId, driverId);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('admin', 'dispatcher')
|
||||
@Get('admin/drivers/:driverId/documents/requirements')
|
||||
driverRequirements(@Param('driverId') driverId: string, @CurrentUser() user: AuthUser) {
|
||||
return this.documents.requirements(user.tenantId, driverId);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('admin', 'dispatcher')
|
||||
@Get('admin/documents/pending')
|
||||
pending(@CurrentUser() user: AuthUser) {
|
||||
return this.documents.pending(user.tenantId);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('admin', 'dispatcher')
|
||||
@Patch(':id/review')
|
||||
@Patch('admin/documents/:id/review')
|
||||
review(
|
||||
@CurrentUser() user: AuthUser,
|
||||
@Param('id') id: string,
|
||||
@@ -60,4 +94,11 @@ export class DocumentsController {
|
||||
) {
|
||||
return this.documents.review(user.tenantId, id, user.userId, status, note);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('admin', 'dispatcher')
|
||||
@Post('admin/drivers/:driverId/face-match')
|
||||
faceMatch(@Param('driverId') driverId: string, @CurrentUser() user: AuthUser) {
|
||||
return this.documents.faceMatch(user.tenantId, driverId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user