Package com.masai.Dao
Class BuyerDaoImpl
java.lang.Object
com.masai.Dao.BuyerDaoImpl
- All Implemented Interfaces:
BuyerDao
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddAmountToBuyerBalance(double amount, String unsername) Adds a specified amount to the buyer's balance.booleandeleteBuyer(String username, String password) Deletes a buyer based on their username and password.Retrieve all products available for sale.Retrieve all products by category.getAllReturnProduct(String username) Retrieves all return products for a buyer.getAllReturnProductOfBuyerByType(String username, String type) Retrieves all return products of a buyer by the specified type.doublegetBalance(String username) Retrieve buyer balance by username.getBuyerAllTransactionbyDateRange(LocalDate startDate, LocalDate endDate, String username) Retrieves all transactions of a buyer within a specified date range.getBuyerAllTransactionByGSTPercentage(String username) Retrieves all transactions of a buyer based on the GST percentage of the transactions.getBuyerAllTransactionByPurchaseDate(String username) Retrieves all transactions of a buyer based on the purchase date of the transactions.getBuyerAllTransactionByQuantity(String username) Retrieves all transactions of a buyer based on the quantity of the transactions.getBuyerAllTransactionByTotalPrice(String username) Retrieves all transactions of a buyer based on the total price of the transactions.getBuyerByUsername(String username) Retrieve buyer details by username.getProductsByProductId(int id) Retrieve product by product ID.booleanhideTransactions(String username) Hide buyer transactions .loginBuyer(String username, String password) Login as a buyer.purchaseItem(int productId, int quantity) Purchase an item.booleanpurchaseReturnItem(int productId, int quantity) Purchase return items.recoverBuyerAcount(String username, String password, LocalDate date) Recovers a buyer's account based on their username, password, and recovery date.Register a new buyer.booleanunhideTransactions(String username) Unhide buyer transactions .Update buyer details.View all transactions.
-
Constructor Details
-
BuyerDaoImpl
public BuyerDaoImpl()
-
-
Method Details
-
loginBuyer
Login as a buyer.- Specified by:
loginBuyerin interfaceBuyerDao- Parameters:
username- The buyer's username.password- The buyer's password.- Returns:
- The Buyer object representing the logged-in buyer.
- Throws:
InvalidCredentialsException- If the username or password is invalid.
-
getBalance
Retrieve buyer balance by username.- Specified by:
getBalancein interfaceBuyerDao- Parameters:
username- The username of the buyer.- Returns:
- The balance of the buyer with the specified username.
-
getBuyerByUsername
Retrieve buyer details by username.- Specified by:
getBuyerByUsernamein interfaceBuyerDao- Parameters:
username- The username of the buyer.- Returns:
- The Buyer object representing the buyer with the specified username.
-
registerNewBuyer
Register a new buyer.- Specified by:
registerNewBuyerin interfaceBuyerDao- Parameters:
buyer- The Buyer object containing the buyer's information.- Returns:
- A message indicating the success or failure of the registration process.
-
updateBuyerDetails
Update buyer details.- Specified by:
updateBuyerDetailsin interfaceBuyerDao- Parameters:
buyer- The Buyer object containing the updated buyer's information.- Returns:
- A message indicating the success or failure of the update process.
-
getAllProductForSell
Retrieve all products available for sale.- Specified by:
getAllProductForSellin interfaceBuyerDao- Returns:
- A ResultSet containing information about all products available for sale.
- Throws:
RecordNotFoundException- If no products for sale are found.
-
purchaseReturnItem
public boolean purchaseReturnItem(int productId, int quantity) Purchase return items.- Specified by:
purchaseReturnItemin interfaceBuyerDao- Parameters:
productId- The ID of the product to return.quantity- The quantity to return.- Returns:
- True if the return is successful, False otherwise.
-
purchaseItem
Purchase an item.- Specified by:
purchaseItemin interfaceBuyerDao- Parameters:
productId- The ID of the product to purchase.quantity- The quantity to purchase.- Returns:
- A message indicating the success or failure of the purchase process.
-
unhideTransactions
Unhide buyer transactions .- Specified by:
unhideTransactionsin interfaceBuyerDao- Parameters:
username- The username of the buyer.- Returns:
- True if the transactions are successfully unhidden, False otherwise.
-
hideTransactions
Hide buyer transactions .- Specified by:
hideTransactionsin interfaceBuyerDao- Parameters:
username- The username of the buyer.- Returns:
- True if the transactions are successfully hidden, False otherwise.
-
viewAllTransactions
View all transactions.- Specified by:
viewAllTransactionsin interfaceBuyerDao- Returns:
- A ResultSet containing information about all transactions.
-
getAllProductsByCategory
Retrieve all products by category.- Specified by:
getAllProductsByCategoryin interfaceBuyerDao- Parameters:
category- The category of the products.- Returns:
- A ResultSet containing information about all products in the specified category.
- Throws:
RecordNotFoundException- If no products are found in the specified category.
-
getProductsByProductId
Retrieve product by product ID.- Specified by:
getProductsByProductIdin interfaceBuyerDao- Parameters:
id- The ID of the product.- Returns:
- A ResultSet containing information about the product with the specified ID.
- Throws:
RecordNotFoundException- If no product is found with the specified ID.
-
addAmountToBuyerBalance
Adds a specified amount to the buyer's balance.- Specified by:
addAmountToBuyerBalancein interfaceBuyerDao- Parameters:
amount- The amount to add to the buyer's balance.username- The username of the buyer.- Returns:
trueif the balance was successfully updated,falseotherwise.
-
deleteBuyer
Deletes a buyer based on their username and password.- Specified by:
deleteBuyerin interfaceBuyerDao- Parameters:
username- The username of the buyer.password- The password of the buyer.- Returns:
trueif the buyer was successfully deleted,falseotherwise.
-
recoverBuyerAcount
Recovers a buyer's account based on their username, password, and recovery date.- Specified by:
recoverBuyerAcountin interfaceBuyerDao- Parameters:
username- The username of the buyer.password- The password of the buyer.date- The recovery date of the buyer's account.- Returns:
- The recovered buyer account as a string.
-
getBuyerAllTransactionbyDateRange
public ResultSet getBuyerAllTransactionbyDateRange(LocalDate startDate, LocalDate endDate, String username) throws RecordNotFoundException Retrieves all transactions of a buyer within a specified date range.- Specified by:
getBuyerAllTransactionbyDateRangein interfaceBuyerDao- Parameters:
startDate- The start date of the date range.endDate- The end date of the date range.username- The username of the buyer.- Returns:
- A ResultSet containing the transactions within the date range.
- Throws:
RecordNotFoundException- If no transactions are found within the specified date range.
-
getBuyerAllTransactionByPurchaseDate
public ResultSet getBuyerAllTransactionByPurchaseDate(String username) throws RecordNotFoundException Retrieves all transactions of a buyer based on the purchase date of the transactions.- Specified by:
getBuyerAllTransactionByPurchaseDatein interfaceBuyerDao- Parameters:
username- The username of the buyer.- Returns:
- A ResultSet containing the transactions.
- Throws:
RecordNotFoundException- If no transactions are found for the buyer.
-
getBuyerAllTransactionByQuantity
Retrieves all transactions of a buyer based on the quantity of the transactions.- Specified by:
getBuyerAllTransactionByQuantityin interfaceBuyerDao- Parameters:
username- The username of the buyer.- Returns:
- A ResultSet containing the transactions.
- Throws:
RecordNotFoundException- If no transactions are found for the buyer.
-
getBuyerAllTransactionByGSTPercentage
public ResultSet getBuyerAllTransactionByGSTPercentage(String username) throws RecordNotFoundException Retrieves all transactions of a buyer based on the GST percentage of the transactions.- Specified by:
getBuyerAllTransactionByGSTPercentagein interfaceBuyerDao- Parameters:
username- The username of the buyer.- Returns:
- A ResultSet containing the transactions.
- Throws:
RecordNotFoundException- If no transactions are found for the buyer.
-
getBuyerAllTransactionByTotalPrice
Retrieves all transactions of a buyer based on the total price of the transactions.- Specified by:
getBuyerAllTransactionByTotalPricein interfaceBuyerDao- Parameters:
username- The username of the buyer.- Returns:
- A ResultSet containing the transactions.
- Throws:
RecordNotFoundException- If no transactions are found for the buyer.
-
getAllReturnProduct
Retrieves all return products for a buyer.- Specified by:
getAllReturnProductin interfaceBuyerDao- Parameters:
username- The username of the buyer.- Returns:
- A ResultSet containing the return products.
-
getAllReturnProductOfBuyerByType
Retrieves all return products of a buyer by the specified type.- Specified by:
getAllReturnProductOfBuyerByTypein interfaceBuyerDao- Parameters:
username- The username of the buyer.type- The type of return products to retrieve.- Returns:
- A ResultSet containing the return products.
-