Backend: Delete Zapisnik
Last modified with commit 54c7b1e on
by TjasaSimovic.
Backend task for deleting a Draft record (DELETE /drivepark/records/{recordId}) – confirm hard delete, check the Draft-only rule, remove child rows and blobs, implement, and verify against the spec.
Docs: Zapisnici list (Deleting a record)
Spec: DELETE /drivepark/records/{recordId} (deleteDriveParkRecord), DriveParkRecordConflict in api-docs/openapi.yaml
DB: DriveParkRecords, DriveParkRecordEquipment, DriveParkRecordPhotos in api/database/pending_schema.sql (-- DRIVE PARK --)
1. Double check API spec and DB structure
- Hard delete: the spec and schema remove the record, its equipment and photo rows, and the photo blobs. A Draft has no signatures or PDF. Confirm no history is needed.
- Only Draft → 409
record_not_draftfor Preuzeto and Vraćeno (docs: they can’t be deleted). - A saved return draft can’t be discarded (docs comment, recommended: no). Confirm.
- Roles and permissions:
drivepark.access.
2. Implementation
- Roles and permissions: require
drivepark.access→ 403. - In one transaction: delete the photo and equipment rows and the record, with
PickupCompletedAt IS NULLin the record’sDELETE … WHERE; 0 rows → 404 or 409 (load the record to tell which). Delete the photo blobs after the commit. - Success → 204.
3. Verify implementation against spec
- Status codes and
errorvalues matchdeleteDriveParkRecord. - Draft with photos → 204, rows and blobs gone. Preuzeto → 409. Deleting twice → 404.
Done when
A Manager of Vozni park can remove a draft record, and it disappears from the list.