张延森 4 år sedan
förälder
incheckning
1ac9729943

+ 1
- 1
pom.xml Visa fil

@@ -10,7 +10,7 @@
10 10
 	</parent>
11 11
 	<groupId>com.shigongli</groupId>
12 12
 	<artifactId>shigongli</artifactId>
13
-	<version>1.0.3</version>
13
+	<version>1.0.5</version>
14 14
 	<name>shigongli</name>
15 15
 	<description>ShiGongli Service</description>
16 16
 

+ 22
- 3
src/main/java/com/shigongli/controller/TaHouseController.java Visa fil

@@ -11,6 +11,7 @@ import com.shigongli.constants.StatusConstant;
11 11
 import com.shigongli.entity.TaPerson;
12 12
 import com.shigongli.entity.TaShop;
13 13
 import com.shigongli.entity.TaShopKeeper;
14
+import com.shigongli.service.ITaHouseSurroundService;
14 15
 import com.shigongli.service.ITaShopKeeperService;
15 16
 import com.shigongli.service.ITaShopService;
16 17
 import io.swagger.annotations.Api;
@@ -25,6 +26,7 @@ import com.shigongli.service.ITaHouseService;
25 26
 import com.shigongli.entity.TaHouse;
26 27
 
27 28
 import javax.servlet.http.HttpServletRequest;
29
+import java.time.LocalDateTime;
28 30
 import java.util.HashMap;
29 31
 import java.util.List;
30 32
 import java.util.Map;
@@ -57,6 +59,9 @@ public class TaHouseController extends BaseController {
57 59
     @Autowired
58 60
     ITaShopService iTaShopService;
59 61
 
62
+    @Autowired
63
+    ITaHouseSurroundService iTaHouseSurroundService;
64
+
60 65
     @Autowired
61 66
     ScreenShotUtil screenShotUtil;
62 67
 
@@ -91,6 +96,7 @@ public class TaHouseController extends BaseController {
91 96
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
92 97
     public ResponseBean houseList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
93 98
                                   @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
99
+                                  @ApiParam("商铺ID") @RequestParam(value ="shopId", required = false) String shopId,
94 100
                                   HttpServletRequest request) throws Exception{
95 101
 
96 102
         TaPerson taPerson = getPerson(request);
@@ -99,7 +105,7 @@ public class TaHouseController extends BaseController {
99 105
         }
100 106
 
101 107
         IPage<TaHouse> pg = new Page<>(pageNum, pageSize);
102
-        IPage<TaHouse> result = iTaHouseService.getHousesOfKeeper(pg, taPerson);
108
+        IPage<TaHouse> result = iTaHouseService.getHousesOfKeeper(pg, taPerson, shopId);
103 109
         return ResponseBean.success(result);
104 110
     }
105 111
 
@@ -138,7 +144,19 @@ public class TaHouseController extends BaseController {
138 144
             taHouse.setShopId(shopKeeperList.get(0).getShopId());
139 145
         }
140 146
 
147
+        taHouse.setCreateDate(LocalDateTime.now());
148
+
149
+        // 复制房源
150
+        if (!StringUtils.isEmpty(taHouse.getOriginId())) {
151
+            taHouse.setTitle(String.format("%s(复制)", taHouse.getTitle() + ""));
152
+        }
153
+
141 154
         if (iTaHouseService.save(taHouse)){
155
+            // 复制房源
156
+            if (!StringUtils.isEmpty(taHouse.getOriginId())) {
157
+                iTaHouseSurroundService.copySurroundByHouse(taHouse.getOriginId(), taHouse.getHouseId());
158
+            }
159
+
142 160
             return ResponseBean.success(taHouse);
143 161
         } else {
144 162
             return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
@@ -199,9 +217,10 @@ public class TaHouseController extends BaseController {
199 217
      * 查询当前房源
200 218
      * @param id  实体ID
201 219
      */
202
-    @RequestMapping(value="/ma/taHouse/{id}",method= RequestMethod.GET)
220
+    @RequestMapping(value="/{client}/taHouse/{id}",method= RequestMethod.GET)
203 221
     @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
204
-    public ResponseBean houseDetail(@ApiParam("房源ID") @PathVariable String id) throws Exception{
222
+    public ResponseBean houseDetail(@ApiParam("客户端") @PathVariable String client,
223
+                                    @ApiParam("房源ID") @PathVariable String id) throws Exception{
205 224
         TaHouse taHouse = iTaHouseService.getById(id);
206 225
         TaShop taShop = iTaShopService.getById(taHouse.getShopId());
207 226
         taHouse.setTaShop(taShop);

+ 1
- 1
src/main/java/com/shigongli/controller/TaShopController.java Visa fil

@@ -113,7 +113,7 @@ public class TaShopController extends BaseController {
113 113
     @RequestMapping(value="/mp/taShop/{id}",method= RequestMethod.PUT)
114 114
     @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
115 115
     public ResponseBean taShopUpdate(@ApiParam("对象ID") @PathVariable String id,
116
-                                        @ApiParam("更新内容") @RequestBody TaShop taShop) throws Exception{
116
+                                     @ApiParam("更新内容") @RequestBody TaShop taShop) throws Exception{
117 117
         if (StringUtils.isEmpty(taShop.getName())) {
118 118
             return ResponseBean.error("名称不能为空", ResponseBean.ERROR_MISSING_PARAMS);
119 119
         }

+ 6
- 0
src/main/java/com/shigongli/entity/TaHouse.java Visa fil

@@ -82,4 +82,10 @@ public class TaHouse implements Serializable {
82 82
 
83 83
     @TableField(exist = false)
84 84
     private TaShop taShop;
85
+
86
+    /**
87
+     * 复制来源ID
88
+     */
89
+    @TableField(exist = false)
90
+    private String originId;
85 91
 }

+ 1
- 1
src/main/java/com/shigongli/mapper/TaHouseMapper.java Visa fil

@@ -17,5 +17,5 @@ import org.apache.ibatis.annotations.Param;
17 17
 @Mapper
18 18
 public interface TaHouseMapper extends BaseMapper<TaHouse> {
19 19
 
20
-    IPage<TaHouse> getHousesOfKeeper(IPage<TaHouse> pg, @Param("personId") String personId);
20
+    IPage<TaHouse> getHousesOfKeeper(IPage<TaHouse> pg, @Param("personId") String personId, @Param("shopId") String shopId);
21 21
 }

+ 2
- 0
src/main/java/com/shigongli/mapper/TaHouseSurroundMapper.java Visa fil

@@ -18,4 +18,6 @@ import org.apache.ibatis.annotations.Param;
18 18
 public interface TaHouseSurroundMapper extends BaseMapper<TaHouseSurround> {
19 19
 
20 20
     IPage<TaHouseSurround> getListByHouseOrNot(IPage<TaHouseSurround> pg, @Param("houseId") String houseId);
21
+
22
+    int copySurroundByHouse(@Param("fromHouse") String fromHouse,@Param("toHouse") String toHouse);
21 23
 }

+ 1
- 1
src/main/java/com/shigongli/service/ITaHouseService.java Visa fil

@@ -15,7 +15,7 @@ import com.shigongli.entity.TaPerson;
15 15
  */
16 16
 public interface ITaHouseService extends IService<TaHouse> {
17 17
 
18
-    IPage<TaHouse> getHousesOfKeeper(IPage<TaHouse> pg, TaPerson taPerson);
18
+    IPage<TaHouse> getHousesOfKeeper(IPage<TaHouse> pg, TaPerson taPerson, String shopId);
19 19
 
20 20
     boolean isOwner(String personId, String houseId);
21 21
 }

+ 2
- 0
src/main/java/com/shigongli/service/ITaHouseSurroundService.java Visa fil

@@ -15,4 +15,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
15 15
 public interface ITaHouseSurroundService extends IService<TaHouseSurround> {
16 16
 
17 17
     IPage<TaHouseSurround> getListByHouseOrNot(IPage<TaHouseSurround> pg, String houseId);
18
+
19
+    void copySurroundByHouse(String fromHouse, String toHouse);
18 20
 }

+ 2
- 2
src/main/java/com/shigongli/service/impl/TaHouseServiceImpl.java Visa fil

@@ -35,9 +35,9 @@ public class TaHouseServiceImpl extends ServiceImpl<TaHouseMapper, TaHouse> impl
35 35
     ITaShopKeeperService iTaShopKeeperService;
36 36
 
37 37
     @Override
38
-    public IPage<TaHouse> getHousesOfKeeper(IPage<TaHouse> pg, TaPerson taPerson) {
38
+    public IPage<TaHouse> getHousesOfKeeper(IPage<TaHouse> pg, TaPerson taPerson, String shopId) {
39 39
 
40
-        return taHouseMapper.getHousesOfKeeper(pg, taPerson.getPersonId());
40
+        return taHouseMapper.getHousesOfKeeper(pg, taPerson.getPersonId(), shopId);
41 41
     }
42 42
 
43 43
     @Override

+ 5
- 0
src/main/java/com/shigongli/service/impl/TaHouseSurroundServiceImpl.java Visa fil

@@ -25,4 +25,9 @@ public class TaHouseSurroundServiceImpl extends ServiceImpl<TaHouseSurroundMappe
25 25
     public IPage<TaHouseSurround> getListByHouseOrNot(IPage<TaHouseSurround> pg, String houseId) {
26 26
         return taHouseSurroundMapper.getListByHouseOrNot(pg, houseId);
27 27
     }
28
+
29
+    @Override
30
+    public void copySurroundByHouse(String fromHouse, String toHouse) {
31
+        taHouseSurroundMapper.copySurroundByHouse(fromHouse, toHouse);
32
+    }
28 33
 }

+ 2
- 1
src/main/java/com/shigongli/service/impl/TaShopKeeperServiceImpl.java Visa fil

@@ -63,7 +63,8 @@ public class TaShopKeeperServiceImpl extends ServiceImpl<TaShopKeeperMapper, TaS
63 63
 
64 64
         QueryWrapper<TaShopKeeper> queryWrapper = new QueryWrapper<TaShopKeeper>()
65 65
                 .eq("person_id", personId)
66
-                .eq("status", StatusConstant.NORMAL);
66
+                .eq("status", StatusConstant.NORMAL)
67
+                .orderByAsc("shop_id");
67 68
 
68 69
         List<TaShopKeeper> list = list(queryWrapper);
69 70
         if (null != list && list.size() > 0) {

+ 4
- 0
src/main/resources/mapper/TaHouseMapper.xml Visa fil

@@ -10,7 +10,11 @@
10 10
         INNER JOIN ta_shop_keeper s ON t.shop_id = s.shop_id
11 11
         WHERE
12 12
             s.person_id = #{personId}
13
+        <if test="null != shopId and '' != shopId">
14
+            AND s.shop_id = #{shopId}
15
+        </if>
13 16
             AND s.`status` = 1
14 17
             AND t.`status` = 1
18
+        ORDER BY t.title DESC
15 19
     </select>
16 20
 </mapper>

+ 15
- 0
src/main/resources/mapper/TaHouseSurroundMapper.xml Visa fil

@@ -1,6 +1,21 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.shigongli.mapper.TaHouseSurroundMapper">
4
+    <insert id="copySurroundByHouse">
5
+        INSERT INTO ta_house_surround ( surround_id, house_id, image_id, sort_no, `status`, create_date )
6
+            SELECT
7
+            UUID( ),
8
+            #{toHouse},
9
+            t.image_id,
10
+            t.sort_no,
11
+            t.`status`,
12
+            NOW( )
13
+        FROM
14
+            ta_house_surround t
15
+        WHERE
16
+            t.house_id = #{fromHouse}
17
+            AND t.`status` = 1
18
+    </insert>
4 19
 
5 20
     <select id="getListByHouseOrNot" resultType="com.shigongli.entity.TaHouseSurround">
6 21
         SELECT