From 4829ac72b2cee1bc6c1d411538c85dbfe8bd3501 Mon Sep 17 00:00:00 2001 From: Thunder Date: Thu, 7 Mar 2024 13:21:04 +0700 Subject: [PATCH] Fix unchecked positive product quantity --- .../controller/management/order/AddProductIntoOrder.java | 6 ++++++ .../view/jsp/management/order/add-product-into-order.jsp | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/hardingadonis/saledock/controller/management/order/AddProductIntoOrder.java b/src/main/java/io/hardingadonis/saledock/controller/management/order/AddProductIntoOrder.java index 1559fdd..5f44317 100644 --- a/src/main/java/io/hardingadonis/saledock/controller/management/order/AddProductIntoOrder.java +++ b/src/main/java/io/hardingadonis/saledock/controller/management/order/AddProductIntoOrder.java @@ -65,6 +65,12 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) Integer productId = Integer.parseInt(productIdParam); Integer productQuantity = Integer.parseInt(productQuantityParam); + + if(productQuantity <= 0){ + request.setAttribute("message", "productQuantityNotPositive"); + this.doGet(request, response); + return; + } Optional product = Singleton.productDAO.getByID(productId); diff --git a/src/main/webapp/view/jsp/management/order/add-product-into-order.jsp b/src/main/webapp/view/jsp/management/order/add-product-into-order.jsp index 234990f..152ed27 100644 --- a/src/main/webapp/view/jsp/management/order/add-product-into-order.jsp +++ b/src/main/webapp/view/jsp/management/order/add-product-into-order.jsp @@ -56,6 +56,11 @@ Nhập sai định dạng số lượng sản phẩm. Vui lòng kiểm tra lại. + + +