Package com.jdbc.database
Class DB2024TEAM07_ReviewDAO
java.lang.Object
com.jdbc.database.DB2024TEAM07_ReviewDAO
This class provides data access object (DAO) methods for interacting with the DB2024_Review and related tables in a database.
It manages various functionalities related to user reviews, restaurant reviews, and review management.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructor that establishes a connection to the database using the DB2024TEAM07_Database class. -
Method Summary
Modifier and TypeMethodDescriptionintadd(DB2024TEAM07_Review review, int menuId, int resId) Adds a new review to the database.intdelete(int review_id) Deletes a review from the database.intgetCount()Retrieves the total number of reviews in the database.intgetResCount(int res_id) Retrieves the total number of reviews for a specific restaurant.getResReview(int page, int res_id) Retrieves a paginated list of reviews for a specific restaurant, ordered by review ID in descending order.getReview(int page) Retrieves a paginated list of reviews from the database, ordered by review ID in descending order.intgetUserCount(String user_id) Retrieves the total number of reviews for a specific user.getUserReview(int page, String user_id) Retrieves a paginated list of reviews for a specific user, ordered by review ID in descending order.intupdate(DB2024TEAM07_Review review) Updates an existing review in the database.
-
Field Details
-
conn
-
pStmt
-
rs
-
-
Constructor Details
-
DB2024TEAM07_ReviewDAO
public DB2024TEAM07_ReviewDAO()Constructor that establishes a connection to the database using the DB2024TEAM07_Database class.
-
-
Method Details
-
add
Adds a new review to the database.- Parameters:
review- the review object containing user ID, rating, and review contentmenuId- the ID of the menu associated with the reviewresId- the ID of the restaurant associated with the review- Returns:
- 1 on successful insertion, -1 if the review ID cannot be generated, or -2 on an error
-
update
Updates an existing review in the database.- Parameters:
review- the review object containing updated rating and review content- Returns:
- the number of rows affected (1 for a successful update) or -2 on an error
-
getCount
public int getCount()Retrieves the total number of reviews in the database.- Returns:
- the total count of reviews as an integer
-
getReview
Retrieves a paginated list of reviews from the database, ordered by review ID in descending order.- Parameters:
page- the page number (starting from 1) to retrieve- Returns:
- a list of `DB2024TEAM07_Review` objects representing the reviews for that page
-
getUserCount
Retrieves the total number of reviews for a specific user.- Parameters:
user_id- the ID of the user- Returns:
- the total count of reviews for that user as an integer
-
getUserReview
Retrieves a paginated list of reviews for a specific user, ordered by review ID in descending order.- Parameters:
page- the page number (starting from 1) to retrieveuser_id- the ID of the user- Returns:
- a list of `DB2024TEAM07_ResReviewVO` objects representing the reviews for that user and page
-
getResCount
public int getResCount(int res_id) Retrieves the total number of reviews for a specific restaurant.- Parameters:
res_id- the ID of the restaurant- Returns:
- the total count of reviews for that restaurant as an integer
-
getResReview
Retrieves a paginated list of reviews for a specific restaurant, ordered by review ID in descending order.- Parameters:
page- the page number (starting from 1) to retrieveres_id- the ID of the restaurant- Returns:
- a list of `DB2024TEAM07_UserReview` objects representing the reviews for that restaurant and page
-
delete
public int delete(int review_id) Deletes a review from the database.- Parameters:
review_id- the ID of the review to delete- Returns:
- the number of rows affected (1 for a successful deletion) or -2 on an error
-