Your Name 4 years ago
parent
commit
a9f16a73a3

+ 35
- 6
src/main/java/com/shigongli/controller/TaHousePersonController.java View File

@@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.shigongli.common.BaseController;
7 7
 import com.shigongli.common.ResponseBean;
8
+import com.shigongli.common.StringUtils;
9
+import com.shigongli.constants.StatusConstant;
10
+import com.shigongli.vo.HousePersonParams;
8 11
 import io.swagger.annotations.Api;
9 12
 import io.swagger.annotations.ApiOperation;
10 13
 import io.swagger.annotations.ApiParam;
@@ -20,6 +23,9 @@ import com.shigongli.service.ITaHousePersonService;
20 23
 import com.shigongli.entity.TaHousePerson;
21 24
 import org.springframework.web.bind.annotation.RestController;
22 25
 
26
+import java.util.ArrayList;
27
+import java.util.List;
28
+
23 29
 /**
24 30
  * <p>
25 31
     * 住房人 前端控制器
@@ -60,16 +66,39 @@ public class TaHousePersonController extends BaseController {
60 66
     }
61 67
 
62 68
     /**
63
-     * 保存对象
64
-     * @param taHousePerson 实体对象
69
+     * 保存入住人
70
+     * @param housePersonParams 实体对象
65 71
      * @return
66 72
      */
67
-    @RequestMapping(value="/taHousePerson",method= RequestMethod.POST)
73
+    @RequestMapping(value="/ma/taHousePerson",method= RequestMethod.POST)
68 74
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
-    public ResponseBean taHousePersonAdd(@ApiParam("保存内容") @RequestBody TaHousePerson taHousePerson) throws Exception{
75
+    public ResponseBean taHousePersonAdd(@ApiParam("保存内容") @RequestBody HousePersonParams housePersonParams) throws Exception{
76
+
77
+        if (null == housePersonParams) {
78
+            return ResponseBean.error("请设置入住人员信息", ResponseBean.ERROR_MISSING_PARAMS);
79
+        }
80
+
81
+        if (StringUtils.isEmpty(housePersonParams.getHouseId()) || StringUtils.isEmpty(housePersonParams.getOrderId())) {
82
+            return ResponseBean.error("请设置房源或订单信息", ResponseBean.ERROR_MISSING_PARAMS);
83
+        }
84
+
85
+        if (null == housePersonParams.getPersonList() || housePersonParams.getPersonList().size() < 1) {
86
+            return ResponseBean.error("请设置入住人员信息", ResponseBean.ERROR_MISSING_PARAMS);
87
+        }
88
+
89
+        List<TaHousePerson> taHousePersonList = new ArrayList<>();
90
+        for (HousePersonParams.Person person: housePersonParams.getPersonList()) {
91
+            TaHousePerson taHousePerson = new TaHousePerson();
92
+            taHousePerson.setHouseId(housePersonParams.getHouseId());
93
+            taHousePerson.setOrderId(housePersonParams.getOrderId());
94
+            taHousePerson.setPhone(person.getPhone());
95
+            taHousePerson.setName(person.getName());
96
+            taHousePerson.setStatus(StatusConstant.NORMAL);
97
+            taHousePersonList.add(taHousePerson);
98
+        }
70 99
 
71
-        if (iTaHousePersonService.save(taHousePerson)){
72
-            return ResponseBean.success(taHousePerson);
100
+        if (iTaHousePersonService.saveBatch(taHousePersonList)){
101
+            return ResponseBean.success(taHousePersonList);
73 102
         }else {
74 103
             return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
75 104
         }

+ 33
- 0
src/main/java/com/shigongli/vo/HousePersonParams.java View File

@@ -0,0 +1,33 @@
1
+package com.shigongli.vo;
2
+
3
+
4
+import io.swagger.annotations.ApiModel;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.Data;
7
+
8
+import java.util.List;
9
+
10
+@ApiModel(description = "报存入住人员参数")
11
+@Data
12
+public class HousePersonParams {
13
+
14
+    @ApiModelProperty("订单号")
15
+    String orderId;
16
+
17
+    @ApiModelProperty("房源ID")
18
+    String houseId;
19
+
20
+    @ApiModelProperty("入住人列表")
21
+    List<Person> personList;
22
+
23
+    @ApiModel(description = "入住人员")
24
+    @Data
25
+    public static class Person {
26
+
27
+        @ApiModelProperty("姓名")
28
+        String name;
29
+
30
+        @ApiModelProperty("手机号")
31
+        String phone;
32
+    }
33
+}