Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request #113 from hardingadonis/dev
Browse files Browse the repository at this point in the history
Sale Dock - v0.5.0
  • Loading branch information
hardingadonis authored Feb 4, 2024
2 parents a1a665e + 2576adf commit 5fbfbd8
Show file tree
Hide file tree
Showing 53 changed files with 1,455 additions and 105 deletions.
27 changes: 27 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,33 @@
"bug",
"review"
]
},
{
"login": "SaibalCts23",
"name": "SaibalCts23",
"avatar_url": "https://avatars.githubusercontent.com/u/153187590?v=4",
"profile": "https://github.com/SaibalCts23",
"contributions": [
"code"
]
},
{
"login": "AdrishOfHogwarts",
"name": "Adrish Bose",
"avatar_url": "https://avatars.githubusercontent.com/u/152976845?v=4",
"profile": "https://github.com/AdrishOfHogwarts",
"contributions": [
"code"
]
},
{
"login": "AnkitaGhosh2000",
"name": "AnkitaGhosh2000",
"avatar_url": "https://avatars.githubusercontent.com/u/152983487?v=4",
"profile": "https://github.com/AnkitaGhosh2000",
"contributions": [
"code"
]
}
],
"commitType": "docs",
Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ target/
# NetBeans
nbproject/
nb-configuration.xml
server/*.war
server/*.war

## Eclipse
.settings/
.classpath
.project
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,13 @@ docker-compose up -d
<td align="center" valign="top" width="20%"><a href="https://allcontributors.org"><img src="https://avatars.githubusercontent.com/u/46410174?v=4" width="100px;" alt=""/><br /><sub><b>All Contributors</b></sub></a></td>
<td align="center" valign="top" width="20%"><a href="https://imgbot.net"><img src="https://avatars.githubusercontent.com/u/31427850?v=4" width="100px;" alt=""/><br /><sub><b>Imgbot</b></sub></a></td>
<td align="center" valign="top" width="20%"><a href="https://www.codefactor.io"><img src="https://avatars.githubusercontent.com/u/13309880?v=4" width="100px;" alt=""/><br /><sub><b>Automated code reviews</b></sub></a></td>
<td align="center" valign="top" width="20%"><a href="https://github.com/AnkitaGhosh2000"><img src="https://avatars.githubusercontent.com/u/152983487?v=4" width="100px;" alt=""/><br /><sub><b>AnkitaGhosh2000</b></sub></a></td>
</tr>
<tr>
<td align="center" valign="top" width="20%"><a href="https://github.com/SaibalCts23"><img src="https://avatars.githubusercontent.com/u/153187590?v=4" width="100px;" alt=""/><br /><sub><b>SaibalCts23</b></sub></a></td>
<td align="center" valign="top" width="20%"><a href="https://github.com/AdrishOfHogwarts"><img src="https://avatars.githubusercontent.com/u/152976845?v=4" width="100px;" alt=""/><br /><sub><b>Adrish Bose</b></sub></a></td>
</tr>
</tbody>
<tfoot>
<tr>
<td align="center" size="13px" colspan="5">
<img src="https://raw.githubusercontent.com/all-contributors/all-contributors-cli/1b8533af435da9854653492b1327a23a4dbd0a10/assets/logo-small.svg">
<a href="https://all-contributors.js.org/docs/en/bot/usage">Add your contributions</a>
</img>
</td>
</tr>
</tfoot>
</table>

<!-- markdownlint-restore -->
Expand Down
30 changes: 15 additions & 15 deletions database/setup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ USE `saledock`;
--

CREATE TABLE `category` (
`id` bigint(20) NOT NULL,
`id` int(20) NOT NULL,
`created_at` datetime(6) DEFAULT NULL,
`name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
Expand All @@ -53,7 +53,7 @@ INSERT INTO `category` (`id`, `created_at`, `name`) VALUES
--

CREATE TABLE `customer` (
`id` bigint(20) NOT NULL,
`id` int(20) NOT NULL,
`address` varchar(255) NOT NULL,
`code` varchar(255) NOT NULL,
`created_at` datetime(6) DEFAULT NULL,
Expand All @@ -78,7 +78,7 @@ INSERT INTO `customer` (`id`, `address`, `code`, `created_at`, `email`, `name`,
--

CREATE TABLE `employee` (
`id` bigint(20) NOT NULL,
`id` int(20) NOT NULL,
`code` varchar(255) NOT NULL,
`created_at` datetime(6) DEFAULT NULL,
`email` varchar(255) NOT NULL,
Expand Down Expand Up @@ -106,15 +106,15 @@ INSERT INTO `employee` (`id`, `code`, `created_at`, `email`, `name`, `password`,
--

CREATE TABLE `order` (
`id` bigint(20) NOT NULL,
`id` int(20) NOT NULL,
`code` varchar(255) NOT NULL,
`created_at` datetime(6) DEFAULT NULL,
`note` longtext DEFAULT NULL,
`status` enum('PENDING','SHIPPING','DONE','CANCELLED') NOT NULL,
`total` double NOT NULL,
`updated_at` datetime(6) DEFAULT NULL,
`customer_id` bigint(20) NOT NULL,
`employee_id` bigint(20) NOT NULL
`customer_id` int(20) NOT NULL,
`employee_id` int(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
Expand All @@ -133,8 +133,8 @@ INSERT INTO `order` (`id`, `code`, `created_at`, `note`, `status`, `total`, `upd

CREATE TABLE `order_detail` (
`quantity` int(11) NOT NULL,
`order_id` bigint(20) NOT NULL,
`product_id` bigint(20) NOT NULL
`order_id` int(20) NOT NULL,
`product_id` int(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
Expand All @@ -155,15 +155,15 @@ INSERT INTO `order_detail` (`quantity`, `order_id`, `product_id`) VALUES
--

CREATE TABLE `product` (
`id` bigint(20) NOT NULL,
`id` int(20) NOT NULL,
`code` varchar(255) NOT NULL,
`created_at` datetime(6) DEFAULT NULL,
`description` longtext DEFAULT NULL,
`image_url` longtext DEFAULT NULL,
`name` varchar(255) NOT NULL,
`price` double NOT NULL,
`updated_at` datetime(6) DEFAULT NULL,
`category_id` bigint(20) NOT NULL
`category_id` int(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
Expand Down Expand Up @@ -238,31 +238,31 @@ ALTER TABLE `product`
-- AUTO_INCREMENT for table `category`
--
ALTER TABLE `category`
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
MODIFY `id` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `customer`
--
ALTER TABLE `customer`
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
MODIFY `id` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `employee`
--
ALTER TABLE `employee`
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
MODIFY `id` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `order`
--
ALTER TABLE `order`
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
MODIFY `id` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `product`
--
ALTER TABLE `product`
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
MODIFY `id` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;

--
-- Constraints for dumped tables
Expand Down
2 changes: 1 addition & 1 deletion get_version.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

major_version=0
minor_version=4
minor_version=5
path_version=0

echo "$major_version.$minor_version.$path_version"
8 changes: 6 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>io.hardingadonis</groupId>
<artifactId>saledock</artifactId>
<version>0.4.0</version>
<version>0.5.0</version>
<packaging>war</packaging>

<name>Sale Dock - v${project.version}</name>
Expand Down Expand Up @@ -75,7 +75,11 @@
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>

<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
<version>2.0.1</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)

String id = request.getParameter("id");
if (id == null) {
response.sendError(404);
response.sendError(404);
return;
}

Integer id_customer = Integer.valueOf(id);
Optional<Customer> customer = Singleton.customerDAO.getByID(id_customer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
response.setContentType("text/html; charset=UTF-8");

List<Customer> customers = Singleton.customerDAO.getAll();
Integer customerCount = Singleton.customerDAO.count();
request.setAttribute("customerCount", customerCount);
request.setAttribute("customers", customers);
request.setAttribute("page", "customer");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,65 @@
package io.hardingadonis.saledock.controller.management.order;

import java.io.*;
import io.hardingadonis.saledock.model.*;
import io.hardingadonis.saledock.utils.*;
import jakarta.servlet.*;
import jakarta.servlet.annotation.*;
import jakarta.servlet.http.*;
import java.io.*;

@WebServlet(name = "AddOrderServlet", urlPatterns = {"/add-order"})
public class AddOrderServlet extends HttpServlet {

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=UTF-8");

request.setAttribute("page", "order");

RequestDispatcher requestDispatcher = request.getRequestDispatcher("/view/jsp/management/order/add-order.jsp");
requestDispatcher.forward(request, response);
}

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String customerID = request.getParameter("customerID");
String productID = request.getParameter("productID");
String quantity = request.getParameter("quantity");

if (customerID == null || productID == null || quantity == null) {
response.sendError(404, "Please provide Customer ID, Product ID and Quantity");
return;
}

Integer id_customer = Integer.valueOf(customerID);
Integer id_product = Integer.valueOf(productID);

Customer customer = Singleton.customerDAO.getByID(id_customer).orElse(null);
Product product = Singleton.productDAO.getByID(id_product).orElse(null);
HttpSession session = request.getSession();
Employee employee = (Employee) session.getAttribute("employee");

// Check if an employee is logged in
if (employee == null) {
response.sendRedirect(request.getContextPath() + "/login?message=notLoggedIn");
return;
}

if (customer == null || product == null) {
response.sendError(404, "Please provide correct Customer ID and Product ID");
return;
}

Order order = new Order();
order.setCustomer(customer);
order.setEmployee(employee);

order.addProduct(product, Integer.valueOf(quantity));

Singleton.orderDAO.save(order);
response.sendRedirect(request.getContextPath() + "/order");
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package io.hardingadonis.saledock.controller.management.order;

import io.hardingadonis.saledock.model.*;
import io.hardingadonis.saledock.utils.*;
import java.io.*;
import jakarta.servlet.*;
import jakarta.servlet.annotation.*;
import jakarta.servlet.http.*;
import java.util.Optional;

@WebServlet(name = "OrderDetailServlet", urlPatterns = {"/order-detail"})
public class OrderDetailServlet extends HttpServlet {

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=UTF-8");

request.setAttribute("page", "order");

String id = request.getParameter("id");
if (id == null) {
response.sendError(404);
return;
}

Integer id_order = Integer.parseInt(id);
Optional<Order> order = Singleton.orderDAO.getByID(id_order);

if (order.isPresent()) {
var ord = order.get();
request.setAttribute("ord", ord);

request.getRequestDispatcher("/view/jsp/management/order/order-detail.jsp").forward(request, response);
} else {
response.sendRedirect(request.getContextPath() + "/order");
}

}

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
package io.hardingadonis.saledock.controller.management.order;

import java.io.*;
import io.hardingadonis.saledock.model.*;
import io.hardingadonis.saledock.utils.*;
import jakarta.servlet.*;
import jakarta.servlet.annotation.*;
import jakarta.servlet.http.*;
import java.io.*;
import java.util.*;

@WebServlet(name = "OrderServlet", urlPatterns = {"/order"})
public class OrderServlet extends HttpServlet {

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=UTF-8");

List<Order> orders = Singleton.orderDAO.getAll();
request.setAttribute("orders", orders);
request.setAttribute("page", "order");

request.getRequestDispatcher("/view/jsp/management/order/order.jsp").forward(request, response);
}

@Override
Expand Down
Loading

0 comments on commit 5fbfbd8

Please sign in to comment.