From 1d4e7dc07b0ef56d852a02ffc6f02df0d28d4549 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期一, 23 八月 2021 16:58:31 +0800
Subject: [PATCH] 优化代码

---
 service-user/src/main/java/com/java110/user/api/RentingApi.java |   37 +++++++++++++++++++++----------------
 1 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/service-user/src/main/java/com/java110/user/api/RentingApi.java b/service-user/src/main/java/com/java110/user/api/RentingApi.java
old mode 100644
new mode 100755
index 7a806fa..4f09d46
--- a/service-user/src/main/java/com/java110/user/api/RentingApi.java
+++ b/service-user/src/main/java/com/java110/user/api/RentingApi.java
@@ -1,6 +1,8 @@
 package com.java110.user.api;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.aliyuncs.utils.StringUtils;
 import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.dto.rentingConfig.RentingConfigDto;
 import com.java110.dto.rentingPool.RentingPoolDto;
@@ -13,11 +15,7 @@
 import com.java110.user.bmo.rentingConfig.IGetRentingConfigBMO;
 import com.java110.user.bmo.rentingConfig.ISaveRentingConfigBMO;
 import com.java110.user.bmo.rentingConfig.IUpdateRentingConfigBMO;
-import com.java110.user.bmo.rentingPool.IAuditRentingBMO;
-import com.java110.user.bmo.rentingPool.IDeleteRentingPoolBMO;
-import com.java110.user.bmo.rentingPool.IGetRentingPoolBMO;
-import com.java110.user.bmo.rentingPool.ISaveRentingPoolBMO;
-import com.java110.user.bmo.rentingPool.IUpdateRentingPoolBMO;
+import com.java110.user.bmo.rentingPool.*;
 import com.java110.user.bmo.rentingPoolAttr.IDeleteRentingPoolAttrBMO;
 import com.java110.user.bmo.rentingPoolAttr.IGetRentingPoolAttrBMO;
 import com.java110.user.bmo.rentingPoolAttr.ISaveRentingPoolAttrBMO;
@@ -27,12 +25,7 @@
 import com.java110.utils.util.DateUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 
 @RestController
@@ -177,16 +170,23 @@
         Assert.hasKeyAndValue(reqJson, "rentingTitle", "璇锋眰鎶ユ枃涓湭鍖呭惈rentingTitle");
         Assert.hasKeyAndValue(reqJson, "roomId", "璇锋眰鎶ユ枃涓湭鍖呭惈roomId");
         Assert.hasKeyAndValue(reqJson, "communityId", "璇锋眰鎶ユ枃涓湭鍖呭惈communityId");
+        Assert.hasKeyAndValue(reqJson, "communityName", "璇锋眰鎶ユ枃涓湭鍖呭惈communityName");
         Assert.hasKeyAndValue(reqJson, "price", "璇锋眰鎶ユ枃涓湭鍖呭惈price");
         Assert.hasKeyAndValue(reqJson, "paymentType", "璇锋眰鎶ユ枃涓湭鍖呭惈paymentType");
         Assert.hasKeyAndValue(reqJson, "checkIn", "璇锋眰鎶ユ枃涓湭鍖呭惈checkIn");
         Assert.hasKeyAndValue(reqJson, "rentingConfigId", "璇锋眰鎶ユ枃涓湭鍖呭惈rentingConfigId");
         Assert.hasKeyAndValue(reqJson, "ownerName", "璇锋眰鎶ユ枃涓湭鍖呭惈ownerName");
         Assert.hasKeyAndValue(reqJson, "ownerTel", "璇锋眰鎶ユ枃涓湭鍖呭惈ownerTel");
+        JSONArray photos = null;
+        if (reqJson.containsKey("photos")) {
+            photos = reqJson.getJSONArray("photos");
+        }else{
+            photos = new JSONArray();
+        }
 
 
         RentingPoolPo rentingPoolPo = BeanConvertUtil.covertBean(reqJson, RentingPoolPo.class);
-        return saveRentingPoolBMOImpl.save(rentingPoolPo);
+        return saveRentingPoolBMOImpl.save(rentingPoolPo,photos);
     }
 
     /**
@@ -204,8 +204,7 @@
         Assert.hasKeyAndValue(reqJson, "roomId", "璇锋眰鎶ユ枃涓湭鍖呭惈roomId");
         Assert.hasKeyAndValue(reqJson, "communityId", "璇锋眰鎶ユ枃涓湭鍖呭惈communityId");
         Assert.hasKeyAndValue(reqJson, "price", "璇锋眰鎶ユ枃涓湭鍖呭惈price");
-        Assert.hasKeyAndValue(reqJson, "paymentType", "璇锋眰鎶ユ枃涓湭鍖呭惈paymentType");
-        Assert.hasKeyAndValue(reqJson, "checkInDate", "璇锋眰鎶ユ枃涓湭鍖呭惈checkInDate");
+        Assert.hasKeyAndValue(reqJson, "checkIn", "璇锋眰鎶ユ枃涓湭鍖呭惈checkInDate");
         Assert.hasKeyAndValue(reqJson, "rentingConfigId", "璇锋眰鎶ユ枃涓湭鍖呭惈rentingConfigId");
         Assert.hasKeyAndValue(reqJson, "ownerName", "璇锋眰鎶ユ枃涓湭鍖呭惈ownerName");
         Assert.hasKeyAndValue(reqJson, "ownerTel", "璇锋眰鎶ユ枃涓湭鍖呭惈ownerTel");
@@ -245,15 +244,21 @@
      */
     @RequestMapping(value = "/queryRentingPool", method = RequestMethod.GET)
     public ResponseEntity<String> queryRentingPool(@RequestParam(value = "communityId", required = false) String communityId,
+                                                   @RequestParam(value = "communityName", required = false) String communityName,
                                                    @RequestParam(value = "page") int page,
                                                    @RequestParam(value = "row") int row,
-                                                   @RequestParam(value = "state", required = false) String state
+                                                   @RequestParam(value = "state", required = false) String state,
+                                                   @RequestParam(value = "rentingType", required = false) String rentingType,
+                                                   @RequestParam(value = "rentingId", required = false) String rentingId
     ) {
         RentingPoolDto rentingPoolDto = new RentingPoolDto();
         rentingPoolDto.setPage(page);
         rentingPoolDto.setRow(row);
         rentingPoolDto.setCommunityId(communityId);
-        if (state.contains(",")) {
+        rentingPoolDto.setCommunityName(communityName);
+        rentingPoolDto.setRentingId(rentingId);
+        rentingPoolDto.setRentingType(rentingType);
+        if (!StringUtils.isEmpty(state) && state.contains(",")) {
             rentingPoolDto.setStates(state.split(","));
         } else {
             rentingPoolDto.setState(state);

--
Gitblit v1.8.0