liu 1 year ago
parent
commit
314e05e3f7
1 changed files with 16 additions and 0 deletions
  1. 16 0
      src/main/java/com/template/controller/WelcomeBedController.java

+ 16 - 0
src/main/java/com/template/controller/WelcomeBedController.java

@@ -72,6 +72,14 @@ public class WelcomeBedController implements WelcomeBedControllerAPI {
             String st = paramUtils.getParamError(bindingResult);
             return CommonResult.fail(st);
         }
+        WelcomeDormitory byId = welcomeDormitoryService.getById(iwbr.getDormitoryId());
+        if (ObjectUtils.isEmpty(byId)) {
+            return CommonResult.fail("该宿舍号不存在");
+        }
+        if (!byId.getSex().equals(iwbr.getSex())) {
+            return CommonResult.fail("请勿跨性别添加床位");
+        }
+
 
         WelcomeBed existData = welcomeBedService.queryBedData(iwbr.getSchool(), iwbr.getBuildId(), iwbr.getDormitoryId(), iwbr.getNumber());
         if (existData != null) {
@@ -128,6 +136,14 @@ public class WelcomeBedController implements WelcomeBedControllerAPI {
             return CommonResult.fail("床位信息已失效,编辑失败");
         }
 
+        WelcomeDormitory byId = welcomeDormitoryService.getById(uwbr.getDormitoryId());
+        if (ObjectUtils.isEmpty(byId)) {
+            return CommonResult.fail("该宿舍号不存在");
+        }
+        if (!byId.getSex().equals(uwbr.getSex())) {
+            return CommonResult.fail("请勿跨性别修改床位");
+        }
+
         WelcomeBed existData = welcomeBedService.queryBedData(uwbr.getSchool(), uwbr.getBuildId(), uwbr.getDormitoryId(), uwbr.getNumber());
         if (existData != null && existData.getId().intValue() != uwbr.getId().intValue()) {
             return CommonResult.fail("该床位号已存在,请勿重复插入!");