|
@@ -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
|
}
|