张延森 4 years ago
parent
commit
1ac9729943

+ 1
- 1
pom.xml View File

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

+ 22
- 3
src/main/java/com/shigongli/controller/TaHouseController.java View File

11
 import com.shigongli.entity.TaPerson;
11
 import com.shigongli.entity.TaPerson;
12
 import com.shigongli.entity.TaShop;
12
 import com.shigongli.entity.TaShop;
13
 import com.shigongli.entity.TaShopKeeper;
13
 import com.shigongli.entity.TaShopKeeper;
14
+import com.shigongli.service.ITaHouseSurroundService;
14
 import com.shigongli.service.ITaShopKeeperService;
15
 import com.shigongli.service.ITaShopKeeperService;
15
 import com.shigongli.service.ITaShopService;
16
 import com.shigongli.service.ITaShopService;
16
 import io.swagger.annotations.Api;
17
 import io.swagger.annotations.Api;
25
 import com.shigongli.entity.TaHouse;
26
 import com.shigongli.entity.TaHouse;
26
 
27
 
27
 import javax.servlet.http.HttpServletRequest;
28
 import javax.servlet.http.HttpServletRequest;
29
+import java.time.LocalDateTime;
28
 import java.util.HashMap;
30
 import java.util.HashMap;
29
 import java.util.List;
31
 import java.util.List;
30
 import java.util.Map;
32
 import java.util.Map;
57
     @Autowired
59
     @Autowired
58
     ITaShopService iTaShopService;
60
     ITaShopService iTaShopService;
59
 
61
 
62
+    @Autowired
63
+    ITaHouseSurroundService iTaHouseSurroundService;
64
+
60
     @Autowired
65
     @Autowired
61
     ScreenShotUtil screenShotUtil;
66
     ScreenShotUtil screenShotUtil;
62
 
67
 
91
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
96
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
92
     public ResponseBean houseList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
97
     public ResponseBean houseList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
93
                                   @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
98
                                   @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
99
+                                  @ApiParam("商铺ID") @RequestParam(value ="shopId", required = false) String shopId,
94
                                   HttpServletRequest request) throws Exception{
100
                                   HttpServletRequest request) throws Exception{
95
 
101
 
96
         TaPerson taPerson = getPerson(request);
102
         TaPerson taPerson = getPerson(request);
99
         }
105
         }
100
 
106
 
101
         IPage<TaHouse> pg = new Page<>(pageNum, pageSize);
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
         return ResponseBean.success(result);
109
         return ResponseBean.success(result);
104
     }
110
     }
105
 
111
 
138
             taHouse.setShopId(shopKeeperList.get(0).getShopId());
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
         if (iTaHouseService.save(taHouse)){
154
         if (iTaHouseService.save(taHouse)){
155
+            // 复制房源
156
+            if (!StringUtils.isEmpty(taHouse.getOriginId())) {
157
+                iTaHouseSurroundService.copySurroundByHouse(taHouse.getOriginId(), taHouse.getHouseId());
158
+            }
159
+
142
             return ResponseBean.success(taHouse);
160
             return ResponseBean.success(taHouse);
143
         } else {
161
         } else {
144
             return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
162
             return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
199
      * 查询当前房源
217
      * 查询当前房源
200
      * @param id  实体ID
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
     @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
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
         TaHouse taHouse = iTaHouseService.getById(id);
224
         TaHouse taHouse = iTaHouseService.getById(id);
206
         TaShop taShop = iTaShopService.getById(taHouse.getShopId());
225
         TaShop taShop = iTaShopService.getById(taHouse.getShopId());
207
         taHouse.setTaShop(taShop);
226
         taHouse.setTaShop(taShop);

+ 1
- 1
src/main/java/com/shigongli/controller/TaShopController.java View File

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

+ 6
- 0
src/main/java/com/shigongli/entity/TaHouse.java View File

82
 
82
 
83
     @TableField(exist = false)
83
     @TableField(exist = false)
84
     private TaShop taShop;
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 View File

17
 @Mapper
17
 @Mapper
18
 public interface TaHouseMapper extends BaseMapper<TaHouse> {
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 View File

18
 public interface TaHouseSurroundMapper extends BaseMapper<TaHouseSurround> {
18
 public interface TaHouseSurroundMapper extends BaseMapper<TaHouseSurround> {
19
 
19
 
20
     IPage<TaHouseSurround> getListByHouseOrNot(IPage<TaHouseSurround> pg, @Param("houseId") String houseId);
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 View File

15
  */
15
  */
16
 public interface ITaHouseService extends IService<TaHouse> {
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
     boolean isOwner(String personId, String houseId);
20
     boolean isOwner(String personId, String houseId);
21
 }
21
 }

+ 2
- 0
src/main/java/com/shigongli/service/ITaHouseSurroundService.java View File

15
 public interface ITaHouseSurroundService extends IService<TaHouseSurround> {
15
 public interface ITaHouseSurroundService extends IService<TaHouseSurround> {
16
 
16
 
17
     IPage<TaHouseSurround> getListByHouseOrNot(IPage<TaHouseSurround> pg, String houseId);
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 View File

35
     ITaShopKeeperService iTaShopKeeperService;
35
     ITaShopKeeperService iTaShopKeeperService;
36
 
36
 
37
     @Override
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
     @Override
43
     @Override

+ 5
- 0
src/main/java/com/shigongli/service/impl/TaHouseSurroundServiceImpl.java View File

25
     public IPage<TaHouseSurround> getListByHouseOrNot(IPage<TaHouseSurround> pg, String houseId) {
25
     public IPage<TaHouseSurround> getListByHouseOrNot(IPage<TaHouseSurround> pg, String houseId) {
26
         return taHouseSurroundMapper.getListByHouseOrNot(pg, houseId);
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 View File

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

+ 4
- 0
src/main/resources/mapper/TaHouseMapper.xml View File

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

+ 15
- 0
src/main/resources/mapper/TaHouseSurroundMapper.xml View File

1
 <?xml version="1.0" encoding="UTF-8"?>
1
 <?xml version="1.0" encoding="UTF-8"?>
2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
 <mapper namespace="com.shigongli.mapper.TaHouseSurroundMapper">
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
     <select id="getListByHouseOrNot" resultType="com.shigongli.entity.TaHouseSurround">
20
     <select id="getListByHouseOrNot" resultType="com.shigongli.entity.TaHouseSurround">
6
         SELECT
21
         SELECT