|
@@ -1,5 +1,6 @@
|
1
|
1
|
package com.huiju.estateagents.controller;
|
2
|
2
|
|
|
3
|
+import com.alibaba.fastjson.JSONObject;
|
3
|
4
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
4
|
5
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
5
|
6
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -7,6 +8,8 @@ import com.huiju.estateagents.base.BaseController;
|
7
|
8
|
import com.huiju.estateagents.base.ResponseBean;
|
8
|
9
|
import com.huiju.estateagents.entity.TaPreselectionRecord;
|
9
|
10
|
import com.huiju.estateagents.service.ITaPreselectionRecordService;
|
|
11
|
+import org.apache.commons.lang3.StringUtils;
|
|
12
|
+import org.apache.ibatis.annotations.Param;
|
10
|
13
|
import org.slf4j.Logger;
|
11
|
14
|
import org.slf4j.LoggerFactory;
|
12
|
15
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -14,8 +17,8 @@ import org.springframework.web.bind.annotation.*;
|
14
|
17
|
|
15
|
18
|
/**
|
16
|
19
|
* <p>
|
17
|
|
- * 预选记录表 前端控制器
|
18
|
|
- * </p>
|
|
20
|
+ * 预选记录表 前端控制器
|
|
21
|
+ * </p>
|
19
|
22
|
*
|
20
|
23
|
* @author jobob
|
21
|
24
|
* @since 2020-02-10
|
|
@@ -32,25 +35,26 @@ public class TaPreselectionRecordController extends BaseController {
|
32
|
35
|
|
33
|
36
|
/**
|
34
|
37
|
* 分页查询列表
|
|
38
|
+ *
|
35
|
39
|
* @param pageNum
|
36
|
40
|
* @param pageSize
|
37
|
41
|
* @return
|
38
|
42
|
*/
|
39
|
|
- @RequestMapping(value="/taPreselectionRecord",method= RequestMethod.GET)
|
40
|
|
- public ResponseBean taPreselectionRecordList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
41
|
|
- @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
|
|
43
|
+ @RequestMapping(value = "/taPreselectionRecord", method = RequestMethod.GET)
|
|
44
|
+ public ResponseBean taPreselectionRecordList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
45
|
+ @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
42
|
46
|
ResponseBean responseBean = new ResponseBean();
|
43
|
47
|
try {
|
44
|
48
|
//使用分页插件
|
45
|
|
- IPage<TaPreselectionRecord> pg = new Page<>(pageNum, pageSize);
|
|
49
|
+ IPage<TaPreselectionRecord> pg = new Page<>(pageNum, pageSize);
|
46
|
50
|
QueryWrapper<TaPreselectionRecord> queryWrapper = new QueryWrapper<>();
|
47
|
51
|
queryWrapper.orderByDesc("create_date");
|
48
|
52
|
|
49
|
53
|
IPage<TaPreselectionRecord> result = iTaPreselectionRecordService.page(pg, queryWrapper);
|
50
|
54
|
responseBean.addSuccess(result);
|
51
|
|
- }catch (Exception e){
|
|
55
|
+ } catch (Exception e) {
|
52
|
56
|
e.printStackTrace();
|
53
|
|
- logger.error("taPreselectionRecordList -=- {}",e.toString());
|
|
57
|
+ logger.error("taPreselectionRecordList -=- {}", e.toString());
|
54
|
58
|
responseBean.addError(e.getMessage());
|
55
|
59
|
}
|
56
|
60
|
return responseBean;
|
|
@@ -58,21 +62,43 @@ public class TaPreselectionRecordController extends BaseController {
|
58
|
62
|
|
59
|
63
|
/**
|
60
|
64
|
* 保存对象
|
|
65
|
+ *
|
61
|
66
|
* @param taPreselectionRecord 实体对象
|
62
|
67
|
* @return
|
63
|
68
|
*/
|
64
|
|
- @RequestMapping(value="/taPreselectionRecord",method= RequestMethod.POST)
|
65
|
|
- public ResponseBean taPreselectionRecordAdd(@RequestBody TaPreselectionRecord taPreselectionRecord){
|
|
69
|
+ @RequestMapping(value = "/taPreselectionRecord", method = RequestMethod.POST)
|
|
70
|
+ public ResponseBean taPreselectionRecordAdd(@RequestBody TaPreselectionRecord taPreselectionRecord) {
|
66
|
71
|
ResponseBean responseBean = new ResponseBean();
|
|
72
|
+
|
|
73
|
+ logger.info("taPreselectionRecordAdd 接收参数,taPreselectionRecord:{}", JSONObject.toJSONString(taPreselectionRecord));
|
|
74
|
+
|
67
|
75
|
try {
|
68
|
|
- if (iTaPreselectionRecordService.save(taPreselectionRecord)){
|
|
76
|
+
|
|
77
|
+ // 校验参数
|
|
78
|
+ if (StringUtils.isBlank(taPreselectionRecord.getHouseId()) && StringUtils.isBlank(taPreselectionRecord.getPersonId()) &&
|
|
79
|
+ taPreselectionRecord.getOrgId() == null) {
|
|
80
|
+ logger.info("taPreselectionRecordAdd 参数错误");
|
|
81
|
+ responseBean.addError("参数错误");
|
|
82
|
+ return responseBean;
|
|
83
|
+ }
|
|
84
|
+
|
|
85
|
+ // 校验用户是否已经预选房源
|
|
86
|
+ TaPreselectionRecord record = iTaPreselectionRecordService
|
|
87
|
+ .checkPreselect(taPreselectionRecord.getPersonId(), taPreselectionRecord.getHouseId());
|
|
88
|
+ if (record != null) {
|
|
89
|
+ logger.info("taPreselectionRecordAdd 用户已经预选该房源");
|
|
90
|
+ responseBean.addError("您已经预选过该房源");
|
|
91
|
+ return responseBean;
|
|
92
|
+ }
|
|
93
|
+
|
|
94
|
+ if (iTaPreselectionRecordService.save(taPreselectionRecord)) {
|
69
|
95
|
responseBean.addSuccess(taPreselectionRecord);
|
70
|
|
- }else {
|
|
96
|
+ } else {
|
71
|
97
|
responseBean.addError("fail");
|
72
|
98
|
}
|
73
|
|
- }catch (Exception e){
|
|
99
|
+ } catch (Exception e) {
|
74
|
100
|
e.printStackTrace();
|
75
|
|
- logger.error("taPreselectionRecordAdd -=- {}",e.toString());
|
|
101
|
+ logger.error("taPreselectionRecordAdd -=- {}", e.toString());
|
76
|
102
|
responseBean.addError(e.getMessage());
|
77
|
103
|
}
|
78
|
104
|
return responseBean;
|
|
@@ -80,21 +106,22 @@ public class TaPreselectionRecordController extends BaseController {
|
80
|
106
|
|
81
|
107
|
/**
|
82
|
108
|
* 根据id删除对象
|
83
|
|
- * @param id 实体ID
|
|
109
|
+ *
|
|
110
|
+ * @param id 实体ID
|
84
|
111
|
*/
|
85
|
112
|
@ResponseBody
|
86
|
|
- @RequestMapping(value="/taPreselectionRecord/{id}", method= RequestMethod.DELETE)
|
87
|
|
- public ResponseBean taPreselectionRecordDelete(@PathVariable Integer id){
|
|
113
|
+ @RequestMapping(value = "/taPreselectionRecord/{id}", method = RequestMethod.DELETE)
|
|
114
|
+ public ResponseBean taPreselectionRecordDelete(@PathVariable Integer id) {
|
88
|
115
|
ResponseBean responseBean = new ResponseBean();
|
89
|
116
|
try {
|
90
|
|
- if(iTaPreselectionRecordService.removeById(id)){
|
|
117
|
+ if (iTaPreselectionRecordService.removeById(id)) {
|
91
|
118
|
responseBean.addSuccess("success");
|
92
|
|
- }else {
|
|
119
|
+ } else {
|
93
|
120
|
responseBean.addError("fail");
|
94
|
121
|
}
|
95
|
|
- }catch (Exception e){
|
|
122
|
+ } catch (Exception e) {
|
96
|
123
|
e.printStackTrace();
|
97
|
|
- logger.error("taPreselectionRecordDelete -=- {}",e.toString());
|
|
124
|
+ logger.error("taPreselectionRecordDelete -=- {}", e.toString());
|
98
|
125
|
responseBean.addError(e.getMessage());
|
99
|
126
|
}
|
100
|
127
|
return responseBean;
|
|
@@ -102,23 +129,24 @@ public class TaPreselectionRecordController extends BaseController {
|
102
|
129
|
|
103
|
130
|
/**
|
104
|
131
|
* 修改对象
|
105
|
|
- * @param id 实体ID
|
|
132
|
+ *
|
|
133
|
+ * @param id 实体ID
|
106
|
134
|
* @param taPreselectionRecord 实体对象
|
107
|
135
|
* @return
|
108
|
136
|
*/
|
109
|
|
- @RequestMapping(value="/taPreselectionRecord/{id}",method= RequestMethod.PUT)
|
|
137
|
+ @RequestMapping(value = "/taPreselectionRecord/{id}", method = RequestMethod.PUT)
|
110
|
138
|
public ResponseBean taPreselectionRecordUpdate(@PathVariable Integer id,
|
111
|
|
- @RequestBody TaPreselectionRecord taPreselectionRecord){
|
|
139
|
+ @RequestBody TaPreselectionRecord taPreselectionRecord) {
|
112
|
140
|
ResponseBean responseBean = new ResponseBean();
|
113
|
141
|
try {
|
114
|
|
- if (iTaPreselectionRecordService.updateById(taPreselectionRecord)){
|
|
142
|
+ if (iTaPreselectionRecordService.updateById(taPreselectionRecord)) {
|
115
|
143
|
responseBean.addSuccess(taPreselectionRecord);
|
116
|
|
- }else {
|
|
144
|
+ } else {
|
117
|
145
|
responseBean.addError("fail");
|
118
|
146
|
}
|
119
|
|
- }catch (Exception e){
|
|
147
|
+ } catch (Exception e) {
|
120
|
148
|
e.printStackTrace();
|
121
|
|
- logger.error("taPreselectionRecordUpdate -=- {}",e.toString());
|
|
149
|
+ logger.error("taPreselectionRecordUpdate -=- {}", e.toString());
|
122
|
150
|
responseBean.addError(e.getMessage());
|
123
|
151
|
}
|
124
|
152
|
return responseBean;
|
|
@@ -126,16 +154,78 @@ public class TaPreselectionRecordController extends BaseController {
|
126
|
154
|
|
127
|
155
|
/**
|
128
|
156
|
* 根据id查询对象
|
129
|
|
- * @param id 实体ID
|
|
157
|
+ *
|
|
158
|
+ * @param id 实体ID
|
130
|
159
|
*/
|
131
|
|
- @RequestMapping(value="/taPreselectionRecord/{id}",method= RequestMethod.GET)
|
132
|
|
- public ResponseBean taPreselectionRecordGet(@PathVariable Integer id){
|
|
160
|
+ @RequestMapping(value = "/taPreselectionRecord/{id}", method = RequestMethod.GET)
|
|
161
|
+ public ResponseBean taPreselectionRecordGet(@PathVariable Integer id) {
|
133
|
162
|
ResponseBean responseBean = new ResponseBean();
|
134
|
163
|
try {
|
135
|
164
|
responseBean.addSuccess(iTaPreselectionRecordService.getById(id));
|
136
|
|
- }catch (Exception e){
|
|
165
|
+ } catch (Exception e) {
|
137
|
166
|
e.printStackTrace();
|
138
|
|
- logger.error("taPreselectionRecordDelete -=- {}",e.toString());
|
|
167
|
+ logger.error("taPreselectionRecordDelete -=- {}", e.toString());
|
|
168
|
+ responseBean.addError(e.getMessage());
|
|
169
|
+ }
|
|
170
|
+ return responseBean;
|
|
171
|
+ }
|
|
172
|
+
|
|
173
|
+ /**
|
|
174
|
+ * 取消房源预选
|
|
175
|
+ *
|
|
176
|
+ * @param personId 用户ID
|
|
177
|
+ * @return
|
|
178
|
+ */
|
|
179
|
+ @RequestMapping("/wx/taPreselectionRecordCancel")
|
|
180
|
+ public ResponseBean taPreselectionRecordCancel(@RequestParam("personId") String personId,
|
|
181
|
+ @RequestParam("houseId") String houseId) {
|
|
182
|
+ ResponseBean responseBean = new ResponseBean();
|
|
183
|
+ try {
|
|
184
|
+ responseBean.addSuccess(iTaPreselectionRecordService.taPreselectionRecordCancel(personId, houseId));
|
|
185
|
+ } catch (Exception e) {
|
|
186
|
+ logger.error("taPreselectionRecordCancel -=- {}", e.toString());
|
|
187
|
+ responseBean.addError(e.getMessage());
|
|
188
|
+ }
|
|
189
|
+ return responseBean;
|
|
190
|
+ }
|
|
191
|
+
|
|
192
|
+ /**
|
|
193
|
+ * 获取当前用户预选记录
|
|
194
|
+ *
|
|
195
|
+ * @param pageNum 页码
|
|
196
|
+ * @param pageSize 分页大小
|
|
197
|
+ * @param personId 用户ID
|
|
198
|
+ * @return
|
|
199
|
+ */
|
|
200
|
+ @RequestMapping(value = "/wx/listPreselectionRecord", method = RequestMethod.POST)
|
|
201
|
+ public ResponseBean listPreselectionRecord(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
202
|
+ @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
|
|
203
|
+ @RequestParam("personId") String personId) {
|
|
204
|
+ ResponseBean responseBean = new ResponseBean();
|
|
205
|
+ try {
|
|
206
|
+ responseBean.addSuccess(iTaPreselectionRecordService.listPreselectionRecord(pageNum, pageSize, personId));
|
|
207
|
+ } catch (Exception e) {
|
|
208
|
+ logger.error("listPreselectionRecord -=- {}", e.toString());
|
|
209
|
+ responseBean.addError(e.getMessage());
|
|
210
|
+ }
|
|
211
|
+ return responseBean;
|
|
212
|
+ }
|
|
213
|
+
|
|
214
|
+ /**
|
|
215
|
+ * 校验用户是否已经预选该房源
|
|
216
|
+ *
|
|
217
|
+ * @param personId 用户ID
|
|
218
|
+ * @param houseId 房源ID
|
|
219
|
+ * @return
|
|
220
|
+ */
|
|
221
|
+ @RequestMapping(value = "/wx/checkPreselect", method = RequestMethod.POST)
|
|
222
|
+ public ResponseBean checkPreselect(@RequestParam("personId") String personId,
|
|
223
|
+ @RequestParam("houseId") String houseId) {
|
|
224
|
+ ResponseBean responseBean = new ResponseBean();
|
|
225
|
+ try {
|
|
226
|
+ responseBean.addSuccess(iTaPreselectionRecordService.checkPreselect(personId, houseId));
|
|
227
|
+ } catch (Exception e) {
|
|
228
|
+ logger.error("checkPreselect -=- {}", e.toString());
|
139
|
229
|
responseBean.addError(e.getMessage());
|
140
|
230
|
}
|
141
|
231
|
return responseBean;
|