StudentLoanManagement
com.student_loan.service.ItemService Class Reference

Public Member Functions

List< Item > getAllItems ()
 
List< Item > getAvailableItems ()
 
Optional< Item > getItemById (Long id)
 
List< Item > getItemsById (List< Long > itemsId)
 
List< Item > getItemsByUser (Long id)
 
List< Item > getItemsByAvailability (ItemStatus status)
 
Item saveItem (Item item)
 
List< LoanAndItemDto > getItemsLentByUserWithActiveLoans (Long userId)
 
List< LoanAndItemDto > getItemsBorrowedByUserWithActiveLoans (Long userId)
 
Item createItem (Item item)
 
void deleteItem (Long id)
 

Detailed Description

Service class for managing items in the system. Handles operations such as retrieving, creating, saving, and deleting items.

Definition at line 24 of file ItemService.java.

Member Function Documentation

◆ createItem()

Item com.student_loan.service.ItemService.createItem ( Item  item)

Creates a new item in the repository.

Parameters
itemThe item to create.
Returns
The created item.
Exceptions
RuntimeExceptionif the item already exists or the owner does not exist.

Definition at line 160 of file ItemService.java.

◆ deleteItem()

void com.student_loan.service.ItemService.deleteItem ( Long  id)

Deletes an item by its ID.

Parameters
idThe ID of the item to delete.

Definition at line 177 of file ItemService.java.

◆ getAllItems()

List< Item > com.student_loan.service.ItemService.getAllItems ( )

Retrieves all items from the repository.

Returns
List of all items.

Definition at line 37 of file ItemService.java.

◆ getAvailableItems()

List< Item > com.student_loan.service.ItemService.getAvailableItems ( )

Retrieves only items with AVAILABLE status.

Returns
List of available items.

Definition at line 46 of file ItemService.java.

◆ getItemById()

Optional< Item > com.student_loan.service.ItemService.getItemById ( Long  id)

Finds an item by its ID.

Parameters
idThe item ID.
Returns
Optional containing the item if found, or empty if not.

Definition at line 56 of file ItemService.java.

◆ getItemsBorrowedByUserWithActiveLoans()

List< LoanAndItemDto > com.student_loan.service.ItemService.getItemsBorrowedByUserWithActiveLoans ( Long  userId)

Definition at line 130 of file ItemService.java.

◆ getItemsByAvailability()

List< Item > com.student_loan.service.ItemService.getItemsByAvailability ( ItemStatus  status)

Saves an item to the repository.

Parameters
itemThe item to save.
Returns
The saved item.
Exceptions
RuntimeExceptionif the item's owner does not exist.

Definition at line 98 of file ItemService.java.

◆ getItemsById()

List< Item > com.student_loan.service.ItemService.getItemsById ( List< Long >  itemsId)

Finds a list of items by their IDs.

Parameters
itemsIdList of item IDs.
Returns
List of found items.

Definition at line 66 of file ItemService.java.

◆ getItemsByUser()

List< Item > com.student_loan.service.ItemService.getItemsByUser ( Long  id)

Retrieves all items owned by a specific user.

Parameters
idUser ID.
Returns
List of items owned by the user.
Exceptions
RuntimeExceptionif the user is not found.

Definition at line 83 of file ItemService.java.

◆ getItemsLentByUserWithActiveLoans()

List< LoanAndItemDto > com.student_loan.service.ItemService.getItemsLentByUserWithActiveLoans ( Long  userId)

Definition at line 109 of file ItemService.java.

◆ saveItem()

Item com.student_loan.service.ItemService.saveItem ( Item  item)

Definition at line 101 of file ItemService.java.


The documentation for this class was generated from the following file: