hoangsonww / hoangsonww/Library-Management-Backend

Add CSV export for loan history

Open
#12 0 comments 0 reactions 1 assignee Claimed by @hoangsonww View on GitHub
bug documentation enhancement good first issue help wanted
Dominant language
Go
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## What problem does this solve?

`GET /api/v1/books/{id}/loans` and `/api/v1/borrowers/{id}/loans` return loan history as JSON, but there's no way to get a report out of the system for offline use (audits, handing data to a librarian who wants a spreadsheet, etc.) without a client writing custom conversion code.

## Proposed solution

- Add `?format=csv` support on both existing loan-history endpoints (and optionally a system-wide `GET /api/v1/loans/export`), returning a `Content-Type: text/csv` response with the same fields as the JSON payload.
- Include derived fields already computed for the JSON response (status, days overdue) so the CSV is immediately useful without post-processing.
- Add a `loans export --book-id --format csv > loans.csv` CLI subcommand.

## Alternatives considered

Leaving CSV conversion to the client — reasonable, but every client ends up writing the same trivial JSON-to-CSV code; better to do it once, server-side, especially since the field set is already well-defined.

## Area

Loans (borrow / return)

## Priority

Nice to have — good first issue, small and self-contained on top of existing query logic.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.