Overview
ThePrestamo interface represents a book loan in the virtual library system. It tracks loan requests, approvals, rejections, and returns.
Interface Definition
Properties
Basic Properties
number
required
Unique identifier for the loan. Auto-generated by the backend.
string
required
The date and time when the loan was requested. Typically in ISO 8601 format (e.g.,
"2024-03-15T10:30:00").string
Optional return date for the book. Set when the book is returned or when an approved loan has a due date.
'PENDIENTE' | 'APROBADO' | 'RECHAZADO'
required
The current status of the loan request:
PENDIENTE: Loan request is pending approvalAPROBADO: Loan has been approved by an administratorRECHAZADO: Loan request has been rejected
Relationships
any
required
The user who requested the loan. This is the complete user object returned from the Spring Boot backend.
Estado Enum
Theestado property uses a string literal union type with three possible values:
Estado Values
string
Initial state when a user requests a book loan. Awaiting administrator approval.
string
The loan has been approved by an administrator. The book is now marked as unavailable.
string
The loan request has been rejected by an administrator.
Usage Examples
Requesting a Loan (User)
Viewing All Loans (Admin)
Viewing User’s Own Loans
Approving a Loan (Admin)
Rejecting a Loan (Admin)
Filtering Loans by Status
Checking Book Availability Before Requesting
Template Usage
Component Implementation Example
Related Interfaces
- Libro - Book interface referenced by Prestamo
- Autor - Author interface (referenced through Libro)
- Genero - Genre interface (referenced through Libro)
Related Services
- PrestamoService - Service for loan operations
Business Rules
When a loan is approved (
APROBADO), the associated book’s disponible property is automatically set to false by the backend.The
fechaSolicitud is automatically set by the backend when the loan is created. You don’t need to provide it when requesting a loan.Notes
The
usuario field contains the complete user object from Spring Boot. The exact structure depends on your backend User model.