Commit 40e0d42258e97f734838de5c56df17fe30636ddf
1 parent
8eba684d
库存修改
Showing
1 changed file
with
4 additions
and
1 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/materialinventory/MaterialInventoryServiceImpl.java
| ... | ... | @@ -3,6 +3,7 @@ package com.zteits.urbanops.module.garden.service.materialinventory; |
| 3 | 3 | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| 4 | 4 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| 5 | 5 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 6 | +import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |
| 6 | 7 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| 7 | 8 | import com.zteits.urbanops.framework.common.pojo.PageResult; |
| 8 | 9 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; |
| ... | ... | @@ -131,10 +132,12 @@ public class MaterialInventoryServiceImpl implements MaterialInventoryService { |
| 131 | 132 | @Override |
| 132 | 133 | public int updateInVentoryByMaterialId(MaterialInventoryDO materialInventory, Long outNum) { |
| 133 | 134 | // 1. 入参空值校验(避免无效更新或SQL异常) |
| 135 | + if (materialInventory == null || materialInventory.getInventoryId() == null) { | |
| 136 | + throw exception0(BAD_REQUEST.getCode(),"更新库存失败:InventoryId为空!"); | |
| 137 | + } | |
| 134 | 138 | if (outNum == null) { |
| 135 | 139 | throw exception0(BAD_REQUEST.getCode(),"更新库存失败:outNum为空!"); |
| 136 | 140 | } |
| 137 | - materialInventory.setInventoryId(materialInventory.getInventoryId()); | |
| 138 | 141 | materialInventory.setOutTotalNum(materialInventory.getInventoryTotalNum() + outNum); |
| 139 | 142 | materialInventory.setCurrentNum(materialInventory.getCurrentNum() - outNum); |
| 140 | 143 | return materialInventoryMapper.updateById(materialInventory); | ... | ... |