Your Name 4 年之前
父節點
當前提交
d22f608790

+ 5
- 2
src/main/java/com/shigongli/common/BaseController.java 查看文件

@@ -1,5 +1,6 @@
1 1
 package com.shigongli.common;
2 2
 
3
+import com.shigongli.constants.StatusConstant;
3 4
 import com.shigongli.entity.TaPerson;
4 5
 import com.shigongli.service.ITaPersonService;
5 6
 import org.springframework.beans.factory.annotation.Autowired;
@@ -15,8 +16,10 @@ public class BaseController {
15 16
         String token = JWTUtils.getToken(request);
16 17
         try {
17 18
             Map<String, Object> params = JWTUtils.decode(token);
18
-            String personId = params.get("personId").toString();
19
-            return iTaPersonService.getById(personId);
19
+            String personId = params.get("userId").toString();
20
+            TaPerson taPerson = iTaPersonService.getById(personId);
21
+
22
+            return null == taPerson || StatusConstant.DELETE.equals(taPerson.getStatus()) ? null : taPerson;
20 23
         } catch (Exception e) {
21 24
             e.printStackTrace();
22 25
             return null;

+ 1
- 0
src/main/java/com/shigongli/controller/LoginController.java 查看文件

@@ -88,6 +88,7 @@ public class LoginController extends BaseController {
88 88
             taPerson.setOpenid(sessionInfo.getOpenid());
89 89
             iTaPersonService.save(taPerson);
90 90
         }
91
+        taPerson.setSessionKey(sessionInfo.getSessionKey());
91 92
 
92 93
         // 生成 token
93 94
         Map<String, Object> claims = new HashMap<>();

+ 27
- 0
src/main/java/com/shigongli/controller/TaHouseController.java 查看文件

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.shigongli.common.BaseController;
7 7
 import com.shigongli.common.ResponseBean;
8 8
 import com.shigongli.constants.StatusConstant;
9
+import com.shigongli.entity.TaPerson;
9 10
 import io.swagger.annotations.Api;
10 11
 import io.swagger.annotations.ApiOperation;
11 12
 import io.swagger.annotations.ApiParam;
@@ -21,6 +22,8 @@ import com.shigongli.service.ITaHouseService;
21 22
 import com.shigongli.entity.TaHouse;
22 23
 import org.springframework.web.bind.annotation.RestController;
23 24
 
25
+import javax.servlet.http.HttpServletRequest;
26
+
24 27
 /**
25 28
  * <p>
26 29
     * 房源 前端控制器
@@ -54,12 +57,36 @@ public class TaHouseController extends BaseController {
54 57
 
55 58
 		    IPage<TaHouse> pg = new Page<>(pageNum, pageSize);
56 59
             QueryWrapper<TaHouse> queryWrapper = new QueryWrapper<>();
60
+            queryWrapper.eq("status", StatusConstant.NORMAL);
57 61
             queryWrapper.orderByDesc("create_date");
58 62
 
59 63
             IPage<TaHouse> result = iTaHouseService.page(pg, queryWrapper);
60 64
             return ResponseBean.success(result);
61 65
     }
62 66
 
67
+    /**
68
+     * 分页查询列表
69
+     * @param pageNum
70
+     * @param pageSize
71
+     * @return
72
+     */
73
+    @RequestMapping(value="/ma/taHouse",method= RequestMethod.GET)
74
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
75
+    public ResponseBean houseList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
76
+                                  @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
77
+                                  HttpServletRequest request) throws Exception{
78
+
79
+        TaPerson taPerson = getPerson(request);
80
+        if (null == taPerson) {
81
+            return ResponseBean.error("数据错误, 校验当前人员出错", ResponseBean.ERROR_UNAVAILABLE);
82
+        }
83
+
84
+        IPage<TaHouse> pg = new Page<>(pageNum, pageSize);
85
+        IPage<TaHouse> result = iTaHouseService.getHousesOfKeeper(pg, taPerson);
86
+        return ResponseBean.success(result);
87
+    }
88
+
89
+
63 90
     /**
64 91
      * 保存对象
65 92
      * @param taHouse 实体对象

+ 3
- 0
src/main/java/com/shigongli/entity/TaPerson.java 查看文件

@@ -55,4 +55,7 @@ public class TaPerson implements Serializable {
55 55
 
56 56
     @TableField(exist = false)
57 57
     private String token;
58
+
59
+    @TableField(exist = false)
60
+    private String sessionKey;
58 61
 }

+ 3
- 0
src/main/java/com/shigongli/mapper/TaHouseMapper.java 查看文件

@@ -1,8 +1,10 @@
1 1
 package com.shigongli.mapper;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.shigongli.entity.TaHouse;
4 5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 6
 import org.apache.ibatis.annotations.Mapper;
7
+import org.apache.ibatis.annotations.Param;
6 8
 
7 9
 /**
8 10
  * <p>
@@ -15,4 +17,5 @@ import org.apache.ibatis.annotations.Mapper;
15 17
 @Mapper
16 18
 public interface TaHouseMapper extends BaseMapper<TaHouse> {
17 19
 
20
+    IPage<TaHouse> getHousesOfKeeper(IPage<TaHouse> pg, @Param("personId") String personId);
18 21
 }

+ 3
- 0
src/main/java/com/shigongli/service/ITaHouseService.java 查看文件

@@ -1,7 +1,9 @@
1 1
 package com.shigongli.service;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.shigongli.entity.TaHouse;
4 5
 import com.baomidou.mybatisplus.extension.service.IService;
6
+import com.shigongli.entity.TaPerson;
5 7
 
6 8
 /**
7 9
  * <p>
@@ -13,4 +15,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 15
  */
14 16
 public interface ITaHouseService extends IService<TaHouse> {
15 17
 
18
+    IPage<TaHouse> getHousesOfKeeper(IPage<TaHouse> pg, TaPerson taPerson);
16 19
 }

+ 11
- 0
src/main/java/com/shigongli/service/impl/TaHouseServiceImpl.java 查看文件

@@ -1,9 +1,12 @@
1 1
 package com.shigongli.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.shigongli.entity.TaHouse;
5
+import com.shigongli.entity.TaPerson;
4 6
 import com.shigongli.mapper.TaHouseMapper;
5 7
 import com.shigongli.service.ITaHouseService;
6 8
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9
+import org.springframework.beans.factory.annotation.Autowired;
7 10
 import org.springframework.stereotype.Service;
8 11
 
9 12
 /**
@@ -17,4 +20,12 @@ import org.springframework.stereotype.Service;
17 20
 @Service
18 21
 public class TaHouseServiceImpl extends ServiceImpl<TaHouseMapper, TaHouse> implements ITaHouseService {
19 22
 
23
+    @Autowired
24
+    TaHouseMapper taHouseMapper;
25
+
26
+    @Override
27
+    public IPage<TaHouse> getHousesOfKeeper(IPage<TaHouse> pg, TaPerson taPerson) {
28
+
29
+        return taHouseMapper.getHousesOfKeeper(pg, taPerson.getPersonId());
30
+    }
20 31
 }

+ 11
- 0
src/main/resources/mapper/TaHouseMapper.xml 查看文件

@@ -2,4 +2,15 @@
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.TaHouseMapper">
4 4
 
5
+    <select id="getHousesOfKeeper" resultType="com.shigongli.entity.TaHouse">
6
+        SELECT
7
+            t.*
8
+        FROM
9
+            ta_house t
10
+        INNER JOIN ta_shop_keeper s ON t.shop_id = s.shop_id
11
+        WHERE
12
+            s.person_id = #{personId}
13
+            AND s.`status` = 1
14
+            AND t.`status` = 1
15
+    </select>
5 16
 </mapper>