weiximei 6 年前
父节点
当前提交
ba9f476a41

+ 47
- 7
whole-estate/src/main/java/com/example/wholeestate/controller/BuildingController.java 查看文件

@@ -11,10 +11,7 @@ import io.swagger.annotations.ApiImplicitParam;
11 11
 import io.swagger.annotations.ApiImplicitParams;
12 12
 import io.swagger.annotations.ApiOperation;
13 13
 import org.springframework.beans.factory.annotation.Autowired;
14
-import org.springframework.web.bind.annotation.RequestBody;
15
-import org.springframework.web.bind.annotation.RequestMapping;
16
-import org.springframework.web.bind.annotation.RequestMethod;
17
-import org.springframework.web.bind.annotation.RestController;
14
+import org.springframework.web.bind.annotation.*;
18 15
 
19 16
 import javax.servlet.http.HttpSession;
20 17
 
@@ -32,17 +29,60 @@ import javax.servlet.http.HttpSession;
32 29
 public class BuildingController extends BaseController {
33 30
 @Autowired
34 31
     private IBuildingService iBuildingService;
35
-    @ApiOperation(value = "楼盘API", notes = "楼盘API")
32
+
33
+    @RequestMapping(value = "/buildingSelectId/{id}", method = RequestMethod.GET)
34
+    @ApiOperation(value = "楼盘详情", notes = "楼盘详情")
35
+    @ApiImplicitParams({
36
+            @ApiImplicitParam(paramType = "path", dataTypeClass=Integer.class, name = "id", value = "楼盘id"),
37
+    })
38
+//    @ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "token")
39
+    public ResponseBean buildingSelectId(@PathVariable(value = "id") Integer id, HttpSession session){
40
+//    SysUser sessionUser= getSessionUser(session);
41
+        ResponseBean  responseBean = iBuildingService.buildingSelectId(id);
42
+        return responseBean;
43
+    }
44
+    @ApiOperation(value = "楼盘列表", notes = "楼盘列表")
36 45
     @ApiImplicitParams({
37 46
             @ApiImplicitParam(paramType = "body",dataType = "String",name = "parameter",value = "pageNum:分页第几页" +
38 47
                     "pageSize:每页长度")
39 48
 
40 49
     })
41 50
     @ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "token")
42
-    @RequestMapping(value = "/buildingList", method = RequestMethod.POST)
51
+    @RequestMapping(value = "/buildinglist", method = RequestMethod.POST)
43 52
     public ResponseBean buildingList(@RequestBody String parameter, HttpSession session){
44
-    SysUser sessionUser= getSessionUser(session);
53
+        SysUser sessionUser= getSessionUser(session);
45 54
         ResponseBean  responseBean = iBuildingService.buildingList(parameter);
46 55
         return responseBean;
47 56
     }
57
+
58
+    @ApiOperation(value = "楼盘修改", notes = "楼盘修改")
59
+    @ApiImplicitParams({
60
+            @ApiImplicitParam(paramType = "body",dataType = "String",name = "parameter",value = "buildingId:楼盘ID,buildingName:楼盘名称," +
61
+                    "name:楼盘别名,price:价格,openingDate:开盘时间,coordinate:项目坐标,propertyType:物业类型,dynamic:最新动态,tel:电话")
62
+
63
+    })
64
+
65
+//    @ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "token")
66
+    @RequestMapping(value = "/building/update", method = RequestMethod.POST)
67
+    public ResponseBean buildingUpdate(@RequestBody String parameter, HttpSession session){
68
+        SysUser sessionUser= getSessionUser(session);
69
+        ResponseBean  responseBean = iBuildingService.buildingUpdate(parameter);
70
+        return responseBean;
71
+    }
72
+
73
+    @ApiOperation(value = "楼盘预约", notes = "楼盘预约")
74
+    @ApiImplicitParams({
75
+            @ApiImplicitParam(paramType = "body",dataType = "String",name = "parameter",value = "pageNum:分页第几页" +
76
+                    "pageSize:每页长度")
77
+
78
+    })
79
+//    @ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "token")
80
+    @RequestMapping(value = "/appointmentlsit", method = RequestMethod.POST)
81
+    public ResponseBean appointmentList(@RequestBody String parameter, HttpSession session){
82
+//        SysUser sessionUser= getSessionUser(session);
83
+        ResponseBean  responseBean = iBuildingService.appointmentList(parameter);
84
+        return responseBean;
85
+    }
86
+
87
+
48 88
 }

+ 24
- 0
whole-estate/src/main/java/com/example/wholeestate/dao/AppointmentMapper.java 查看文件

@@ -0,0 +1,24 @@
1
+package com.example.wholeestate.dao;
2
+
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6
+import com.example.wholeestate.model.Appointment;
7
+
8
+/**
9
+ * <p>
10
+ * 预约记录表 Mapper 接口
11
+ * </p>
12
+ *
13
+ * @author jobob
14
+ * @since 2019-03-20
15
+ */
16
+public interface AppointmentMapper extends BaseMapper<Appointment> {
17
+    /**
18
+     * 预约列表
19
+     * @param page
20
+     * @return
21
+     */
22
+    IPage<Appendable> appendableList(Page<Appendable> page);
23
+
24
+}

+ 8
- 0
whole-estate/src/main/java/com/example/wholeestate/dao/BuildingMapper.java 查看文件

@@ -1,6 +1,8 @@
1 1
 package com.example.wholeestate.dao;
2 2
 
3 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;
4 6
 import com.example.wholeestate.model.Building;
5 7
 
6 8
 /**
@@ -12,5 +14,11 @@ import com.example.wholeestate.model.Building;
12 14
  * @since 2019-03-20
13 15
  */
14 16
 public interface BuildingMapper extends BaseMapper<Building> {
17
+    /**
18
+     * 楼盘列表
19
+     * @param page
20
+     * @return
21
+     */
22
+    IPage<Building> buildingList(Page page);
15 23
 
16 24
 }

+ 72
- 0
whole-estate/src/main/java/com/example/wholeestate/model/Appointment.java 查看文件

@@ -0,0 +1,72 @@
1
+package com.example.wholeestate.model;
2
+
3
+import com.baomidou.mybatisplus.annotation.TableName;
4
+import java.time.LocalDateTime;
5
+import java.io.Serializable;
6
+import lombok.Data;
7
+import lombok.EqualsAndHashCode;
8
+import lombok.experimental.Accessors;
9
+
10
+/**
11
+ * <p>
12
+ * 预约记录表
13
+ * </p>
14
+ *
15
+ * @author jobob
16
+ * @since 2019-03-20
17
+ */
18
+@Data
19
+@EqualsAndHashCode(callSuper = false)
20
+@Accessors(chain = true)
21
+@TableName("ta_appointment")
22
+public class Appointment implements Serializable {
23
+
24
+    private static final long serialVersionUID = 1L;
25
+
26
+    /**
27
+     * 预约ID
28
+     */
29
+    private String appointmentId;
30
+
31
+    /**
32
+     * 楼盘ID
33
+     */
34
+    private String buildingId;
35
+
36
+    /**
37
+     * 用户ID
38
+     */
39
+    private String customerId;
40
+
41
+    /**
42
+     * 预约时间
43
+     */
44
+    private String appointmentDate;
45
+
46
+    /**
47
+     * 姓名
48
+     */
49
+    private String customerName;
50
+
51
+    /**
52
+     * 手机号
53
+     */
54
+    private String phone;
55
+
56
+    /**
57
+     * 备注
58
+     */
59
+    private String remark;
60
+
61
+    /**
62
+     * 0正常,-1删除
63
+     */
64
+    private Integer status;
65
+
66
+    /**
67
+     * 创建时间
68
+     */
69
+    private LocalDateTime createDate;
70
+
71
+
72
+}

+ 4
- 2
whole-estate/src/main/java/com/example/wholeestate/model/Building.java 查看文件

@@ -3,6 +3,8 @@ package com.example.wholeestate.model;
3 3
 import com.baomidou.mybatisplus.annotation.TableName;
4 4
 import java.time.LocalDateTime;
5 5
 import java.io.Serializable;
6
+import java.util.Date;
7
+
6 8
 import lombok.Data;
7 9
 import lombok.EqualsAndHashCode;
8 10
 import lombok.experimental.Accessors;
@@ -26,7 +28,7 @@ public class Building implements Serializable {
26 28
     /**
27 29
      * 楼盘ID
28 30
      */
29
-    private String buildingId;
31
+    private Integer buildingId;
30 32
 
31 33
     /**
32 34
      * 楼盘名称
@@ -46,7 +48,7 @@ public class Building implements Serializable {
46 48
     /**
47 49
      * 开盘时间
48 50
      */
49
-    private LocalDateTime openingDate;
51
+    private Date openingDate;
50 52
 
51 53
     /**
52 54
      * 项目地址

+ 21
- 0
whole-estate/src/main/java/com/example/wholeestate/service/IBuildingService.java 查看文件

@@ -19,4 +19,25 @@ public interface IBuildingService extends IService<Building> {
19 19
      * @return
20 20
      */
21 21
     ResponseBean buildingList(String parameter);
22
+
23
+    /**
24
+     * 楼盘详情
25
+      * @param id
26
+     * @return
27
+     */
28
+    ResponseBean buildingSelectId(Integer id);
29
+
30
+    /**
31
+     * 修改楼盘
32
+     * @param parameter
33
+     * @return
34
+     */
35
+    ResponseBean buildingUpdate(String parameter);
36
+
37
+    /**
38
+     *
39
+     * @param parameter
40
+     * @return
41
+     */
42
+    ResponseBean appointmentList(String parameter);
22 43
 }

+ 93
- 1
whole-estate/src/main/java/com/example/wholeestate/service/impl/BuildingServiceImpl.java 查看文件

@@ -1,13 +1,24 @@
1 1
 package com.example.wholeestate.service.impl;
2 2
 
3 3
 import com.alibaba.fastjson.JSONObject;
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.baomidou.mybatisplus.core.metadata.IPage;
6
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
4 7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5 8
 import com.example.wholeestate.common.resp.ResponseBean;
9
+import com.example.wholeestate.dao.AppointmentMapper;
6 10
 import com.example.wholeestate.dao.BuildingMapper;
7 11
 import com.example.wholeestate.model.Building;
8 12
 import com.example.wholeestate.service.IBuildingService;
13
+import com.fasterxml.jackson.databind.util.ArrayBuilders;
14
+import org.springframework.beans.factory.annotation.Autowired;
9 15
 import org.springframework.stereotype.Service;
10 16
 
17
+import java.time.LocalDateTime;
18
+import java.util.Date;
19
+import java.util.HashMap;
20
+import java.util.List;
21
+
11 22
 /**
12 23
  * <p>
13 24
  * 楼盘表 服务实现类
@@ -18,11 +29,92 @@ import org.springframework.stereotype.Service;
18 29
  */
19 30
 @Service
20 31
 public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> implements IBuildingService {
32
+    @Autowired
33
+    private BuildingMapper buildingMapper;
21 34
 
35
+    @Autowired
36
+    private AppointmentMapper AppointmentMapper;
22 37
     @Override
23 38
     public ResponseBean buildingList(String parameter) {
24 39
         ResponseBean response= new ResponseBean();
25 40
         JSONObject object= JSONObject.parseObject(parameter);
26
-        return null;
41
+
42
+        Integer pageNum = object.getInteger("pageNum");
43
+        Integer pageSize = object.getInteger("pageSize");
44
+
45
+        Page<Building> page = new Page<>();
46
+        page.setSize(pageSize == null ? 10 : pageSize);
47
+        page.setCurrent(pageNum == null ? 1 : pageNum);
48
+         IPage<Building> building= buildingMapper.buildingList(page);
49
+        List<Building> buildingList=building.getRecords();
50
+
51
+        HashMap hashMap= new HashMap<>();
52
+        hashMap.put("list",buildingList);
53
+        hashMap.put("total",building.getTotal());
54
+        hashMap.put("pageNum",building.getCurrent());
55
+        hashMap.put("pageSize",building.getSize());
56
+        response.addSuccess(hashMap);
57
+        return response;
27 58
     }
59
+
60
+    @Override
61
+    public ResponseBean buildingSelectId(Integer id) {
62
+        ResponseBean response= new ResponseBean();
63
+        QueryWrapper<Building> buildingtWrapper = new QueryWrapper<>();
64
+        buildingtWrapper.lambda().eq(Building::getStatus,0);
65
+        Building building= buildingMapper.selectOne(buildingtWrapper);
66
+        response.addSuccess(building);
67
+        return response;
68
+    }
69
+
70
+    @Override
71
+    public ResponseBean buildingUpdate(String parameter) {
72
+        ResponseBean response= new ResponseBean();
73
+
74
+        JSONObject object= JSONObject.parseObject(parameter);
75
+
76
+        Building building = JSONObject.parseObject(parameter,Building.class);
77
+        if (!"".equals(building.getBuildingId())&&null!=building.getBuildingId()){
78
+            response.addError("楼盘名称不能为空");
79
+            return response;
80
+        }
81
+        if (!"".equals(building.getPrice())&&null!=building.getPrice()){
82
+            response.addError("价格不能为空");
83
+            return response;
84
+        }
85
+        if (!"".equals(building.getOpeningDate())&&null!=building.getOpeningDate()){
86
+            response.addError("开盘时间");
87
+            return response;
88
+        }
89
+        building.setOpeningDate(object.getDate("openingDate"));
90
+        building.setCreateDate(LocalDateTime.now());
91
+        buildingMapper.insert(building);
92
+        response.addSuccess("成功");
93
+        return response;
94
+    }
95
+
96
+    @Override
97
+    public ResponseBean appointmentList(String parameter) {
98
+        ResponseBean response= new ResponseBean();
99
+        JSONObject object= JSONObject.parseObject(parameter);
100
+
101
+        Integer pageNum = object.getInteger("pageNum");
102
+        Integer pageSize = object.getInteger("pageSize");
103
+
104
+        Page<Appendable> page = new Page<>();
105
+        page.setSize(pageSize == null ? 10 : pageSize);
106
+        page.setCurrent(pageNum == null ? 1 : pageNum);
107
+        IPage<Appendable> building= AppointmentMapper.appendableList(page);
108
+        List<Appendable> buildingList=building.getRecords();
109
+
110
+        HashMap hashMap= new HashMap<>();
111
+        hashMap.put("list",buildingList);
112
+        hashMap.put("total",building.getTotal());
113
+        hashMap.put("pageNum",building.getCurrent());
114
+        hashMap.put("pageSize",building.getSize());
115
+        response.addSuccess(hashMap);
116
+        return response;
117
+    }
118
+
119
+
28 120
 }

+ 8
- 0
whole-estate/src/main/resources/mapper/AppointmentMapper.xml 查看文件

@@ -0,0 +1,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">
3
+<mapper namespace="com.example.wholeestate.dao.AppointmentMapper">
4
+
5
+    <select id="appendableList" resultType="com.example.wholeestate.model.Appointment">
6
+        SELECT * FROM ta_appointment
7
+    </select>
8
+</mapper>

+ 3
- 1
whole-estate/src/main/resources/mapper/BuildingMapper.xml 查看文件

@@ -1,5 +1,7 @@
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.example.wholeestate.dao.BuildingMapper">
4
-
4
+    <select id="buildingList" resultType="com.example.wholeestate.model.Building">
5
+        SELECT * FROM ta_building
6
+    </select>
5 7
 </mapper>