diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..ab1f416
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,10 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Ignored default folder with query files
+/queries/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..bf2c501
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..aa00ffa
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..a9076af
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..f6a588b
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/database.sql b/database.sql
index 2169346..837c335 100644
--- a/database.sql
+++ b/database.sql
@@ -9,7 +9,6 @@
-- 6. The script should be executable from start to finish without errors.
-
-- =======================================================
-- USER TABLE
-- =======================================================
@@ -30,6 +29,12 @@
--
-- CREATE TABLE ...
+CREATE TABLE users(
+ id SERIAL PRIMARY KEY,
+ username TEXT UNIQUE NOT NULL,
+ password VARCHAR(250) NOT NULL,
+ email VARCHAR(100)
+);
-- =======================================================
@@ -52,7 +57,13 @@
--
-- CREATE TABLE ...
-
+CREATE TABLE menu_items(
+ id SERIAL PRIMARY KEY,
+ name VARCHAR(100) NOT NULL,
+ description TEXT,
+ price DECIMAL(10, 2) NOT NULL CHECK ( price > 0 ),
+ category VARCHAR(100)
+);
-- =======================================================
-- ORDER TABLE
@@ -77,7 +88,12 @@
--
-- CREATE TABLE ...
-
+CREATE TABLE orders (
+ id SERIAL PRIMARY KEY,
+ user_id INT NOT NULL REFERENCES users(id),
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ total_price DECIMAL(10, 2) DEFAULT 0.00
+);
-- =======================================================
-- ORDER DETAIL TABLE
@@ -100,7 +116,13 @@
--
-- CREATE TABLE ...
-
+CREATE TABLE order_detail(
+ id SERIAL PRIMARY KEY,
+ order_id INT NOT NULL REFERENCES orders(id),
+ menu_item_id INT NOT NULL REFERENCES menuItem(id),
+ quantity INT NOT NULL CHECK ( quantity > 0 ),
+ unit_price DECIMAL(10, 2) NOT NULL
+);
-- =======================================================
-- INITIAL MENU DATA
@@ -116,6 +138,12 @@
--
-- INSERT INTO ...
+INSERT INTO menuItem(
+ name, description, price, category
+) VALUES('Pizza Margherita', 'Classic pizza with tomato sauce and mozzarella', 10.00, 'Pizza'),
+ ('Beef Burger', 'Juicy beef patty with cheese, lettuce, and tomato', 8.50, 'Burger'),
+ ('Pasta Alfredo', 'Creamy pasta with grilled chicken and parmesan', 12.00, 'Pasta'),
+ ('Coca Cola', 'Cold soft drink', 2.00, 'Drink');
-- =======================================================
@@ -127,7 +155,18 @@
--
-- INSERT INTO ...
+--AI generated
+INSERT INTO users (
+ username, password, email
+) VALUES('ali_dev', '$2a$12$K8M6O2wWfG1...hashed_long_string...', 'ali@email.com'),
+ ('sara_k', '$2a$12$R9P2m1vXyZ7...hashed_long_string...', NULL),
+ ('reza_food', '$2a$12$T5N8b9zQpW3...hashed_long_string...', 'reza@email.com');
+INSERT INTO orders (
+ user_id, total_price
+) VALUES(1, 18.50), -- سفارش اول علی
+ (2, 12.00), -- سفارش سارا
+ (1, 20.00); -- سفارش دوم علی
-- =======================================================
-- VERIFICATION QUERIES
@@ -135,7 +174,7 @@
--
-- Uncomment these queries to verify your database.
--
--- SELECT * FROM ...;
--- SELECT * FROM ...;
--- SELECT * FROM ...;
--- SELECT * FROM ...;
\ No newline at end of file
+SELECT * FROM users;
+SELECT * FROM menuItem;
+SELECT * FROM orders;
+SELECT * FROM order_detail;
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 028ca50..c12c681 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,6 +27,12 @@
${postgresql.version}
+
+ org.mindrot
+ jbcrypt
+ 0.4
+
+
\ No newline at end of file
diff --git a/src/main/java/dev/dao/MenuItemDao.java b/src/main/java/dev/dao/MenuItemDao.java
index 3bbebe9..a11edf1 100644
--- a/src/main/java/dev/dao/MenuItemDao.java
+++ b/src/main/java/dev/dao/MenuItemDao.java
@@ -1,7 +1,13 @@
package dev.dao;
+import dev.database.DatabaseConnection;
import dev.model.MenuItem;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
import java.util.List;
public class MenuItemDao {
@@ -10,14 +16,53 @@ public class MenuItemDao {
// TODO:
// Retrieve all menu items
+ List