feat(api): batch add-to-album endpoint (Spec 064) #1278
Loading…
Reference in a new issue
No description provided.
Delete branch "spec/064-api"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Spec 064 (Add Photos to Existing Album, Web + Android) — Backend-Lane.
POST /api/albums/{albumId}/items/batch{ "mediaItemId": [uuid,...] }(minItems: 1), Response{ added, skipped }@Transactional(1 Transaktion pro Batch, Rollback bei Fehler), Owner-/Active-Check 1× pro BatchON CONFLICT DO NOTHING(kein Umsortieren vorhandener Items bei Wiederholung)recordAcceptedGeneratedAlbumEdit(..., "add_item")nur für neu eingefügte Itemsspecs/001-v1-baseline/contracts/core-api.openapi.yamlergänztAlbumServiceAddItemsBatchTest(Testcontainers),AlbumControllerAddItemsBatchTest(MockMvc)Verification
rtk ./gradlew :apps:api:test --tests '*AddItemsBatch*' --tests '*AlbumServiceTest'*→ BUILD SUCCESSFUL. Voller Modul-Lauf: 2179 tests, 1 unrelated People-Flake (Re-Run grün,$\{ISSUE-169\}).Refs: spec 064, S064T001
POST /api/albums/{albumId}/items/batch (spec 064 S2) takes {"mediaItemId": ["<uuid>", ...]} and answers {"added": n, "skipped": n} in one transaction: album ownership/active check once per batch, then the same album_items uniqueness (album_event_id, media_item_id) per id via ON CONFLICT DO NOTHING — already-present ids keep their sort_order and count as skipped, so repeating a batch changes nothing. Empty/missing list is 400 (@NotEmpty + service guard), foreign album 403, unknown/deleted album or unknown/inactive/foreign media item 404 with a full rollback; recordAcceptedGeneratedAlbumEdit("add_item") runs per newly added item. The single-item endpoint stays unchanged; contract extended in specs/001-v1-baseline/contracts/core-api.openapi.yaml.