Backend: Zapisnik o preuzimanju – view
GitHub Issue: #195
Last modified with commit e90a924 on
by Aljaž.
Backend task for loading a record (GET /drivepark/records/{recordId}) for the pickup form and the pickup view – check the API spec and DB structure, return the vehicle data, equipment, photos and signatures, implement, and verify against the spec.
Docs: Zapisnik o preuzimanju – view
Spec: GET /drivepark/records/{recordId} (getDriveParkRecord), DriveParkRecordDetail, DriveParkRecordPhoto, DriveParkRecordNotFound in api-docs/openapi.yaml
DB: DriveParkRecords, DriveParkRecordEquipment, DriveParkRecordPhotos in api/database/pending_schema.sql (-- DRIVE PARK --)
The same endpoint also loads a Draft into the pickup form and a record into the return form and return view (Backend: Zapisnik o vraćanju – view).
1. Double check API spec and DB structure
- Every section of the view is in
DriveParkRecordDetail: Podaci o vozilu (vehicle*fields from Vehicles), Oprema vozila (equipment; the 2 fixed items come from the frontend), Podaci o korisniku, Rok korištenja, Stanje vozila pri preuzimanju, Fotografije (photoswithstage: pickup), Potpisi (pickupUserSignature,pickupCompanySignature). - The vehicle data is not stored in the record: it is read from Vehicles, so later inventory changes show in the view (the signed PDF keeps the old values). Deleted and archived vehicles must still be returned.
- Created by / when: the docs comment recommends showing “Kreirano: date, user” under the
title.
pickupCompletedAt/pickupCompletedByare in the response; confirm with the project manager whether the view shows them. - Signatures as data URLs: each is a small PNG. Check the response size is acceptable; otherwise add a signature download endpoint.
- Roles and permissions:
drivepark.access.
2. Implementation
- Roles and permissions: require
drivepark.access→ 403. - Load the record joined with Vehicles (no
DeletedAt/ archived filter), its equipment (byOrderIndex) and photos (byCreatedAt) — three queries at most, no query per photo. Unknown id → 404. - Read the signature blobs and return them as
data:image/png;base64,…; null while the stage isn’t completed. - Computed fields:
status;drivenDays/drivenHours(see the return view task).
3. Verify implementation against spec
- Route and response shape match
getDriveParkRecord. - 401 / 403 / 404 / 500 can be produced; no undocumented ones.
- Draft → signatures null,
pickupCompletedAtnull. Preuzeto → both pickup signatures set, return fields null. - Equipment comes back in the order it was entered.
Done when
A completed pickup record can be opened read-only with all its data, photos and both signatures.