6739 餐厨废弃物新增时费用输入过大时系统报错,建议添加限制
This commit is contained in:
parent
0ea545d226
commit
43490a106f
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue