hoangsonww / hoangsonww/Library-Management-Backend
Add CSV bulk-import for authors/books
- Dominant language
- Go
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
## What problem does this solve?
Seeding a real catalog today means one `POST /api/v1/authors` and one `POST /api/v1/books` call per row — fine for the Postman/Bruno demo data, painful for anyone migrating an existing library's spreadsheet or another system's export into this one.
## Proposed solution
- Add `POST /api/v1/books/import` and `POST /api/v1/authors/import` (JWT-gated, `multipart/form-data` CSV upload) that parse rows, validate each with the existing `go-playground/validator` DTOs, and insert them in a single transaction — returning a per-row success/error report (so one bad row doesn't silently drop the rest, and the caller can see exactly which rows failed and why).
- Reuse the existing author-lookup-or-create-by-name logic if a book row references an author name that doesn't exist yet, to keep imports self-contained.
- Add a `books import ` CLI subcommand that streams the file to the endpoint and prints the row report.
## Alternatives considered
A one-off script outside the API — works for a single migration but isn't reusable, isn't testable the way an endpoint is, and doesn't benefit future users who also need to bulk-load data.
## Area
Books, Authors
## Priority
Nice to have — good first issue, since it's mostly plumbing on top of validation/insert logic that already exists per-row.
Contributor guide
Assessment
This issue has not been assessed yet.