|
@@ -1,380 +1,384 @@
|
1
|
|
-package com.huiju.estateagents.controller;
|
2
|
|
-
|
3
|
|
-
|
4
|
|
-import com.alibaba.fastjson.JSONObject;
|
5
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
6
|
|
-import com.huiju.estateagents.base.ResponseBean;
|
7
|
|
-import com.huiju.estateagents.common.CommConstant;
|
8
|
|
-import com.huiju.estateagents.common.JWTUtils;
|
9
|
|
-import com.huiju.estateagents.entity.TaBuildingDynamic;
|
10
|
|
-import com.huiju.estateagents.entity.TaPerson;
|
11
|
|
-import com.huiju.estateagents.entity.TaPersonBuilding;
|
12
|
|
-import com.huiju.estateagents.service.ITaPersonService;
|
13
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
14
|
|
-import org.springframework.web.bind.annotation.*;
|
15
|
|
-
|
16
|
|
-import com.huiju.estateagents.base.BaseController;
|
17
|
|
-
|
18
|
|
-import javax.servlet.http.HttpServletRequest;
|
19
|
|
-import java.util.ArrayList;
|
20
|
|
-import java.util.HashMap;
|
21
|
|
-import java.util.List;
|
22
|
|
-import java.util.Map;
|
23
|
|
-
|
24
|
|
-/**
|
25
|
|
- * <p>
|
26
|
|
- * 人员表 前端控制器
|
27
|
|
- * </p>
|
28
|
|
- *
|
29
|
|
- * @author jobob
|
30
|
|
- * @since 2019-05-10
|
31
|
|
- */
|
32
|
|
-@RestController
|
33
|
|
-@RequestMapping("/api")
|
34
|
|
-public class TaPersonController extends BaseController {
|
35
|
|
- @Autowired
|
36
|
|
- ITaPersonService taPersonService;
|
37
|
|
-
|
38
|
|
- /**
|
39
|
|
- *
|
40
|
|
- * 因为人员表是集合系统的所有种类的用户,包含了各种角色。因此各种角色的操作都在本 controller 中完成
|
41
|
|
- * 以下是置业顾问卡片内容
|
42
|
|
- *
|
43
|
|
- */
|
44
|
|
-
|
45
|
|
- /**
|
46
|
|
- * 获取卡片列表
|
47
|
|
- * @param pageNumber
|
48
|
|
- * @param pageSize
|
49
|
|
- * @return
|
50
|
|
- */
|
51
|
|
- @GetMapping("/wx/cards")
|
52
|
|
- public ResponseBean getCardList(@RequestParam(defaultValue = "1") int pageNumber,
|
53
|
|
- @RequestParam(defaultValue = "10") int pageSize,
|
54
|
|
- @RequestParam(defaultValue = "false") boolean mine,HttpServletRequest request) {
|
55
|
|
- if (pageNumber < 0 || pageSize < 0) {
|
56
|
|
- return ResponseBean.error("分页参数不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
57
|
|
- }
|
58
|
|
- if (mine){
|
59
|
|
- String openid = JWTUtils.getSubject(request);
|
60
|
|
- List<TaPerson> taPersons = taPersonService.getPersonsByOpenId(openid);
|
61
|
|
- if (null == taPersons || taPersons.size() != 1) {
|
62
|
|
- return ResponseBean.error("验证人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
|
63
|
|
- }
|
64
|
|
- TaPerson person = taPersons.get(0);
|
65
|
|
- IPage<Map<String, Object>> result = taPersonService.getSavedConsaultants(pageNumber,pageSize,person.getPersonId());
|
66
|
|
- return ResponseBean.success(result);
|
67
|
|
- }else {
|
68
|
|
- IPage<Map<String, Object>> result = taPersonService.getCardList(pageNumber, pageSize);
|
69
|
|
- return ResponseBean.success(result);
|
70
|
|
- }
|
71
|
|
-
|
72
|
|
-
|
73
|
|
- }
|
74
|
|
-
|
75
|
|
- /**
|
76
|
|
- * 绑定卡片
|
77
|
|
- * @param paramStr
|
78
|
|
- * @return
|
79
|
|
- */
|
80
|
|
- @PostMapping("/wx/cards/apply")
|
81
|
|
- public ResponseBean applyCard(@RequestBody String paramStr, HttpServletRequest request) {
|
82
|
|
- JSONObject params = JSONObject.parseObject(paramStr);
|
83
|
|
- String phone = (String) params.get("phone");
|
84
|
|
- String pass = (String) params.get("pass");
|
85
|
|
- String openid = JWTUtils.getSubject(request);
|
86
|
|
-
|
87
|
|
- if (isEmpty(phone) || isEmpty(pass)) {
|
88
|
|
- return ResponseBean.error("参数不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
89
|
|
- }
|
90
|
|
-
|
91
|
|
- ResponseBean resp = taPersonService.checkPhoneAndPass(phone, pass);
|
92
|
|
-
|
93
|
|
- // 成功返回空数据
|
94
|
|
- if (resp.getCode() != ResponseBean.CODE_SUCCESS) {
|
95
|
|
- return resp;
|
96
|
|
- }
|
97
|
|
-
|
98
|
|
- return taPersonService.bindCard(phone, pass, openid);
|
99
|
|
- }
|
100
|
|
-
|
101
|
|
- /**
|
102
|
|
- * 获取名片详情
|
103
|
|
- * @param id
|
104
|
|
- * @return
|
105
|
|
- */
|
106
|
|
- @GetMapping("/wx/cards/{id}")
|
107
|
|
- public ResponseBean getCardDetail(@PathVariable String id, HttpServletRequest request) {
|
108
|
|
- if (isEmpty(id)) {
|
109
|
|
- return ResponseBean.error("参数不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
110
|
|
- }
|
111
|
|
-
|
112
|
|
- String openid = JWTUtils.getSubject(request);
|
113
|
|
-
|
114
|
|
- return taPersonService.getCardDetail(openid, id);
|
115
|
|
- }
|
116
|
|
-
|
117
|
|
- /**
|
118
|
|
- * 找回密码
|
119
|
|
- * @param plat 平台类型 wx 是微信相关, admin 是后台管理系统
|
120
|
|
- * @param paramStr
|
121
|
|
- * @return
|
122
|
|
- */
|
123
|
|
- @PostMapping("/{plat}/resetPass")
|
124
|
|
- public ResponseBean resetPassword(@PathVariable String plat, @RequestBody String paramStr) {
|
125
|
|
- JSONObject params = JSONObject.parseObject(paramStr);
|
126
|
|
- String phone = (String) params.get("phone");
|
127
|
|
- String code = (String) params.get("code");
|
128
|
|
- String pass = (String) params.get("pass");
|
129
|
|
-
|
130
|
|
- if (isEmpty(phone) || isEmpty(code) || isEmpty(pass)) {
|
131
|
|
- return ResponseBean.error("参数不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
132
|
|
- }
|
133
|
|
-
|
134
|
|
- // todo
|
135
|
|
- // 验证 验证码是否正确
|
136
|
|
- if (code != "1234") {
|
137
|
|
- return ResponseBean.error("验证码不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
138
|
|
- }
|
139
|
|
-
|
140
|
|
- return taPersonService.resetPassword(phone, pass, plat);
|
141
|
|
- }
|
142
|
|
-
|
143
|
|
-
|
144
|
|
- /**
|
145
|
|
- *
|
146
|
|
- * 以下是经纪人部分
|
147
|
|
- *
|
148
|
|
- */
|
149
|
|
-
|
150
|
|
-
|
151
|
|
- /**
|
152
|
|
- * 注册经纪人
|
153
|
|
- * @param paramStr
|
154
|
|
- * @param request
|
155
|
|
- * @return
|
156
|
|
- */
|
157
|
|
- @PostMapping("/wx/register")
|
158
|
|
- public ResponseBean resgiteAgent(@RequestBody String paramStr, HttpServletRequest request) {
|
159
|
|
- JSONObject params = JSONObject.parseObject(paramStr);
|
160
|
|
- String name = (String) params.get("name");
|
161
|
|
- String phone = (String) params.get("phone");
|
162
|
|
- Integer sex = (Integer) params.get("sex");
|
163
|
|
- String explain = (String) params.get("explain");
|
164
|
|
-
|
165
|
|
- if (isEmpty(name) || isEmpty(phone) || isEmpty(explain)) {
|
166
|
|
- return ResponseBean.error("请检查部分参数不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
167
|
|
- }
|
168
|
|
-
|
169
|
|
- // 当前人员
|
170
|
|
- String openid = JWTUtils.getSubject(request);
|
171
|
|
-
|
172
|
|
- return taPersonService.resgiteAgent(name, phone, sex, explain, openid);
|
173
|
|
- }
|
174
|
|
-
|
175
|
|
- /**
|
176
|
|
- * 生成海报
|
177
|
|
- * @param paramStr
|
178
|
|
- * @param request
|
179
|
|
- * @return
|
180
|
|
- */
|
181
|
|
- @PostMapping("/wx/poster")
|
182
|
|
- public ResponseBean genPoster(@RequestBody String paramStr, HttpServletRequest request) {
|
183
|
|
- return null;
|
184
|
|
- }
|
185
|
|
-
|
186
|
|
-
|
187
|
|
- /**
|
188
|
|
- *
|
189
|
|
- * 以下是个人中心部分
|
190
|
|
- *
|
191
|
|
- */
|
192
|
|
-
|
193
|
|
- /**
|
194
|
|
- * 获取个人信息
|
195
|
|
- * @param request
|
196
|
|
- * @return
|
197
|
|
- */
|
198
|
|
- @GetMapping("/wx/user/info")
|
199
|
|
- public ResponseBean getUserInfo(HttpServletRequest request) {
|
200
|
|
- String openid = JWTUtils.getSubject(request);
|
201
|
|
-
|
202
|
|
- return taPersonService.getWxUser(openid);
|
203
|
|
- }
|
204
|
|
-
|
205
|
|
- /**
|
206
|
|
- * 个人签到
|
207
|
|
- * @param request
|
208
|
|
- * @return
|
209
|
|
- */
|
210
|
|
- @PostMapping("/wx/user/signin")
|
211
|
|
- public ResponseBean userSign(HttpServletRequest request) {
|
212
|
|
- String openid = JWTUtils.getSubject(request);
|
213
|
|
-
|
214
|
|
- return taPersonService.getWxUserSign(openid);
|
215
|
|
- }
|
216
|
|
-
|
217
|
|
-
|
218
|
|
- /**
|
219
|
|
- *
|
220
|
|
- *
|
221
|
|
- * 以下是系统用户管理
|
222
|
|
- *
|
223
|
|
- */
|
224
|
|
-
|
225
|
|
- /**
|
226
|
|
- * 用户手机号登录
|
227
|
|
- * @param paramStr
|
228
|
|
- * @return
|
229
|
|
- */
|
230
|
|
- @PostMapping("/admin/signin")
|
231
|
|
- public ResponseBean signin(@RequestBody String paramStr) {
|
232
|
|
- JSONObject params = JSONObject.parseObject(paramStr);
|
233
|
|
- if (params == null) {
|
234
|
|
- return ResponseBean.error("非法参数", ResponseBean.ERROR_MISSING_PARAMS);
|
235
|
|
- }
|
236
|
|
-
|
237
|
|
- String userPhone = params.getString("phone");
|
238
|
|
- String userCaptcha = params.getString("captcha");
|
239
|
|
-
|
240
|
|
- // todo
|
241
|
|
- if (!"1234".equals(userCaptcha)) {
|
242
|
|
- return ResponseBean.error("验证码不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
243
|
|
- }
|
244
|
|
-
|
245
|
|
- TaPerson taPerson = taPersonService.getPersonByTel(userPhone);
|
246
|
|
- if (taPerson == null) {
|
247
|
|
- return ResponseBean.error("手机号不存在", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
248
|
|
- }
|
249
|
|
-
|
250
|
|
- if (taPerson.getStatus() != CommConstant.STATUS_NORMAL) {
|
251
|
|
- return ResponseBean.error("用户状态异常", ResponseBean.ERROR_UNAVAILABLE);
|
252
|
|
- }
|
253
|
|
-
|
254
|
|
- String token = JWTUtils.newToken(taPerson.getPersonId());
|
255
|
|
-
|
256
|
|
- Map<String, Object> result = new HashMap<>();
|
257
|
|
- result.put("token", token);
|
258
|
|
- result.put("person", taPerson);
|
259
|
|
-
|
260
|
|
- return ResponseBean.success(result);
|
261
|
|
- }
|
262
|
|
-
|
263
|
|
- /**
|
264
|
|
- * 获取当前用户
|
265
|
|
- * @param request
|
266
|
|
- * @return
|
267
|
|
- */
|
268
|
|
- @GetMapping("/admin/user/current")
|
269
|
|
- public ResponseBean getCurrentPerson(HttpServletRequest request) {
|
270
|
|
- String personId = JWTUtils.getSubject(request);
|
271
|
|
- TaPerson taPerson = taPersonService.getById(personId);
|
272
|
|
- if (null == taPerson || taPerson.getStatus() != CommConstant.STATUS_NORMAL) {
|
273
|
|
- return ResponseBean.error("用户状态异常", ResponseBean.ERROR_AUTH_EXPIRED);
|
274
|
|
- }
|
275
|
|
-
|
276
|
|
- return ResponseBean.success(taPerson);
|
277
|
|
- }
|
278
|
|
-
|
279
|
|
- @GetMapping("/admin/consultant")
|
280
|
|
- public ResponseBean getConsultantList(
|
281
|
|
- Integer pageNumber,
|
282
|
|
- Integer pageSize,
|
283
|
|
- String name,
|
284
|
|
- String phone
|
285
|
|
- ) {
|
286
|
|
- if (null == pageNumber) pageNumber = 1;
|
287
|
|
- if (null == pageSize) pageSize = 10;
|
288
|
|
-
|
289
|
|
- IPage<TaPerson> taPersonIPage = taPersonService.getPersonList(pageNumber, pageSize, CommConstant.PERSON_REALTY_CONSULTANT, name, phone);
|
290
|
|
- return ResponseBean.success(taPersonIPage);
|
291
|
|
- }
|
292
|
|
-
|
293
|
|
- @GetMapping("/admin/consultant/{id}")
|
294
|
|
- public ResponseBean getConsultant(@PathVariable String id) {
|
295
|
|
- TaPerson taPerson = taPersonService.getById(id);
|
296
|
|
-
|
297
|
|
- List<TaPersonBuilding> buildings = taPersonService.getPersonBuildings(id);
|
298
|
|
- if (null != buildings && buildings.size() > 0) {
|
299
|
|
- List<String> projects = new ArrayList<>();
|
300
|
|
- for (TaPersonBuilding b : buildings) {
|
301
|
|
- projects.add(b.getBuildingId());
|
302
|
|
- }
|
303
|
|
- taPerson.setProjects(projects);
|
304
|
|
- }
|
305
|
|
-
|
306
|
|
- return ResponseBean.success(taPerson);
|
307
|
|
- }
|
308
|
|
-
|
309
|
|
- @PostMapping("/admin/consultant")
|
310
|
|
- public ResponseBean newConsultant(@RequestBody String paramStr) {
|
311
|
|
- return taPersonService.newConsultant(paramStr);
|
312
|
|
- }
|
313
|
|
-
|
314
|
|
- @PutMapping("/admin/consultant/{id}")
|
315
|
|
- public ResponseBean editConsultant(@PathVariable String id, @RequestBody String paramStr) {
|
316
|
|
- return taPersonService.editConsultant(id, paramStr);
|
317
|
|
- }
|
318
|
|
-
|
319
|
|
- boolean isEmpty(String str) {
|
320
|
|
- return null == str || "".equals(str.trim());
|
321
|
|
- }
|
322
|
|
-
|
323
|
|
- /**
|
324
|
|
-// * 获取收藏置业顾问列表
|
325
|
|
-// * @param pageNumber
|
326
|
|
-// * @param pageSize
|
327
|
|
-// * @return
|
328
|
|
-// */
|
329
|
|
-// @GetMapping("/wx/savedPerson")
|
330
|
|
-// public ResponseBean getSavedConsaultants(@RequestParam(defaultValue = "1") int pageNumber,
|
331
|
|
-// @RequestParam(defaultValue = "10") int pageSize,HttpServletRequest request) {
|
332
|
|
-// String openid = JWTUtils.getSubject(request);
|
333
|
|
-// List<TaPerson> taPersons = taPersonService.getPersonsByOpenId(openid);
|
334
|
|
-// if (null == taPersons || taPersons.size() != 1) {
|
335
|
|
-// return ResponseBean.error("验证人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
|
336
|
|
-// }
|
337
|
|
-// TaPerson person = taPersons.get(0);
|
338
|
|
-// if (pageNumber < 0 || pageSize < 0) {
|
339
|
|
-// return ResponseBean.error("分页参数不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
340
|
|
-// }
|
341
|
|
-// try {
|
342
|
|
-// IPage<TaPerson> result = taPersonService.getSavedConsaultants(pageNumber,pageSize,person.getPersonId());
|
343
|
|
-// return ResponseBean.success(result);
|
344
|
|
-// }catch (Exception e){
|
345
|
|
-// e.printStackTrace();
|
346
|
|
-// return ResponseBean.error("查询失败", ResponseBean.ERROR_UNAVAILABLE);
|
347
|
|
-// }
|
348
|
|
-//
|
349
|
|
-// }
|
350
|
|
- /**
|
351
|
|
- * 获取我参加过的活动列表
|
352
|
|
- * @param pageNumber
|
353
|
|
- * @param pageSize
|
354
|
|
- * @return
|
355
|
|
- */
|
356
|
|
- @GetMapping("/wx/joinedActivity/")
|
357
|
|
- public ResponseBean getJoinedActivity(@RequestParam(defaultValue = "1") int pageNumber,
|
358
|
|
- @RequestParam(defaultValue = "10") int pageSize,HttpServletRequest request){
|
359
|
|
- String openid = JWTUtils.getSubject(request);
|
360
|
|
- List<TaPerson> taPersons = taPersonService.getPersonsByOpenId(openid);
|
361
|
|
- if (null == taPersons || taPersons.size() != 1) {
|
362
|
|
- return ResponseBean.error("验证人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
|
363
|
|
- }
|
364
|
|
- TaPerson person = taPersons.get(0);
|
365
|
|
-
|
366
|
|
- if (pageNumber < 0 || pageSize < 0) {
|
367
|
|
- return ResponseBean.error("分页参数不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
368
|
|
- }
|
369
|
|
- try {
|
370
|
|
- IPage<TaBuildingDynamic> result = taPersonService.getJoinedActivity(pageNumber,pageSize,person.getPhone(),"");
|
371
|
|
- return ResponseBean.success(result);
|
372
|
|
- }catch (Exception e){
|
373
|
|
- e.printStackTrace();
|
374
|
|
- return ResponseBean.error("查询失败", ResponseBean.ERROR_UNAVAILABLE);
|
375
|
|
- }
|
376
|
|
-
|
377
|
|
- }
|
378
|
|
-
|
379
|
|
-
|
380
|
|
-}
|
|
1
|
+package com.huiju.estateagents.controller;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+import com.alibaba.fastjson.JSONObject;
|
|
5
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
6
|
+import com.huiju.estateagents.base.ResponseBean;
|
|
7
|
+import com.huiju.estateagents.common.CommConstant;
|
|
8
|
+import com.huiju.estateagents.common.JWTUtils;
|
|
9
|
+import com.huiju.estateagents.entity.TaBuildingDynamic;
|
|
10
|
+import com.huiju.estateagents.entity.TaPerson;
|
|
11
|
+import com.huiju.estateagents.entity.TaPersonBuilding;
|
|
12
|
+import com.huiju.estateagents.service.ITaPersonService;
|
|
13
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
14
|
+import org.springframework.web.bind.annotation.*;
|
|
15
|
+
|
|
16
|
+import com.huiju.estateagents.base.BaseController;
|
|
17
|
+
|
|
18
|
+import javax.servlet.http.HttpServletRequest;
|
|
19
|
+import java.util.ArrayList;
|
|
20
|
+import java.util.HashMap;
|
|
21
|
+import java.util.List;
|
|
22
|
+import java.util.Map;
|
|
23
|
+
|
|
24
|
+/**
|
|
25
|
+ * <p>
|
|
26
|
+ * 人员表 前端控制器
|
|
27
|
+ * </p>
|
|
28
|
+ *
|
|
29
|
+ * @author jobob
|
|
30
|
+ * @since 2019-05-10
|
|
31
|
+ */
|
|
32
|
+@RestController
|
|
33
|
+@RequestMapping("/api")
|
|
34
|
+public class TaPersonController extends BaseController {
|
|
35
|
+ @Autowired
|
|
36
|
+ ITaPersonService taPersonService;
|
|
37
|
+
|
|
38
|
+ /**
|
|
39
|
+ *
|
|
40
|
+ * 因为人员表是集合系统的所有种类的用户,包含了各种角色。因此各种角色的操作都在本 controller 中完成
|
|
41
|
+ * 以下是置业顾问卡片内容
|
|
42
|
+ *
|
|
43
|
+ */
|
|
44
|
+
|
|
45
|
+ /**
|
|
46
|
+ * 获取卡片列表
|
|
47
|
+ * @param pageNumber
|
|
48
|
+ * @param pageSize
|
|
49
|
+ * @return
|
|
50
|
+ */
|
|
51
|
+ @GetMapping("/wx/cards")
|
|
52
|
+ public ResponseBean getCardList(@RequestParam(defaultValue = "1") int pageNumber,
|
|
53
|
+ @RequestParam(defaultValue = "10") int pageSize,
|
|
54
|
+ @RequestParam(defaultValue = "false") boolean mine,HttpServletRequest request) {
|
|
55
|
+ if (pageNumber < 0 || pageSize < 0) {
|
|
56
|
+ return ResponseBean.error("分页参数不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
57
|
+ }
|
|
58
|
+ if (mine){
|
|
59
|
+ String openid = JWTUtils.getSubject(request);
|
|
60
|
+ List<TaPerson> taPersons = taPersonService.getPersonsByOpenId(openid);
|
|
61
|
+ if (null == taPersons || taPersons.size() != 1) {
|
|
62
|
+ return ResponseBean.error("验证人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
|
|
63
|
+ }
|
|
64
|
+ TaPerson person = taPersons.get(0);
|
|
65
|
+ IPage<Map<String, Object>> result = taPersonService.getSavedConsaultants(pageNumber,pageSize,person.getPersonId());
|
|
66
|
+ return ResponseBean.success(result);
|
|
67
|
+ }else {
|
|
68
|
+ IPage<Map<String, Object>> result = taPersonService.getCardList(pageNumber, pageSize);
|
|
69
|
+ return ResponseBean.success(result);
|
|
70
|
+ }
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+ }
|
|
74
|
+
|
|
75
|
+ /**
|
|
76
|
+ * 绑定卡片
|
|
77
|
+ * @param paramStr
|
|
78
|
+ * @return
|
|
79
|
+ */
|
|
80
|
+ @PostMapping("/wx/cards/apply")
|
|
81
|
+ public ResponseBean applyCard(@RequestBody String paramStr, HttpServletRequest request) {
|
|
82
|
+ JSONObject params = JSONObject.parseObject(paramStr);
|
|
83
|
+ String phone = (String) params.get("phone");
|
|
84
|
+ String pass = (String) params.get("pass");
|
|
85
|
+ String openid = JWTUtils.getSubject(request);
|
|
86
|
+
|
|
87
|
+ if (isEmpty(phone) || isEmpty(pass)) {
|
|
88
|
+ return ResponseBean.error("参数不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
89
|
+ }
|
|
90
|
+
|
|
91
|
+ ResponseBean resp = taPersonService.checkPhoneAndPass(phone, pass);
|
|
92
|
+
|
|
93
|
+ // 成功返回空数据
|
|
94
|
+ if (resp.getCode() != ResponseBean.CODE_SUCCESS) {
|
|
95
|
+ return resp;
|
|
96
|
+ }
|
|
97
|
+
|
|
98
|
+ return taPersonService.bindCard(phone, pass, openid);
|
|
99
|
+ }
|
|
100
|
+
|
|
101
|
+ /**
|
|
102
|
+ * 获取名片详情
|
|
103
|
+ * @param id
|
|
104
|
+ * @return
|
|
105
|
+ */
|
|
106
|
+ @GetMapping("/wx/cards/{id}")
|
|
107
|
+ public ResponseBean getCardDetail(@PathVariable String id, HttpServletRequest request) {
|
|
108
|
+ if (isEmpty(id)) {
|
|
109
|
+ return ResponseBean.error("参数不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
110
|
+ }
|
|
111
|
+ String openid = JWTUtils.getSubject(request);
|
|
112
|
+ List<TaPerson> taPersons = taPersonService.getPersonsByOpenId(openid);
|
|
113
|
+ if (null == taPersons || taPersons.size() != 1) {
|
|
114
|
+ return ResponseBean.error("验证人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
|
|
115
|
+ }
|
|
116
|
+ TaPerson person = taPersons.get(0);
|
|
117
|
+
|
|
118
|
+ return taPersonService.getCardDetail(openid, id,person.getPersonId());
|
|
119
|
+ }
|
|
120
|
+
|
|
121
|
+ /**
|
|
122
|
+ * 找回密码
|
|
123
|
+ * @param plat 平台类型 wx 是微信相关, admin 是后台管理系统
|
|
124
|
+ * @param paramStr
|
|
125
|
+ * @return
|
|
126
|
+ */
|
|
127
|
+ @PostMapping("/{plat}/resetPass")
|
|
128
|
+ public ResponseBean resetPassword(@PathVariable String plat, @RequestBody String paramStr) {
|
|
129
|
+ JSONObject params = JSONObject.parseObject(paramStr);
|
|
130
|
+ String phone = (String) params.get("phone");
|
|
131
|
+ String code = (String) params.get("code");
|
|
132
|
+ String pass = (String) params.get("pass");
|
|
133
|
+
|
|
134
|
+ if (isEmpty(phone) || isEmpty(code) || isEmpty(pass)) {
|
|
135
|
+ return ResponseBean.error("参数不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
136
|
+ }
|
|
137
|
+
|
|
138
|
+ // todo
|
|
139
|
+ // 验证 验证码是否正确
|
|
140
|
+ if (code != "1234") {
|
|
141
|
+ return ResponseBean.error("验证码不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
142
|
+ }
|
|
143
|
+
|
|
144
|
+ return taPersonService.resetPassword(phone, pass, plat);
|
|
145
|
+ }
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+ /**
|
|
149
|
+ *
|
|
150
|
+ * 以下是经纪人部分
|
|
151
|
+ *
|
|
152
|
+ */
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+ /**
|
|
156
|
+ * 注册经纪人
|
|
157
|
+ * @param paramStr
|
|
158
|
+ * @param request
|
|
159
|
+ * @return
|
|
160
|
+ */
|
|
161
|
+ @PostMapping("/wx/register")
|
|
162
|
+ public ResponseBean resgiteAgent(@RequestBody String paramStr, HttpServletRequest request) {
|
|
163
|
+ JSONObject params = JSONObject.parseObject(paramStr);
|
|
164
|
+ String name = (String) params.get("name");
|
|
165
|
+ String phone = (String) params.get("phone");
|
|
166
|
+ Integer sex = (Integer) params.get("sex");
|
|
167
|
+ String explain = (String) params.get("explain");
|
|
168
|
+
|
|
169
|
+ if (isEmpty(name) || isEmpty(phone) || isEmpty(explain)) {
|
|
170
|
+ return ResponseBean.error("请检查部分参数不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
171
|
+ }
|
|
172
|
+
|
|
173
|
+ // 当前人员
|
|
174
|
+ String openid = JWTUtils.getSubject(request);
|
|
175
|
+
|
|
176
|
+ return taPersonService.resgiteAgent(name, phone, sex, explain, openid);
|
|
177
|
+ }
|
|
178
|
+
|
|
179
|
+ /**
|
|
180
|
+ * 生成海报
|
|
181
|
+ * @param paramStr
|
|
182
|
+ * @param request
|
|
183
|
+ * @return
|
|
184
|
+ */
|
|
185
|
+ @PostMapping("/wx/poster")
|
|
186
|
+ public ResponseBean genPoster(@RequestBody String paramStr, HttpServletRequest request) {
|
|
187
|
+ return null;
|
|
188
|
+ }
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+ /**
|
|
192
|
+ *
|
|
193
|
+ * 以下是个人中心部分
|
|
194
|
+ *
|
|
195
|
+ */
|
|
196
|
+
|
|
197
|
+ /**
|
|
198
|
+ * 获取个人信息
|
|
199
|
+ * @param request
|
|
200
|
+ * @return
|
|
201
|
+ */
|
|
202
|
+ @GetMapping("/wx/user/info")
|
|
203
|
+ public ResponseBean getUserInfo(HttpServletRequest request) {
|
|
204
|
+ String openid = JWTUtils.getSubject(request);
|
|
205
|
+
|
|
206
|
+ return taPersonService.getWxUser(openid);
|
|
207
|
+ }
|
|
208
|
+
|
|
209
|
+ /**
|
|
210
|
+ * 个人签到
|
|
211
|
+ * @param request
|
|
212
|
+ * @return
|
|
213
|
+ */
|
|
214
|
+ @PostMapping("/wx/user/signin")
|
|
215
|
+ public ResponseBean userSign(HttpServletRequest request) {
|
|
216
|
+ String openid = JWTUtils.getSubject(request);
|
|
217
|
+
|
|
218
|
+ return taPersonService.getWxUserSign(openid);
|
|
219
|
+ }
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+ /**
|
|
223
|
+ *
|
|
224
|
+ *
|
|
225
|
+ * 以下是系统用户管理
|
|
226
|
+ *
|
|
227
|
+ */
|
|
228
|
+
|
|
229
|
+ /**
|
|
230
|
+ * 用户手机号登录
|
|
231
|
+ * @param paramStr
|
|
232
|
+ * @return
|
|
233
|
+ */
|
|
234
|
+ @PostMapping("/admin/signin")
|
|
235
|
+ public ResponseBean signin(@RequestBody String paramStr) {
|
|
236
|
+ JSONObject params = JSONObject.parseObject(paramStr);
|
|
237
|
+ if (params == null) {
|
|
238
|
+ return ResponseBean.error("非法参数", ResponseBean.ERROR_MISSING_PARAMS);
|
|
239
|
+ }
|
|
240
|
+
|
|
241
|
+ String userPhone = params.getString("phone");
|
|
242
|
+ String userCaptcha = params.getString("captcha");
|
|
243
|
+
|
|
244
|
+ // todo
|
|
245
|
+ if (!"1234".equals(userCaptcha)) {
|
|
246
|
+ return ResponseBean.error("验证码不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
247
|
+ }
|
|
248
|
+
|
|
249
|
+ TaPerson taPerson = taPersonService.getPersonByTel(userPhone);
|
|
250
|
+ if (taPerson == null) {
|
|
251
|
+ return ResponseBean.error("手机号不存在", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
252
|
+ }
|
|
253
|
+
|
|
254
|
+ if (taPerson.getStatus() != CommConstant.STATUS_NORMAL) {
|
|
255
|
+ return ResponseBean.error("用户状态异常", ResponseBean.ERROR_UNAVAILABLE);
|
|
256
|
+ }
|
|
257
|
+
|
|
258
|
+ String token = JWTUtils.newToken(taPerson.getPersonId());
|
|
259
|
+
|
|
260
|
+ Map<String, Object> result = new HashMap<>();
|
|
261
|
+ result.put("token", token);
|
|
262
|
+ result.put("person", taPerson);
|
|
263
|
+
|
|
264
|
+ return ResponseBean.success(result);
|
|
265
|
+ }
|
|
266
|
+
|
|
267
|
+ /**
|
|
268
|
+ * 获取当前用户
|
|
269
|
+ * @param request
|
|
270
|
+ * @return
|
|
271
|
+ */
|
|
272
|
+ @GetMapping("/admin/user/current")
|
|
273
|
+ public ResponseBean getCurrentPerson(HttpServletRequest request) {
|
|
274
|
+ String personId = JWTUtils.getSubject(request);
|
|
275
|
+ TaPerson taPerson = taPersonService.getById(personId);
|
|
276
|
+ if (null == taPerson || taPerson.getStatus() != CommConstant.STATUS_NORMAL) {
|
|
277
|
+ return ResponseBean.error("用户状态异常", ResponseBean.ERROR_AUTH_EXPIRED);
|
|
278
|
+ }
|
|
279
|
+
|
|
280
|
+ return ResponseBean.success(taPerson);
|
|
281
|
+ }
|
|
282
|
+
|
|
283
|
+ @GetMapping("/admin/consultant")
|
|
284
|
+ public ResponseBean getConsultantList(
|
|
285
|
+ Integer pageNumber,
|
|
286
|
+ Integer pageSize,
|
|
287
|
+ String name,
|
|
288
|
+ String phone
|
|
289
|
+ ) {
|
|
290
|
+ if (null == pageNumber) pageNumber = 1;
|
|
291
|
+ if (null == pageSize) pageSize = 10;
|
|
292
|
+
|
|
293
|
+ IPage<TaPerson> taPersonIPage = taPersonService.getPersonList(pageNumber, pageSize, CommConstant.PERSON_REALTY_CONSULTANT, name, phone);
|
|
294
|
+ return ResponseBean.success(taPersonIPage);
|
|
295
|
+ }
|
|
296
|
+
|
|
297
|
+ @GetMapping("/admin/consultant/{id}")
|
|
298
|
+ public ResponseBean getConsultant(@PathVariable String id) {
|
|
299
|
+ TaPerson taPerson = taPersonService.getById(id);
|
|
300
|
+
|
|
301
|
+ List<TaPersonBuilding> buildings = taPersonService.getPersonBuildings(id);
|
|
302
|
+ if (null != buildings && buildings.size() > 0) {
|
|
303
|
+ List<String> projects = new ArrayList<>();
|
|
304
|
+ for (TaPersonBuilding b : buildings) {
|
|
305
|
+ projects.add(b.getBuildingId());
|
|
306
|
+ }
|
|
307
|
+ taPerson.setProjects(projects);
|
|
308
|
+ }
|
|
309
|
+
|
|
310
|
+ return ResponseBean.success(taPerson);
|
|
311
|
+ }
|
|
312
|
+
|
|
313
|
+ @PostMapping("/admin/consultant")
|
|
314
|
+ public ResponseBean newConsultant(@RequestBody String paramStr) {
|
|
315
|
+ return taPersonService.newConsultant(paramStr);
|
|
316
|
+ }
|
|
317
|
+
|
|
318
|
+ @PutMapping("/admin/consultant/{id}")
|
|
319
|
+ public ResponseBean editConsultant(@PathVariable String id, @RequestBody String paramStr) {
|
|
320
|
+ return taPersonService.editConsultant(id, paramStr);
|
|
321
|
+ }
|
|
322
|
+
|
|
323
|
+ boolean isEmpty(String str) {
|
|
324
|
+ return null == str || "".equals(str.trim());
|
|
325
|
+ }
|
|
326
|
+
|
|
327
|
+ /**
|
|
328
|
+// * 获取收藏置业顾问列表
|
|
329
|
+// * @param pageNumber
|
|
330
|
+// * @param pageSize
|
|
331
|
+// * @return
|
|
332
|
+// */
|
|
333
|
+// @GetMapping("/wx/savedPerson")
|
|
334
|
+// public ResponseBean getSavedConsaultants(@RequestParam(defaultValue = "1") int pageNumber,
|
|
335
|
+// @RequestParam(defaultValue = "10") int pageSize,HttpServletRequest request) {
|
|
336
|
+// String openid = JWTUtils.getSubject(request);
|
|
337
|
+// List<TaPerson> taPersons = taPersonService.getPersonsByOpenId(openid);
|
|
338
|
+// if (null == taPersons || taPersons.size() != 1) {
|
|
339
|
+// return ResponseBean.error("验证人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
|
|
340
|
+// }
|
|
341
|
+// TaPerson person = taPersons.get(0);
|
|
342
|
+// if (pageNumber < 0 || pageSize < 0) {
|
|
343
|
+// return ResponseBean.error("分页参数不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
344
|
+// }
|
|
345
|
+// try {
|
|
346
|
+// IPage<TaPerson> result = taPersonService.getSavedConsaultants(pageNumber,pageSize,person.getPersonId());
|
|
347
|
+// return ResponseBean.success(result);
|
|
348
|
+// }catch (Exception e){
|
|
349
|
+// e.printStackTrace();
|
|
350
|
+// return ResponseBean.error("查询失败", ResponseBean.ERROR_UNAVAILABLE);
|
|
351
|
+// }
|
|
352
|
+//
|
|
353
|
+// }
|
|
354
|
+ /**
|
|
355
|
+ * 获取我参加过的活动列表
|
|
356
|
+ * @param pageNumber
|
|
357
|
+ * @param pageSize
|
|
358
|
+ * @return
|
|
359
|
+ */
|
|
360
|
+ @GetMapping("/wx/joinedActivity/")
|
|
361
|
+ public ResponseBean getJoinedActivity(@RequestParam(defaultValue = "1") int pageNumber,
|
|
362
|
+ @RequestParam(defaultValue = "10") int pageSize,HttpServletRequest request){
|
|
363
|
+ String openid = JWTUtils.getSubject(request);
|
|
364
|
+ List<TaPerson> taPersons = taPersonService.getPersonsByOpenId(openid);
|
|
365
|
+ if (null == taPersons || taPersons.size() != 1) {
|
|
366
|
+ return ResponseBean.error("验证人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
|
|
367
|
+ }
|
|
368
|
+ TaPerson person = taPersons.get(0);
|
|
369
|
+
|
|
370
|
+ if (pageNumber < 0 || pageSize < 0) {
|
|
371
|
+ return ResponseBean.error("分页参数不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
372
|
+ }
|
|
373
|
+ try {
|
|
374
|
+ IPage<TaBuildingDynamic> result = taPersonService.getJoinedActivity(pageNumber,pageSize,person.getPhone(),"");
|
|
375
|
+ return ResponseBean.success(result);
|
|
376
|
+ }catch (Exception e){
|
|
377
|
+ e.printStackTrace();
|
|
378
|
+ return ResponseBean.error("查询失败", ResponseBean.ERROR_UNAVAILABLE);
|
|
379
|
+ }
|
|
380
|
+
|
|
381
|
+ }
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+}
|