puzhibing
2025-03-31 14aaf511757e39065ecbd679a5b9bce6ca2573be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
package com.stylefeng.guns.modular.api;
 
import com.alibaba.fastjson.JSONObject;
import com.stylefeng.guns.core.common.constant.JwtConstants;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.system.model.UserInfo;
import com.stylefeng.guns.modular.system.service.ISmsrecordService;
import com.stylefeng.guns.modular.system.service.IUserInfoService;
import com.stylefeng.guns.modular.system.service.IVerifiedService;
import com.stylefeng.guns.modular.system.util.ObsUploadUtil;
import com.stylefeng.guns.modular.system.util.RedisUtil;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.system.util.WeChatUtil;
import com.stylefeng.guns.modular.system.warpper.LoginWarpper;
import com.stylefeng.guns.modular.system.warpper.UserInfoWarpper;
import com.stylefeng.guns.modular.system.warpper.VerifiedWarpper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
 
/**
 * 用户控制器
 */
@Api
@RestController
@RequestMapping("")
public class UserInfoController {
 
    @Autowired
    private IUserInfoService userInfoService;
 
    @Autowired
    private IVerifiedService verifiedService;
 
    @Autowired
    private ISmsrecordService smsrecordService;
 
    @Autowired
    private RedisUtil redisUtil;
 
    @Autowired
    private WeChatUtil weChatUtil;
 
 
 
 
 
    /**
     * 获取短信验证码
     * @param phone
     * @return
     */
    @ResponseBody
    @PostMapping("/base/queryCaptcha")
    @ApiOperation(value = "获取短信验证码", tags = {"用户端-登录"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"),
            @ApiImplicitParam(value = "场景类型(1=身份验证,2=登录确认,3=用户注册,4=修改密码)", name = "type", required = true, dataType = "String")
    })
    public ResultUtil queryCaptcha(String phone, Integer type){
        if(ToolUtil.isNotEmpty(phone)){
            try {
                return userInfoService.queryCaptcha(phone, type);
            }catch (Exception e){
                e.printStackTrace();
                return ResultUtil.runErr();
            }
        }else{
            return ResultUtil.paranErr();
        }
    }
 
 
    /**
     * 手机验证码登录
     * @param phone
     * @param code
     * @param registIp
     * @param registAreaCode
     * @return
     */
    @ResponseBody
    @PostMapping("/base/user/captchaLogin")
    @ApiOperation(value = "手机验证码登录", tags = {"用户端-登录"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"),
            @ApiImplicitParam(value = "短信验证码", name = "code", required = true, dataType = "String"),
            @ApiImplicitParam(value = "ip地址", name = "registIp", required = false, dataType = "String"),
            @ApiImplicitParam(value = "登录端口-小程序传Applets", name = "loginType", required = false, dataType = "String"),
            @ApiImplicitParam(value = "当前定位区县行政编号", name = "registAreaCode", required = false, dataType = "String")
    })
    public ResultUtil<LoginWarpper> captchaLogin(String phone, String code, String registIp, String registAreaCode,String loginType){
        try {
            return userInfoService.captchaLogin(phone, code, registIp, registAreaCode,loginType);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    @ResponseBody
    @PostMapping("/base/user/oneClickLogin")
    @ApiOperation(value = "手机一键登录", tags = {"用户端-登录"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "app端SDK获取的登录token。", name = "accessToken", required = true, dataType = "String"),
            @ApiImplicitParam(value = "ip地址", name = "registIp", required = false, dataType = "String"),
            @ApiImplicitParam(value = "登录端口-小程序传Applets", name = "loginType", required = false, dataType = "String"),
            @ApiImplicitParam(value = "当前定位区县行政编号", name = "registAreaCode", required = false, dataType = "String"),
            @ApiImplicitParam(value = "安卓或者苹果  安卓传android 苹果传ios", name = "androidOrIos", required = false, dataType = "String")
    })
    public ResultUtil<LoginWarpper> oneClickLogin(String accessToken, String registIp, String registAreaCode,String loginType,String androidOrIos){
        try {
            return userInfoService.oneClickLogin(accessToken, registIp, registAreaCode,loginType,androidOrIos);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    /**
     * 手机验证码登录
     * @param phone
     * @param code
     * @return
     */
    @ResponseBody
    @PostMapping("/base/user/captchaLogin_")
    @ApiOperation(value = "手机验证码登录", tags = {"分享专用"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"),
            @ApiImplicitParam(value = "短信验证码", name = "code", required = true, dataType = "String"),
            @ApiImplicitParam(value = "分享的用户id", name = "uid", required = true, dataType = "int"),
            @ApiImplicitParam(value = "登录端口-小程序传Applets", name = "loginType", required = false, dataType = "String"),
            @ApiImplicitParam(value = "用户类型(1=用户,2=司机)", name = "type", required = true, dataType = "int"),
            @ApiImplicitParam(value = "注册类型(1=司机注册,2=用户注册)", name = "userType", required = true, dataType = "int")
    })
    public ResultUtil<LoginWarpper> captchaLogin_(String phone, String code, Integer uid, Integer type, Integer userType,String loginType){
        try {
            return userInfoService.captchaLogin(phone, code, uid, type, userType,loginType);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
 
 
 
    /**
     * 账号密码登录
     * @param phone
     * @param password
     * @return
     */
    @ResponseBody
    @PostMapping("/base/user/userLogin")
    @ApiOperation(value = "账号密码登录", tags = {"用户端-登录"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"),
            @ApiImplicitParam(value = "登录端口-小程序传Applets", name = "loginType", required = false, dataType = "String"),
            @ApiImplicitParam(value = "登录密码", name = "password", required = true, dataType = "String")
    })
    public ResultUtil<LoginWarpper> userLogin(String phone, String password,String loginType){
        if(ToolUtil.isNotEmpty(phone) && ToolUtil.isNotEmpty(password)){
            try {
                return userInfoService.userLogin(phone, password,loginType);
            }catch (Exception e){
                e.printStackTrace();
                return ResultUtil.runErr();
            }
        }else{
            return ResultUtil.paranErr();
        }
    }
 
 
    /**
     * 忘记密码
     * @param phone
     * @param code
     * @param password
     * @return
     */
    @ResponseBody
    @PostMapping("/base/user/forgetPassword")
    @ApiOperation(value = "忘记密码操作", tags = {"用户端-登录"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "手机号码", name = "phone", required = true, dataType = "String"),
            @ApiImplicitParam(value = "验证码", name = "code", required = true, dataType = "String"),
            @ApiImplicitParam(value = "新密码", name = "password", required = true, dataType = "String")
    })
    public ResultUtil forgetPassword(String phone, String code, String password){
        if(ToolUtil.isNotEmpty(phone) && ToolUtil.isNotEmpty(code) && ToolUtil.isNotEmpty(password)){
            try {
                return userInfoService.forgetPassword(phone, code, password);
            }catch (Exception e){
                e.printStackTrace();
                return ResultUtil.runErr();
            }
        }else{
            return ResultUtil.paranErr();
        }
    }
 
 
    /**
     * 微信授权登录
     * @param type              登录端口(1:APP登录,2:小程序)
     * @param openid            微信openid
     * @param unionid           微信unionid
     * @param jscode            小程序登录时的jscode临时凭证
     * @param registIp          ip地址
     * @param registAreaCode    当前定位区县行政编号(6位)
     * @return
     */
    @ResponseBody
    @PostMapping("/base/user/wxLogin")
    @ApiOperation(value = "微信授权登录", tags = {"用户端-登录"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "登录端口(1:APP,2:小程序)", name = "type", required = true, dataType = "int"),
            @ApiImplicitParam(value = "微信openid(APP登录上传)", name = "openid", required = false, dataType = "String"),
            @ApiImplicitParam(value = "微信unionid(APP登录上传)", name = "unionid", required = false, dataType = "String"),
            @ApiImplicitParam(value = "微信jscode(小程序登录上传)", name = "jscode", required = false, dataType = "String"),
            @ApiImplicitParam(value = "ip地址", name = "registIp", required = false, dataType = "String"),
            @ApiImplicitParam(value = "当前定位区县行政编号", name = "registAreaCode", required = true, dataType = "String"),
            @ApiImplicitParam(value = "头像", name = "avatar", required = false, dataType = "String"),
            @ApiImplicitParam(value = "昵称", name = "nickName", required = false, dataType = "String"),
            @ApiImplicitParam(value = "登录端口-小程序传Applets", name = "loginType", required = false, dataType = "String"),
            @ApiImplicitParam(value = "性别(1=男,2=女)", name = "sex", required = false, dataType = "int")
    })
    public ResultUtil<LoginWarpper> wxLogin(Integer type, String openid, String unionid, String jscode, String registIp, String registAreaCode, Integer sex, String nickName, String avatar,String loginType){
        try {
            return userInfoService.wxLogin(type, openid, unionid, jscode, registIp, registAreaCode, sex, nickName, avatar,loginType);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 设置电话号码
     * @param phone
     * @param code
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/api/user/bindingPhone")
    @ApiOperation(value = "设置电话号码", tags = {"用户端-登录"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "电话号码", name = "phone", required = true, dataType = "String"),
            @ApiImplicitParam(value = "验证码", name = "code", required = false, dataType = "String"),
            @ApiImplicitParam(value = "登录端口-小程序传Applets", name = "loginType", required = false, dataType = "String"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<LoginWarpper> bindingPhone(String phone, String code, HttpServletRequest request,String loginType){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            return userInfoService.bindingPhone(uid, phone, code,loginType);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 获取用户个人信息
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/api/user/queryUserInfo")
    @ApiOperation(value = "获取用户详情", tags = {"用户端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<UserInfoWarpper> queryUserInfo(HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            Map<String, Object> map = userInfoService.queryUserInfo(uid);
            return ResultUtil.success(UserInfoWarpper.getUserInfoWarpper(map));
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 手机号码获取用户
     * @param phone
     * @return
     */
    @ResponseBody
    @PostMapping("/api/user/queryUser")
    @ApiOperation(value = "手机号码获取用户", tags = {"用户端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "电话号码", name = "phone", required = true, dataType = "String"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<Object> queryUser(String phone){
        try {
            Map<String, Object> map = userInfoService.queryUser(phone);
            if(null != map){
                return ResultUtil.success(UserInfoWarpper.getUserInfoWarpper(map));
            }
            return ResultUtil.success(new JSONObject());
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 实名认证操作
     * @param verifiedWarpper
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/api/user/verified")
    @ApiOperation(value = "实名认证操作", tags = {"用户端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil verified(VerifiedWarpper verifiedWarpper, HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            return verifiedService.verified(VerifiedWarpper.getVerified(verifiedWarpper), uid);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 设置紧急联系人
     * @param name
     * @param phone
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/api/user/setUrgentUser")
    @ApiOperation(value = "设置紧急联系人", tags = {"用户端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "姓名,没有传空字符串", name = "name", required = true, dataType = "String"),
            @ApiImplicitParam(value = "电话号码,没有传空字符串", name = "phone", required = true, dataType = "String"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil setUrgentUser(String name, String phone, HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            userInfoService.setUrgentUser(name, phone, uid);
            return ResultUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 用户充值余额
     * @param payType
     * @param money
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/api/user/depositBalance")
    @ApiOperation(value = "余额充值", tags = {"用户端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "支付方式(1=微信,2=支付宝)", name = "payType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "充值金额", name = "money", required = true, dataType = "double"),
            @ApiImplicitParam(value = "支付端(1=用户APP端,2=司机APP端,3=用户小程序端)", name = "type", required = false, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil depositBalance(Integer payType, Double money, Integer type, HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            return userInfoService.depositBalance(payType, money, uid, type);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 修改手机号码
     * @param code
     * @param phone
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/api/user/updatePhone")
    @ApiOperation(value = "修改手机号码", tags = {"用户端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "验证码", name = "code", required = true, dataType = "string"),
            @ApiImplicitParam(value = "新手机号", name = "phone", required = true, dataType = "string"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil updatePhone(String code, String phone, HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            return userInfoService.updatePhone(code, phone, uid);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    @ResponseBody
    @PostMapping("/api/user/checkCaptcha")
    @ApiOperation(value = "验证短信验证码", tags = {"用户端-个人中心"}, notes = "1=正确,0=错误")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "电话号码", name = "phone", required = true, dataType = "string"),
            @ApiImplicitParam(value = "短信验证码", name = "code", required = true, dataType = "string"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil checkCaptcha(String phone, String code, HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            UserInfo userInfo = userInfoService.selectById(uid);
            smsrecordService.saveData(4, userInfo.getPhone(), code, "短信验证码【" + code + "】已发到您的手机,验证码将在5分钟后失效,请及时登录!");
            boolean b = userInfoService.checkCaptcha(phone, code);
            Map<String, Object> map = new HashMap<>();
            map.put("ok", b ? 1 : 0);
            return ResultUtil.success(map);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
 
    /**
     * 修改登录密码
     * @param password
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/api/user/updatePassword")
    @ApiOperation(value = "修改登录密码", tags = {"用户端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "新密码", name = "password", required = true, dataType = "string"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil updatePassword(String password, HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            return userInfoService.updatePass(password, uid);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 修改个人信息
     * @param avatar
     * @param nickname
     * @param sex
     * @param birthday
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/api/user/updateInfo")
    @ApiOperation(value = "修改个人信息", tags = {"用户端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "头像", name = "avatar", required = false, dataType = "string"),
            @ApiImplicitParam(value = "昵称", name = "nickname", required = false, dataType = "string"),
            @ApiImplicitParam(value = "性别(1=男,2=女)", name = "sex", required = false, dataType = "int"),
            @ApiImplicitParam(value = "生日(2020-06-15)", name = "birthday", required = false, dataType = "string"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil updateInfo(String avatar, String nickname, Integer sex, Date birthday, HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            userInfoService.updateInfo(avatar, nickname, sex, birthday, uid);
            return ResultUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    @ResponseBody
    @PostMapping("/api/user/queryRealName")
    @ApiOperation(value = "获取实名认证的数据", tags = {"用户端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil queryRealName(HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            Map<String, Object> map = userInfoService.queryRealName(uid);
            return ResultUtil.success(null != map ? map : new HashMap<>());
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 后台调用禁用用户
     * @param uid
     * @return
     */
    @ResponseBody
    @PostMapping("/base/user/freeze")
    public ResultUtil freeze(Integer uid){
        try {
            UserInfo userInfo = userInfoService.selectById(uid);
            String value = redisUtil.getValue(userInfo.getPhone());
            redisUtil.remove(value);
            redisUtil.remove(userInfo.getPhone());
            return ResultUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 仿socket接口(单点登录)
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/api/user/comparisonToken")
    @ApiOperation(value = "单点登录", tags = {"用户端-仿socket接口"}, notes = "match=1(匹配),match=2(不匹配)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil comparisonToken(HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            String requestHeader = request.getHeader(JwtConstants.AUTH_HEADER);
            requestHeader = requestHeader.substring(requestHeader.indexOf(" ") + 1);
            String value = redisUtil.getValue("USER_" + uid);
            Map<String, Object> map = new HashMap<>();
            map.put("match", requestHeader.equals(value) ? 1 : 2);
            return ResultUtil.success(map);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    /**
     * 注销账号
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/api/user/cancellation")
    @ApiOperation(value = "注销账号", tags = {"用户端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil cancellation(HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            UserInfo userInfo = userInfoService.selectById(uid);
            userInfo.setState(2);
            userInfoService.updateById(userInfo);
            //开始验证当前账号是否在别处登录
            String value = redisUtil.getValue("USER_" + uid);
            if(ToolUtil.isNotEmpty(value)){//将另外设备上的强迫下线
                //开始清除redis中无效的数据
                String key = redisUtil.getValue("USER_" + userInfo.getPhone());
                redisUtil.remove(key);//删除个人信息数据
                redisUtil.remove("USER_" + userInfo.getPhone());//删除后台冻结相关缓存
                redisUtil.remove("USER_" + uid);//清除存储的token
            }
            return ResultUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
 
 
    @ResponseBody
    @PostMapping("/base/user/dxlcLogin")
    @ApiOperation(value = "道行龙城登录", tags = {"用户端-道行龙城"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "道行龙城获取的授权", name = "authCode", required = true, dataType = "String"),
            @ApiImplicitParam(value = "登录端口-小程序和H5传Applets", name = "loginType", required = false, dataType = "String"),
            @ApiImplicitParam(value = "当前定位区县行政编号", name = "registAreaCode", required = false, dataType = "String")
    })
    public ResultUtil dxlcLogin(String authCode, String registAreaCode,String loginType){
        try {
            return userInfoService.dxlcLogin(authCode, registAreaCode, loginType);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    @ResponseBody
    @PostMapping("/base/user/getSignatureConfig")
    @ApiOperation(value = "获取微信JS-SDK", tags = {"用户端-道行龙城"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "授权地址", name = "url", required = true, dataType = "String"),
    })
    public ResultUtil getSignatureConfig(String url){
        try {
            Map<String, Object> signatureConfig = weChatUtil.getSignatureConfig(url);
            return ResultUtil.success(signatureConfig);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    /**
     * 手机号码获取用户
     * @return
     */
    @ResponseBody
    @PostMapping("/api/user/phoneLoginBindingWeChat")
    @ApiOperation(value = "微信小程序手机号登录后调用此接口保存微信openid", tags = {"用户端-登录"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "微信登录临时凭证", name = "jscode", required = true, dataType = "String"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil phoneLoginBindingWeChat(String jscode, HttpServletRequest request){
        try {
            Integer userId = userInfoService.getUserIdFormRedis(request);
            if(null == userId){
                return ResultUtil.tokenErr();
            }
            return userInfoService.phoneLoginBindingWeChat(userId, jscode);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
 
    @ResponseBody
    @PostMapping("/base/uploadImg")
    @ApiOperation(value = "上传图片接口", tags = {"公共接口"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "图片文件", name = "file", required = true, dataType = "file"),
    })
    public ResultUtil uploadImg(MultipartFile file, HttpServletRequest request, HttpServletResponse response){
        try {
            String name = file.getOriginalFilename();
            String type = name.substring(name.lastIndexOf(".") + 1).toLowerCase();
            List<String> types = Arrays.asList("jpg", "jpeg", "png");
            if(!types.contains(type)){
                return ResultUtil.error("请上传图片文件(jpg/jpeg/png)");
            }
            String s = ObsUploadUtil.obsUpload(request, file);
            return ResultUtil.success(s);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
 
    /**
     * 注销账号
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/api/user/cancelAccount")
    @ApiOperation(value = "注销账号", tags = {"用户端-登录"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil cancelAccount(HttpServletRequest request){
        try {
            Integer userId = userInfoService.getUserIdFormRedis(request);
            if(null == userId){
                return ResultUtil.tokenErr();
            }
            UserInfo userInfo = userInfoService.selectById(userId);
            userInfo.setFlag(3);
            userInfoService.updateById(userInfo);
            return ResultUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
}