From 43490a106f2cb09cf7d26d8ecfca66383d6d5a71 Mon Sep 17 00:00:00 2001 From: gaowdong Date: Thu, 10 Jul 2025 09:37:52 +0800 Subject: [PATCH] =?UTF-8?q?6739=20=E9=A4=90=E5=8E=A8=E5=BA=9F=E5=BC=83?= =?UTF-8?q?=E7=89=A9=E6=96=B0=E5=A2=9E=E6=97=B6=E8=B4=B9=E7=94=A8=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E8=BF=87=E5=A4=A7=E6=97=B6=E7=B3=BB=E7=BB=9F=E6=8A=A5?= =?UTF-8?q?=E9=94=99=EF=BC=8C=E5=BB=BA=E8=AE=AE=E6=B7=BB=E5=8A=A0=E9=99=90?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KitchenWasteDealController.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/kitchen/controller/KitchenWasteDealController.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/kitchen/controller/KitchenWasteDealController.java index d4dd922..26bdf71 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/kitchen/controller/KitchenWasteDealController.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/kitchen/controller/KitchenWasteDealController.java @@ -1,6 +1,8 @@ package com.bonus.canteen.core.kitchen.controller; +import java.math.BigDecimal; import java.util.List; +import java.util.Objects; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; @@ -89,6 +91,22 @@ public class KitchenWasteDealController extends BaseController { @PostMapping public AjaxResult add(@RequestBody KitchenWasteDeal kitchenWasteDeal) { try { + if(Objects.nonNull(kitchenWasteDeal.getWeight())) { + if(kitchenWasteDeal.getWeight().compareTo(new BigDecimal("9999.99")) > 0) { + return error("重量超过最大值"); + } + if(kitchenWasteDeal.getWeight().compareTo(BigDecimal.ZERO) < 0) { + return error("重量不能小于0"); + } + } + if(Objects.nonNull(kitchenWasteDeal.getSaleAmount())) { + if(kitchenWasteDeal.getSaleAmount().compareTo(new BigDecimal("999999.99")) > 0) { + return error("售卖金额超过最大值"); + } + if(kitchenWasteDeal.getSaleAmount().compareTo(BigDecimal.ZERO) < 0) { + return error("售卖金额不能小于0"); + } + } return toAjax(kitchenWasteDealService.insertKitchenWasteDeal(kitchenWasteDeal)); } catch (Exception e) { log.error("新增厨房废弃物处置失败", e); @@ -106,6 +124,22 @@ public class KitchenWasteDealController extends BaseController { @PostMapping("/edit") public AjaxResult edit(@RequestBody KitchenWasteDeal kitchenWasteDeal) { try { + if(Objects.nonNull(kitchenWasteDeal.getWeight())) { + if(kitchenWasteDeal.getWeight().compareTo(new BigDecimal("9999.99")) > 0) { + return error("重量超过最大值"); + } + if(kitchenWasteDeal.getWeight().compareTo(BigDecimal.ZERO) < 0) { + return error("重量不能小于0"); + } + } + if(Objects.nonNull(kitchenWasteDeal.getSaleAmount())) { + if(kitchenWasteDeal.getSaleAmount().compareTo(new BigDecimal("999999.99")) > 0) { + return error("售卖金额超过最大值"); + } + if(kitchenWasteDeal.getSaleAmount().compareTo(BigDecimal.ZERO) < 0) { + return error("售卖金额不能小于0"); + } + } return toAjax(kitchenWasteDealService.updateKitchenWasteDeal(kitchenWasteDeal)); } catch (Exception e) { log.error("修改厨房废弃物处置失败", e);