liu 1 год назад
Родитель
Сommit
4cbd39c33a

+ 8 - 6
src/main/java/com/template/api/WelcomeStudentDormitoryControllerAPI.java

@@ -3,17 +3,19 @@ package com.template.api;
 import com.template.model.pojo.WelcomeStudentDormitory;
 import com.template.model.result.CommonResult;
 import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.*;
 
 @RequestMapping("/api/welcome-student-dormitory")
 public interface WelcomeStudentDormitoryControllerAPI {
 
-    @PostMapping(value = "/saveStudent")
+    @PostMapping(value = "/saveStudentDormitory")
     @ApiOperation(value = "添加床位", notes = "添加床位", httpMethod = "POST")
-    CommonResult saveStudent(@RequestBody WelcomeStudentDormitory welcomeStudentDormitory);
+    CommonResult saveStudentDormitory(@RequestBody WelcomeStudentDormitory welcomeStudentDormitory);
+
+
+    @GetMapping(value = "/deleteStudentDormitory")
+    @ApiOperation(value = "删除床位", notes = "删除床位", httpMethod = "GET")
+    CommonResult deleteStudentDormitory(@RequestParam Integer studentDormitoryId);
 
 
     @PostMapping(value = "/submit")

+ 15 - 2
src/main/java/com/template/controller/WelcomeStudentDormitoryController.java

@@ -47,8 +47,21 @@ public class WelcomeStudentDormitoryController implements WelcomeStudentDormitor
     WelcomeDormitoryService welcomeDormitoryService;
 
     @Override
-    public CommonResult saveStudent(WelcomeStudentDormitory welcomeStudentDormitory) {
-        return null;
+    public CommonResult saveStudentDormitory(WelcomeStudentDormitory welcomeStudentDormitory) {
+        LambdaQueryWrapper<WelcomeStudentDormitory> wrapper=new LambdaQueryWrapper<>();
+        wrapper.eq(WelcomeStudentDormitory::getStudentCard,welcomeStudentDormitory.getStudentCard());
+        WelcomeStudentDormitory one = welcomeStudentDormitoryService.getOne(wrapper);
+        if (ObjectUtils.isNotEmpty(one)) {
+            return CommonResult.fail("该学生已有床位");
+        }
+        welcomeStudentDormitoryService.save(welcomeStudentDormitory);
+        return CommonResult.ok();
+    }
+
+    @Override
+    public CommonResult deleteStudentDormitory(Integer studentDormitoryId) {
+        welcomeStudentDormitoryService.removeById(studentDormitoryId);
+        return CommonResult.ok();
     }
 
     @Override

+ 3 - 0
src/main/java/com/template/model/pojo/WelcomeStudentDormitory.java

@@ -37,6 +37,9 @@ public class WelcomeStudentDormitory implements Serializable {
     @ApiModelProperty(value = "学生身份证号")
     private String studentCard;
 
+    @ApiModelProperty(value = "录取号")
+    private String admissNum;
+
     @ApiModelProperty(value = "楼栋")
     private String building;