Documentation
¶
Index ¶
- Constants
- Variables
- type Handler
- func (h *Handler) CancelReservation(c echo.Context) error
- func (h *Handler) ConfirmBorrow(c echo.Context) error
- func (h *Handler) GetUserLoans(c echo.Context) error
- func (h *Handler) RegisterRoutes(e *echo.Echo)
- func (h *Handler) ReserveBook(c echo.Context) error
- func (h *Handler) ReturnBook(c echo.Context) error
- type Loan
- type Repository
- func (r *Repository) CreateLoan(ctx context.Context, loan *Loan) error
- func (r *Repository) GetActiveLoansByBook(ctx context.Context, bookID uint) ([]Loan, error)
- func (r *Repository) GetLoanByID(ctx context.Context, id uint) (*Loan, error)
- func (r *Repository) GetLoansByUser(ctx context.Context, userID uint) ([]Loan, error)
- func (r *Repository) UpdateLoan(ctx context.Context, loan *Loan) error
- type Service
Constants ¶
View Source
const ( StatusReserved = "reserved" StatusBorrowed = "borrowed" StatusReturned = "returned" StatusCancelled = "cancelled" )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func (*Handler) CancelReservation ¶
CancelReservation
type Loan ¶
type Loan struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"not null;index" json:"user_id"`
BookID uint `gorm:"not null;index" json:"book_id"`
Status string `gorm:"type:enum('reserved','borrowed','returned','cancelled');not null;default:'reserved'" json:"status"`
IsActive bool `gorm:"not null;default:true" json:"is_active"`
ReservedAt time.Time `gorm:"not null;autoCreateTime" json:"reserved_at"`
BorrowedAt *time.Time `json:"borrowed_at,omitempty"`
DueDate *time.Time `json:"due_date,omitempty"`
ReturnedAt *time.Time `json:"returned_at,omitempty"`
CancelledAt *time.Time `json:"cancelled_at,omitempty"`
Notes string `gorm:"type:varchar(255)" json:"notes,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func NewRepository ¶
func NewRepository(db *gorm.DB) *Repository
func (*Repository) CreateLoan ¶
func (r *Repository) CreateLoan(ctx context.Context, loan *Loan) error
func (*Repository) GetActiveLoansByBook ¶
func (*Repository) GetLoanByID ¶
func (*Repository) GetLoansByUser ¶
func (*Repository) UpdateLoan ¶
func (r *Repository) UpdateLoan(ctx context.Context, loan *Loan) error
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(db *gorm.DB, loanRepo *Repository, bookRepo *books.Repository) *Service
func (*Service) CancelReservation ¶
CancelReservation
func (*Service) ConfirmBorrow ¶
ConfirmBorrow
func (*Service) ReserveBook ¶
ReserveBook
Click to show internal directories.
Click to hide internal directories.