diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StorageLocationController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StorageLocationController.java index c05b2ef..63e6933 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StorageLocationController.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StorageLocationController.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.hxhq.business.domain.StorageLocationJcgj; import com.hxhq.business.domain.YqJcgj; import com.hxhq.business.form.yq.StorageLocationForm; @@ -82,6 +83,12 @@ public class StorageLocationController extends BaseController public AjaxResult save(@RequestBody StorageLocationForm form) { form.setQmrId(SecurityUtils.getUserId()); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(StorageLocation::getName, form.getName()); + long count = storageLocationService.count(queryWrapper); + if(count > 0) { + return error("【" + form.getName() + "】已存在"); + } storageLocationService.addStorageLocation(form); return success(); } @@ -94,6 +101,12 @@ public class StorageLocationController extends BaseController public AjaxResult edit(@RequestBody StorageLocationForm form) { form.setQmrId(SecurityUtils.getUserId()); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(StorageLocation::getName, form.getName()); + StorageLocation storageLocation = storageLocationService.getOne(queryWrapper); + if(storageLocation != null && !storageLocation.getId().equals(form.getId())) { + return error("【" + form.getName() + "】已存在"); + } storageLocationService.updateStorageLocation(form); return success(); }