weiximei 6 years ago
parent
commit
84ce3dafae
17 changed files with 454 additions and 18 deletions
  1. 62
    3
      whole-estate/src/main/java/com/example/wholeestate/controller/ActivityController.java
  2. 26
    4
      whole-estate/src/main/java/com/example/wholeestate/controller/AppointmentController.java
  3. 65
    4
      whole-estate/src/main/java/com/example/wholeestate/controller/BuildingController.java
  4. 22
    0
      whole-estate/src/main/java/com/example/wholeestate/controller/TaCollectionController.java
  5. 2
    2
      whole-estate/src/main/java/com/example/wholeestate/dao/ActivityEnrollMapper.java
  6. 12
    1
      whole-estate/src/main/java/com/example/wholeestate/dao/AppointmentMapper.java
  7. 57
    0
      whole-estate/src/main/java/com/example/wholeestate/dao/TaCollectionMapper.java
  8. 6
    0
      whole-estate/src/main/java/com/example/wholeestate/model/Appointment.java
  9. 43
    0
      whole-estate/src/main/java/com/example/wholeestate/model/TaCollection.java
  10. 3
    1
      whole-estate/src/main/java/com/example/wholeestate/service/IActivityService.java
  11. 10
    0
      whole-estate/src/main/java/com/example/wholeestate/service/IAppointmentService.java
  12. 42
    0
      whole-estate/src/main/java/com/example/wholeestate/service/ITaCollectionService.java
  13. 8
    1
      whole-estate/src/main/java/com/example/wholeestate/service/impl/ActivityServiceImpl.java
  14. 18
    0
      whole-estate/src/main/java/com/example/wholeestate/service/impl/AppointmentServiceImpl.java
  15. 73
    0
      whole-estate/src/main/java/com/example/wholeestate/service/impl/TaCollectionServiceImpl.java
  16. 0
    2
      whole-estate/src/main/resources/application.yml
  17. 5
    0
      whole-estate/src/main/resources/mapper/TaCollectionMapper.xml

+ 62
- 3
whole-estate/src/main/java/com/example/wholeestate/controller/ActivityController.java View File

14
 import io.swagger.annotations.ApiImplicitParams;
14
 import io.swagger.annotations.ApiImplicitParams;
15
 import io.swagger.annotations.ApiOperation;
15
 import io.swagger.annotations.ApiOperation;
16
 import org.springframework.beans.factory.annotation.Autowired;
16
 import org.springframework.beans.factory.annotation.Autowired;
17
+import org.springframework.beans.propertyeditors.CustomDateEditor;
18
+import org.springframework.web.bind.ServletRequestDataBinder;
17
 import org.springframework.web.bind.annotation.*;
19
 import org.springframework.web.bind.annotation.*;
18
 
20
 
21
+import javax.servlet.http.HttpServletRequest;
22
+import java.text.DateFormat;
23
+import java.text.SimpleDateFormat;
24
+import java.util.Date;
25
+
19
 /**
26
 /**
20
  * <p>
27
  * <p>
21
  * 活动表 前端控制器
28
  * 活动表 前端控制器
37
     @Autowired
44
     @Autowired
38
     private IActivityEnrollService iActivityEnrollService;
45
     private IActivityEnrollService iActivityEnrollService;
39
 
46
 
47
+    /**
48
+     * 自定义方法绑定请求参数的Date类型
49
+     *
50
+     * @param request
51
+     * @param binder
52
+     * @throws Exception
53
+     */
54
+    @InitBinder
55
+    protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
56
+        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
57
+        CustomDateEditor editor = new CustomDateEditor(df, true);//true表示允许为空,false反之
58
+        binder.registerCustomEditor(Date.class, editor);
59
+    }
60
+
40
 
61
 
41
     @RequestMapping(value = "/activity/list", method = RequestMethod.GET)
62
     @RequestMapping(value = "/activity/list", method = RequestMethod.GET)
42
     @ApiOperation(value = "活动列表", notes = "活动列表")
63
     @ApiOperation(value = "活动列表", notes = "活动列表")
43
     @ApiImplicitParams({
64
     @ApiImplicitParams({
44
             @ApiImplicitParam(paramType = "query", dataTypeClass = Integer.class, name = "pageNum", value = "pageNum第几页"),
65
             @ApiImplicitParam(paramType = "query", dataTypeClass = Integer.class, name = "pageNum", value = "pageNum第几页"),
45
-            @ApiImplicitParam(paramType = "query", dataTypeClass = Integer.class, name = "pageSize", value = "pageSize一页多少行")
66
+            @ApiImplicitParam(paramType = "query", dataTypeClass = Integer.class, name = "pageSize", value = "pageSize一页多少行"),
67
+            @ApiImplicitParam(paramType = "query", dataTypeClass = String.class, name = "name", value = "活动名称"),
68
+            @ApiImplicitParam(paramType = "query", dataTypeClass = Date.class, name = "beginDate", value = "开始时间"),
69
+            @ApiImplicitParam(paramType = "query", dataTypeClass = Date.class, name = "endDate", value = "结束时间")
46
     })
70
     })
47
-    public ResponseBean getList(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize) {
71
+    public ResponseBean getList(@RequestParam(defaultValue = "1") Integer pageNum,
72
+                                @RequestParam(defaultValue = "10") Integer pageSize,
73
+                                @RequestParam(required = false) String name,
74
+                                @RequestParam(required = false) Date beginDate,
75
+                                @RequestParam(required = false) Date endDate) {
48
         ResponseBean responseBean = new ResponseBean();
76
         ResponseBean responseBean = new ResponseBean();
49
-        responseBean = iActivityService.getList(pageNum, pageSize);
77
+        responseBean = iActivityService.getList(pageNum, pageSize, name, beginDate, endDate);
50
         return responseBean;
78
         return responseBean;
51
     }
79
     }
52
 
80
 
69
     public ResponseBean add(@RequestBody String parameter) {
97
     public ResponseBean add(@RequestBody String parameter) {
70
         ResponseBean responseBean = new ResponseBean();
98
         ResponseBean responseBean = new ResponseBean();
71
         Activity activity = JSONObject.parseObject(parameter, Activity.class);
99
         Activity activity = JSONObject.parseObject(parameter, Activity.class);
100
+        activity.setStatus(0);
72
         activity.setActivityId(idGen.nextId()+"");
101
         activity.setActivityId(idGen.nextId()+"");
73
         iActivityService.save(activity);
102
         iActivityService.save(activity);
74
         return responseBean;
103
         return responseBean;
75
     }
104
     }
76
 
105
 
106
+    @RequestMapping(value = "/activity/send/{activityId}", method = RequestMethod.PUT)
107
+    @ApiOperation(value = "活动发布", notes = "活动发布")
108
+    @ApiImplicitParams({
109
+            @ApiImplicitParam(paramType = "path", dataTypeClass = String.class, name = "activityId", value = "activityId活动编号")
110
+    })
111
+    public ResponseBean send(@PathVariable String activityId) {
112
+        ResponseBean responseBean = new ResponseBean();
113
+        QueryWrapper<Activity> activityQueryWrapper = new QueryWrapper<>();
114
+        activityQueryWrapper.eq("activity_id", activityId);
115
+        Activity activity = iActivityService.getOne(activityQueryWrapper);
116
+        activity.setStatus(1);
117
+        iActivityService.update(activity, activityQueryWrapper);
118
+        return responseBean;
119
+    }
120
+
121
+    @RequestMapping(value = "/activity/cancel/{activityId}", method = RequestMethod.PUT)
122
+    @ApiOperation(value = "活动取消发布", notes = "活动取消发布")
123
+    @ApiImplicitParams({
124
+            @ApiImplicitParam(paramType = "path", dataTypeClass = String.class, name = "activityId", value = "activityId活动编号")
125
+    })
126
+    public ResponseBean cancel(@PathVariable String activityId) {
127
+        ResponseBean responseBean = new ResponseBean();
128
+        QueryWrapper<Activity> activityQueryWrapper = new QueryWrapper<>();
129
+        activityQueryWrapper.eq("activity_id", activityId);
130
+        Activity activity = iActivityService.getOne(activityQueryWrapper);
131
+        activity.setStatus(0);
132
+        iActivityService.update(activity, activityQueryWrapper);
133
+        return responseBean;
134
+    }
135
+
77
     @RequestMapping(value = "/activity/update", method = RequestMethod.PUT)
136
     @RequestMapping(value = "/activity/update", method = RequestMethod.PUT)
78
     @ApiOperation(value = "修改活动", notes = "修改活动")
137
     @ApiOperation(value = "修改活动", notes = "修改活动")
79
     @ApiImplicitParams({
138
     @ApiImplicitParams({

+ 26
- 4
whole-estate/src/main/java/com/example/wholeestate/controller/AppointmentController.java View File

2
 
2
 
3
 
3
 
4
 import com.example.wholeestate.common.base.BaseController;
4
 import com.example.wholeestate.common.base.BaseController;
5
-import org.springframework.web.bind.annotation.RequestMapping;
6
-
7
-import org.springframework.web.bind.annotation.RestController;
5
+import com.example.wholeestate.common.resp.ResponseBean;
6
+import com.example.wholeestate.service.IAppointmentService;
7
+import io.swagger.annotations.Api;
8
+import io.swagger.annotations.ApiImplicitParam;
9
+import io.swagger.annotations.ApiImplicitParams;
10
+import io.swagger.annotations.ApiOperation;
11
+import org.springframework.beans.factory.annotation.Autowired;
12
+import org.springframework.web.bind.annotation.*;
8
 
13
 
9
 /**
14
 /**
10
  * <p>
15
  * <p>
15
  * @since 2019-03-21
20
  * @since 2019-03-21
16
  */
21
  */
17
 @RestController
22
 @RestController
18
-@RequestMapping("/ta/appointment")
23
+@RequestMapping("/")
24
+@Api(value = "预约记录 API", description = "预约记录 API")
19
 public class AppointmentController extends BaseController {
25
 public class AppointmentController extends BaseController {
20
 
26
 
27
+    @Autowired
28
+    private IAppointmentService iAppointmentService;
29
+
30
+    @RequestMapping(value = "/wx/appointment/{openid}", method = RequestMethod.GET)
31
+    @ApiOperation(value = "根据openid 查询 预约记录", notes = "根据openid 查询 预约记录")
32
+    @ApiImplicitParams({
33
+            @ApiImplicitParam(paramType = "query", dataTypeClass = Integer.class, name = "pageNum", value = "pageNum第几页"),
34
+            @ApiImplicitParam(paramType = "query", dataTypeClass = Integer.class, name = "pageSize", value = "pageSize一页多少行"),
35
+            @ApiImplicitParam(paramType = "path", dataTypeClass = String.class, name = "openid", value = "openid")
36
+    })
37
+    public ResponseBean openidAppointementList(@PathVariable("openid") String openid, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize) {
38
+        ResponseBean responseBean = new ResponseBean();
39
+        responseBean = iAppointmentService.getOpenidAppointmentList(openid, pageNum, pageSize);
40
+        return responseBean;
41
+    }
42
+
21
 }
43
 }

+ 65
- 4
whole-estate/src/main/java/com/example/wholeestate/controller/BuildingController.java View File

6
 import com.example.wholeestate.common.session.UserElement;
6
 import com.example.wholeestate.common.session.UserElement;
7
 import com.example.wholeestate.model.SysUser;
7
 import com.example.wholeestate.model.SysUser;
8
 import com.example.wholeestate.service.IBuildingService;
8
 import com.example.wholeestate.service.IBuildingService;
9
+import com.example.wholeestate.service.ITaCollectionService;
9
 import io.swagger.annotations.Api;
10
 import io.swagger.annotations.Api;
10
 import io.swagger.annotations.ApiImplicitParam;
11
 import io.swagger.annotations.ApiImplicitParam;
11
 import io.swagger.annotations.ApiImplicitParams;
12
 import io.swagger.annotations.ApiImplicitParams;
12
 import io.swagger.annotations.ApiOperation;
13
 import io.swagger.annotations.ApiOperation;
13
 import org.springframework.beans.factory.annotation.Autowired;
14
 import org.springframework.beans.factory.annotation.Autowired;
15
+import org.springframework.beans.propertyeditors.CustomDateEditor;
16
+import org.springframework.web.bind.ServletRequestDataBinder;
14
 import org.springframework.web.bind.annotation.*;
17
 import org.springframework.web.bind.annotation.*;
15
 
18
 
19
+import javax.servlet.http.HttpServletRequest;
16
 import javax.servlet.http.HttpSession;
20
 import javax.servlet.http.HttpSession;
21
+import java.text.DateFormat;
22
+import java.text.SimpleDateFormat;
23
+import java.util.Date;
17
 
24
 
18
 /**
25
 /**
19
  * <p>
26
  * <p>
27
 @RequestMapping("/")
34
 @RequestMapping("/")
28
 @Api(value = "楼盘API",description = "楼盘API")
35
 @Api(value = "楼盘API",description = "楼盘API")
29
 public class BuildingController extends BaseController {
36
 public class BuildingController extends BaseController {
30
-@Autowired
37
+
38
+    @Autowired
31
     private IBuildingService iBuildingService;
39
     private IBuildingService iBuildingService;
32
 
40
 
41
+    @Autowired
42
+    private ITaCollectionService iTaCollectionService;
43
+
44
+    /**
45
+     * 自定义方法绑定请求参数的Date类型
46
+     *
47
+     * @param request
48
+     * @param binder
49
+     * @throws Exception
50
+     */
51
+    @InitBinder
52
+    protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
53
+        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
54
+        CustomDateEditor editor = new CustomDateEditor(df, true);//true表示允许为空,false反之
55
+        binder.registerCustomEditor(Date.class, editor);
56
+    }
57
+
33
     @RequestMapping(value = "/buildingSelectId/{id}", method = RequestMethod.GET)
58
     @RequestMapping(value = "/buildingSelectId/{id}", method = RequestMethod.GET)
34
     @ApiOperation(value = "楼盘详情", notes = "楼盘详情")
59
     @ApiOperation(value = "楼盘详情", notes = "楼盘详情")
35
     @ApiImplicitParams({
60
     @ApiImplicitParams({
47
             @ApiImplicitParam(paramType = "Query",dataType = "String",name = "code",value = "code:状态")
72
             @ApiImplicitParam(paramType = "Query",dataType = "String",name = "code",value = "code:状态")
48
     })
73
     })
49
     @RequestMapping(value = "/buildinglist", method = RequestMethod.GET)
74
     @RequestMapping(value = "/buildinglist", method = RequestMethod.GET)
50
-    public ResponseBean buildingList(@RequestParam("pageNum")Integer pageNum,@RequestParam("pageSize")Integer pageSize,
51
-                                        @RequestParam("name")String name,
52
-                                                @RequestParam("code")String code){
75
+    public ResponseBean buildingList(@RequestParam("pageNum")Integer pageNum,
76
+                                     @RequestParam("pageSize")Integer pageSize,
77
+                                     @RequestParam(value = "name", required = false)String name,
78
+                                     @RequestParam(value = "code", required = false)String code){
53
         ResponseBean  responseBean = iBuildingService.buildingList(pageNum,pageSize,name,code);
79
         ResponseBean  responseBean = iBuildingService.buildingList(pageNum,pageSize,name,code);
54
         return responseBean;
80
         return responseBean;
55
     }
81
     }
107
         return responseBean;
133
         return responseBean;
108
     }
134
     }
109
 
135
 
136
+    @RequestMapping(value = "/wx/collection/{openid}", method = RequestMethod.GET)
137
+    @ApiOperation(value = "根据 openid 查询 收藏楼盘")
138
+    @ApiImplicitParams({
139
+            @ApiImplicitParam(paramType = "query", dataTypeClass = Integer.class, name = "pageNum", value = "pageNum第几页"),
140
+            @ApiImplicitParam(paramType = "query", dataTypeClass = Integer.class, name = "pageSize", value = "pageSize一页多少行"),
141
+            @ApiImplicitParam(paramType = "path", dataTypeClass = String.class, name = "openid", value = "openid")
142
+    })
143
+    public ResponseBean openidCollectionBuilding(@PathVariable("openid") String openid, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize) {
144
+        ResponseBean responseBean = new ResponseBean();
145
+        responseBean = iTaCollectionService.openidCollectionBuilding(openid, pageNum, pageSize);
146
+        return responseBean;
147
+    }
148
+
149
+    @RequestMapping(value = "/wx/collection/{openid}", method = RequestMethod.DELETE)
150
+    @ApiOperation(value = "根据 openid 和 buildingId 删除收藏楼盘")
151
+    @ApiImplicitParams({
152
+            @ApiImplicitParam(paramType = "path", dataTypeClass = String.class, name = "openid", value = "openid"),
153
+            @ApiImplicitParam(paramType = "query", dataTypeClass = String.class, name = "buildingId", value = "buildingId楼盘编号"),
154
+    })
155
+    public ResponseBean deleteCollection(@PathVariable("openid") String openid, @RequestParam String buildingId) {
156
+        ResponseBean responseBean = new ResponseBean();
157
+        responseBean = iTaCollectionService.deleteCollection(openid, buildingId);
158
+        return responseBean;
159
+    }
110
 
160
 
161
+    @RequestMapping(value = "/wx/collection/{openid}", method = RequestMethod.POST)
162
+    @ApiOperation(value = "根据 openid 和 buildingId 收藏楼盘")
163
+    @ApiImplicitParams({
164
+            @ApiImplicitParam(paramType = "path", dataTypeClass = String.class, name = "openid", value = "openid"),
165
+            @ApiImplicitParam(paramType = "query", dataTypeClass = String.class, name = "buildingId", value = "buildingId楼盘编号"),
166
+    })
167
+    public ResponseBean addCollection(@PathVariable("openid") String openid, @RequestParam String buildingId) {
168
+        ResponseBean responseBean = new ResponseBean();
169
+        responseBean = iTaCollectionService.addCollection(openid, buildingId);
170
+        return responseBean;
171
+    }
111
 
172
 
112
 }
173
 }

+ 22
- 0
whole-estate/src/main/java/com/example/wholeestate/controller/TaCollectionController.java View File

1
+package com.example.wholeestate.controller;
2
+
3
+
4
+import com.example.wholeestate.common.base.BaseController;
5
+import io.swagger.annotations.Api;
6
+import org.springframework.web.bind.annotation.RequestMapping;
7
+import org.springframework.web.bind.annotation.RestController;
8
+
9
+/**
10
+ * <p>
11
+ * 收藏表 前端控制器
12
+ * </p>
13
+ *
14
+ * @author weiximei
15
+ * @since 2019-03-21
16
+ */
17
+@RestController
18
+@RequestMapping("/")
19
+@Api(value = "收藏 API", description = "收藏 API")
20
+public class TaCollectionController extends BaseController {
21
+
22
+}

+ 2
- 2
whole-estate/src/main/java/com/example/wholeestate/dao/ActivityEnrollMapper.java View File

28
             "RIGHT JOIN ta_activity_enroll tace ON tac.activity_id = tace.activity_id " +
28
             "RIGHT JOIN ta_activity_enroll tace ON tac.activity_id = tace.activity_id " +
29
             "LEFT JOIN ta_customer tacus ON tace.customer_id = tacus.customer_id " +
29
             "LEFT JOIN ta_customer tacus ON tace.customer_id = tacus.customer_id " +
30
             "LEFT JOIN ta_building tab ON tac.building_id = tab.building_id " +
30
             "LEFT JOIN ta_building tab ON tac.building_id = tab.building_id " +
31
-            "WHERE tac.activity_id = #{activityId}")
31
+            "WHERE tac.activity_id = #{activityId} and tac.status > -1")
32
     IPage<Activity> selectPageActivityEnroll(Page page, @Param("activityId") String activityId);
32
     IPage<Activity> selectPageActivityEnroll(Page page, @Param("activityId") String activityId);
33
 
33
 
34
     /**
34
     /**
41
             "RIGHT JOIN ta_activity_enroll tace ON tac.activity_id = tace.activity_id " +
41
             "RIGHT JOIN ta_activity_enroll tace ON tac.activity_id = tace.activity_id " +
42
             "LEFT JOIN ta_customer tacus ON tace.customer_id = tacus.customer_id " +
42
             "LEFT JOIN ta_customer tacus ON tace.customer_id = tacus.customer_id " +
43
             "LEFT JOIN ta_building tab ON tac.building_id = tab.building_id " +
43
             "LEFT JOIN ta_building tab ON tac.building_id = tab.building_id " +
44
-            "WHERE tacus.openid = #{openid}")
44
+            "WHERE tacus.openid = #{openid} tac.status > -1")
45
     IPage<Activity> selectOpenidActivityEnroll(Page page, @Param("openid") String openid);
45
     IPage<Activity> selectOpenidActivityEnroll(Page page, @Param("openid") String openid);
46
 
46
 
47
 }
47
 }

+ 12
- 1
whole-estate/src/main/java/com/example/wholeestate/dao/AppointmentMapper.java View File

4
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
4
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6
 import com.example.wholeestate.model.Appointment;
6
 import com.example.wholeestate.model.Appointment;
7
+import org.apache.ibatis.annotations.Param;
8
+import org.apache.ibatis.annotations.Select;
7
 
9
 
8
 /**
10
 /**
9
  * <p>
11
  * <p>
20
      * @return
22
      * @return
21
      */
23
      */
22
     IPage<Appendable> appendableList(Page<Appendable> page);
24
     IPage<Appendable> appendableList(Page<Appendable> page);
23
-    
25
+
26
+    @Select("SELECT " +
27
+            "taa.*, " +
28
+            "tab.building_name AS buildingName " +
29
+            "FROM " +
30
+            "ta_appointment taa " +
31
+            "LEFT JOIN ta_building tab ON taa.building_id = tab.building_id " +
32
+            "LEFT JOIN ta_customer tac ON taa.customer_id = tac.customer_id " +
33
+            "WHERE tac.openid = #{openid}")
34
+    IPage<Appointment> getOpenidAppendableList(Page<Appointment> page, @Param("openid") String openid);
24
 
35
 
25
 }
36
 }

+ 57
- 0
whole-estate/src/main/java/com/example/wholeestate/dao/TaCollectionMapper.java View File

1
+package com.example.wholeestate.dao;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.example.wholeestate.model.Building;
7
+import com.example.wholeestate.model.TaCollection;
8
+import org.apache.ibatis.annotations.Delete;
9
+import org.apache.ibatis.annotations.Param;
10
+import org.apache.ibatis.annotations.Select;
11
+
12
+/**
13
+ * <p>
14
+ * 收藏表 Mapper 接口
15
+ * </p>
16
+ *
17
+ * @author weiximei
18
+ * @since 2019-03-21
19
+ */
20
+public interface TaCollectionMapper extends BaseMapper<TaCollection> {
21
+
22
+    /**
23
+     * 根据 openid 查询 收藏楼盘记录
24
+     * @param page
25
+     * @param openid
26
+     * @return
27
+     */
28
+    @Select("SELECT " +
29
+            "tab.* " +
30
+            "FROM " +
31
+            "ta_collection tac " +
32
+            "LEFT JOIN ta_building tab ON tac.building_id = tab.building_id " +
33
+            "LEFT JOIN ta_customer tacu ON tac.customer_id = tacu.customer_id " +
34
+            "WHERE tacu.openid = #{openid}")
35
+    IPage<Building> openidCollectionBuilding(Page<Building> page, @Param("openid") String openid);
36
+
37
+    /**
38
+     * 根据 openid 和 楼盘id 删除收藏列表
39
+     * @param openid
40
+     * @param buildingId
41
+     * @return
42
+     */
43
+    @Delete("DELETE FROM ta_collection where customer_id = (select customer_id FROM ta_customer where openid = #{openid}) and building_id = #{buildingId}")
44
+    int deleteCollection(@Param("openid") String openid, @Param("buildingId") String buildingId);
45
+
46
+
47
+    /**
48
+     * 根据 openid 和 楼盘id 查询楼盘记录
49
+     * @param openid
50
+     * @param buildingId
51
+     * @return
52
+     */
53
+    @Select("SELECT * FROM ta_collection where customer_id = (select customer_id FROM ta_customer where openid = #{openid}) and building_id = #{buildingId}")
54
+    TaCollection selectOpenidAndBuildingId(@Param("openid") String openid, @Param("buildingId") String buildingId);
55
+
56
+
57
+}

+ 6
- 0
whole-estate/src/main/java/com/example/wholeestate/model/Appointment.java View File

1
 package com.example.wholeestate.model;
1
 package com.example.wholeestate.model;
2
 
2
 
3
+import com.baomidou.mybatisplus.annotation.TableField;
3
 import com.baomidou.mybatisplus.annotation.TableName;
4
 import com.baomidou.mybatisplus.annotation.TableName;
4
 import java.time.LocalDateTime;
5
 import java.time.LocalDateTime;
5
 import java.io.Serializable;
6
 import java.io.Serializable;
68
      */
69
      */
69
     private LocalDateTime createDate;
70
     private LocalDateTime createDate;
70
 
71
 
72
+    /**
73
+     * 楼盘名称
74
+     */
75
+    @TableField(exist = false)
76
+    private String buildingName;
71
 
77
 
72
 }
78
 }

+ 43
- 0
whole-estate/src/main/java/com/example/wholeestate/model/TaCollection.java View File

1
+package com.example.wholeestate.model;
2
+
3
+import com.baomidou.mybatisplus.annotation.TableName;
4
+import lombok.Data;
5
+import lombok.EqualsAndHashCode;
6
+import lombok.experimental.Accessors;
7
+
8
+import java.io.Serializable;
9
+import java.time.LocalDateTime;
10
+
11
+/**
12
+ * <p>
13
+ * 收藏表
14
+ * </p>
15
+ *
16
+ * @author weiximei
17
+ * @since 2019-03-21
18
+ */
19
+@Data
20
+@EqualsAndHashCode(callSuper = false)
21
+@Accessors(chain = true)
22
+@TableName("ta_collection")
23
+public class TaCollection implements Serializable {
24
+
25
+    private static final long serialVersionUID = 1L;
26
+
27
+    /**
28
+     * 用户ID
29
+     */
30
+    private String customerId;
31
+
32
+    /**
33
+     * 楼盘ID
34
+     */
35
+    private String buildingId;
36
+
37
+    /**
38
+     * 创建时间
39
+     */
40
+    private LocalDateTime createDate;
41
+
42
+
43
+}

+ 3
- 1
whole-estate/src/main/java/com/example/wholeestate/service/IActivityService.java View File

4
 import com.example.wholeestate.common.resp.ResponseBean;
4
 import com.example.wholeestate.common.resp.ResponseBean;
5
 import com.example.wholeestate.model.Activity;
5
 import com.example.wholeestate.model.Activity;
6
 
6
 
7
+import java.util.Date;
8
+
7
 /**
9
 /**
8
  * <p>
10
  * <p>
9
  * 活动表 服务类
11
  * 活动表 服务类
20
      * @param pageSize
22
      * @param pageSize
21
      * @return
23
      * @return
22
      */
24
      */
23
-    ResponseBean getList(Integer pageNum, Integer pageSize);
25
+    ResponseBean getList(Integer pageNum, Integer pageSize, String name, Date beginDate, Date endDate);
24
 
26
 
25
     /**
27
     /**
26
      * 根据 活动id 查询
28
      * 根据 活动id 查询

+ 10
- 0
whole-estate/src/main/java/com/example/wholeestate/service/IAppointmentService.java View File

1
 package com.example.wholeestate.service;
1
 package com.example.wholeestate.service;
2
 
2
 
3
 import com.baomidou.mybatisplus.extension.service.IService;
3
 import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.example.wholeestate.common.resp.ResponseBean;
4
 import com.example.wholeestate.model.Appointment;
5
 import com.example.wholeestate.model.Appointment;
5
 
6
 
6
 /**
7
 /**
13
  */
14
  */
14
 public interface IAppointmentService extends IService<Appointment> {
15
 public interface IAppointmentService extends IService<Appointment> {
15
 
16
 
17
+    /**
18
+     * 根据 openid 查询 预约记录
19
+     * @param openid
20
+     * @param pageNum
21
+     * @param pageSize
22
+     * @return
23
+     */
24
+    ResponseBean getOpenidAppointmentList(String openid, Integer pageNum, Integer pageSize);
25
+
16
 }
26
 }

+ 42
- 0
whole-estate/src/main/java/com/example/wholeestate/service/ITaCollectionService.java View File

1
+package com.example.wholeestate.service;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.example.wholeestate.common.resp.ResponseBean;
5
+import com.example.wholeestate.model.TaCollection;
6
+
7
+/**
8
+ * <p>
9
+ * 收藏表 服务类
10
+ * </p>
11
+ *
12
+ * @author weiximei
13
+ * @since 2019-03-21
14
+ */
15
+public interface ITaCollectionService extends IService<TaCollection> {
16
+
17
+    /**
18
+     * 根据 openid 查询 收藏楼盘记录
19
+     * @param openid
20
+     * @param pageNum
21
+     * @param pageSize
22
+     * @return
23
+     */
24
+    ResponseBean openidCollectionBuilding(String openid, Integer pageNum, Integer pageSize);
25
+
26
+    /**
27
+     * 根据 openid 和 楼盘id 删除收藏列表
28
+     * @param openid
29
+     * @param buildingId
30
+     * @return
31
+     */
32
+    ResponseBean deleteCollection(String openid, String buildingId);
33
+
34
+    /**
35
+     * 根据 openid 和 楼盘id 添加收藏列表
36
+     * @param openid
37
+     * @param buildingId
38
+     * @return
39
+     */
40
+    ResponseBean addCollection(String openid, String buildingId);
41
+
42
+}

+ 8
- 1
whole-estate/src/main/java/com/example/wholeestate/service/impl/ActivityServiceImpl.java View File

11
 import com.example.wholeestate.model.Activity;
11
 import com.example.wholeestate.model.Activity;
12
 import com.example.wholeestate.model.Building;
12
 import com.example.wholeestate.model.Building;
13
 import com.example.wholeestate.service.IActivityService;
13
 import com.example.wholeestate.service.IActivityService;
14
+import org.apache.commons.lang.StringUtils;
14
 import org.springframework.beans.factory.annotation.Autowired;
15
 import org.springframework.beans.factory.annotation.Autowired;
15
 import org.springframework.stereotype.Service;
16
 import org.springframework.stereotype.Service;
16
 
17
 
18
+import java.util.Date;
19
+
17
 /**
20
 /**
18
  * <p>
21
  * <p>
19
  * 活动表 服务实现类
22
  * 活动表 服务实现类
32
     private BuildingMapper buildingMapper;
35
     private BuildingMapper buildingMapper;
33
 
36
 
34
     @Override
37
     @Override
35
-    public ResponseBean getList(Integer pageNum, Integer pageSize) {
38
+    public ResponseBean getList(Integer pageNum, Integer pageSize, String name, Date beginDate, Date endDate) {
36
         ResponseBean responseBean = new ResponseBean();
39
         ResponseBean responseBean = new ResponseBean();
37
 
40
 
38
         Page<Activity> page = new Page<>();
41
         Page<Activity> page = new Page<>();
39
         page.setCurrent(pageNum == null ? 1 : pageNum);
42
         page.setCurrent(pageNum == null ? 1 : pageNum);
40
         page.setSize(pageSize == null ? 10 : pageSize);
43
         page.setSize(pageSize == null ? 10 : pageSize);
41
         QueryWrapper<Activity> queryWrapper = new QueryWrapper<>();
44
         QueryWrapper<Activity> queryWrapper = new QueryWrapper<>();
45
+        queryWrapper.gt("status", -1);
46
+        queryWrapper.like(StringUtils.isNotBlank(name),"title", name);
47
+        queryWrapper.ge(null != beginDate,"begin_date", beginDate);
48
+        queryWrapper.le(null != endDate,"end_date", endDate);
42
         IPage<Activity> activityIPage = activityMapper.selectPage(page, queryWrapper);
49
         IPage<Activity> activityIPage = activityMapper.selectPage(page, queryWrapper);
43
         responseBean.addSuccess(activityIPage);
50
         responseBean.addSuccess(activityIPage);
44
         return responseBean;
51
         return responseBean;

+ 18
- 0
whole-estate/src/main/java/com/example/wholeestate/service/impl/AppointmentServiceImpl.java View File

1
 package com.example.wholeestate.service.impl;
1
 package com.example.wholeestate.service.impl;
2
 
2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
3
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
6
+import com.example.wholeestate.common.resp.ResponseBean;
4
 import com.example.wholeestate.dao.AppointmentMapper;
7
 import com.example.wholeestate.dao.AppointmentMapper;
5
 import com.example.wholeestate.model.Appointment;
8
 import com.example.wholeestate.model.Appointment;
6
 import com.example.wholeestate.service.IAppointmentService;
9
 import com.example.wholeestate.service.IAppointmentService;
10
+import org.springframework.beans.factory.annotation.Autowired;
7
 import org.springframework.stereotype.Service;
11
 import org.springframework.stereotype.Service;
8
 
12
 
9
 /**
13
 /**
17
 @Service
21
 @Service
18
 public class AppointmentServiceImpl extends ServiceImpl<AppointmentMapper, Appointment> implements IAppointmentService {
22
 public class AppointmentServiceImpl extends ServiceImpl<AppointmentMapper, Appointment> implements IAppointmentService {
19
 
23
 
24
+    @Autowired
25
+    private AppointmentMapper appointmentMapper;
26
+
27
+    @Override
28
+    public ResponseBean getOpenidAppointmentList(String openid, Integer pageNum, Integer pageSize) {
29
+        ResponseBean responseBean = new ResponseBean();
30
+        Page<Appointment> page = new Page<>();
31
+        page.setCurrent(pageNum);
32
+        page.setSize(pageSize);
33
+
34
+        IPage<Appointment> openidAppendableList = appointmentMapper.getOpenidAppendableList(page, openid);
35
+        responseBean.addSuccess(openidAppendableList);
36
+        return responseBean;
37
+    }
20
 }
38
 }

+ 73
- 0
whole-estate/src/main/java/com/example/wholeestate/service/impl/TaCollectionServiceImpl.java View File

1
+package com.example.wholeestate.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
+import com.example.wholeestate.common.resp.ResponseBean;
8
+import com.example.wholeestate.dao.CustomerMapper;
9
+import com.example.wholeestate.dao.TaCollectionMapper;
10
+import com.example.wholeestate.model.Building;
11
+import com.example.wholeestate.model.Customer;
12
+import com.example.wholeestate.model.TaCollection;
13
+import com.example.wholeestate.service.ITaCollectionService;
14
+import org.springframework.beans.factory.annotation.Autowired;
15
+import org.springframework.stereotype.Service;
16
+
17
+/**
18
+ * <p>
19
+ * 收藏表 服务实现类
20
+ * </p>
21
+ *
22
+ * @author weiximei
23
+ * @since 2019-03-21
24
+ */
25
+@Service
26
+public class TaCollectionServiceImpl extends ServiceImpl<TaCollectionMapper, TaCollection> implements ITaCollectionService {
27
+
28
+    @Autowired
29
+    private TaCollectionMapper taCollectionMapper;
30
+
31
+    @Autowired
32
+    private CustomerMapper customerMapper;
33
+
34
+    @Override
35
+    public ResponseBean openidCollectionBuilding(String openid, Integer pageNum, Integer pageSize) {
36
+        ResponseBean responseBean = new ResponseBean();
37
+        Page<Building> page = new Page<>();
38
+        page.setCurrent(pageNum);
39
+        page.setSize(pageSize);
40
+        IPage<Building> buildingIPage = taCollectionMapper.openidCollectionBuilding(page, openid);
41
+        responseBean.addSuccess(buildingIPage);
42
+        return responseBean;
43
+    }
44
+
45
+    @Override
46
+    public ResponseBean deleteCollection(String openid, String buildingId) {
47
+        ResponseBean responseBean = new ResponseBean();
48
+        taCollectionMapper.deleteCollection(openid, buildingId);
49
+        responseBean.addSuccess("操作成功!");
50
+        return responseBean;
51
+    }
52
+
53
+    @Override
54
+    public ResponseBean addCollection(String openid, String buildingId) {
55
+        ResponseBean responseBean = new ResponseBean();
56
+
57
+        QueryWrapper<Customer> customerQueryWrapper = new QueryWrapper<>();
58
+        customerQueryWrapper.eq("openid", openid);
59
+        Customer customer = customerMapper.selectOne(customerQueryWrapper);
60
+
61
+        QueryWrapper<TaCollection> taCollectionQueryWrapper = new QueryWrapper<>();
62
+        taCollectionQueryWrapper.eq("customer_id", customer.getCustomerId());
63
+        taCollectionQueryWrapper.eq("building_id", buildingId);
64
+        TaCollection taCollection = taCollectionMapper.selectOne(taCollectionQueryWrapper);
65
+        if (null != taCollection) {
66
+            responseBean.addError("您已收藏过这个楼盘!");
67
+            return responseBean;
68
+        }
69
+
70
+
71
+        return responseBean;
72
+    }
73
+}

+ 0
- 2
whole-estate/src/main/resources/application.yml View File

20
     restart:
20
     restart:
21
       enabled: true #热部署生效
21
       enabled: true #热部署生效
22
       additional-paths: src/main/java #设置重启的目录
22
       additional-paths: src/main/java #设置重启的目录
23
-#  session:
24
-#    store-type: jdbc
25
 mybatis-plus:
23
 mybatis-plus:
26
   mapper-locations: classpath:mapper/*.xml
24
   mapper-locations: classpath:mapper/*.xml
27
   type-aliases-package: com.example.wholeestate.model
25
   type-aliases-package: com.example.wholeestate.model

+ 5
- 0
whole-estate/src/main/resources/mapper/TaCollectionMapper.xml View File

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">
3
+<mapper namespace="com.example.wholeestate.dao.TaCollectionMapper">
4
+
5
+</mapper>