|
@@ -10,7 +10,6 @@ import com.eitc.common.core.redis.RedisCache;
|
10
|
10
|
import com.eitc.common.utils.JWTUtil;
|
11
|
11
|
import com.eitc.common.utils.PatientBaseUtil;
|
12
|
12
|
import com.eitc.common.utils.SecurityUtils;
|
13
|
|
-import com.eitc.system.utils.SendSmsUtil;
|
14
|
13
|
import com.eitc.patient.constant.PatientConstant;
|
15
|
14
|
import com.eitc.patient.domain.AppUser;
|
16
|
15
|
import com.eitc.patient.domain.AppUserPatients;
|
|
@@ -158,11 +157,6 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
158
|
157
|
throw new RuntimeException("用户不存在或密码错误");
|
159
|
158
|
}
|
160
|
159
|
} else if (String.valueOf(AppUserLoginTypeEnum.CAPTCHA.getCode()).equals(loginType)) {
|
161
|
|
- // 手机验证码登录
|
162
|
|
- String captchaCode = map.get("captchaCode");
|
163
|
|
- if (checkCaptchaCode(phoneNumber, captchaCode)) {
|
164
|
|
- throw new RuntimeException("验证码错误");
|
165
|
|
- }
|
166
|
160
|
AppUser user = getAppUserByPhoneNumber(phoneNumber);
|
167
|
161
|
if (Objects.isNull(user)) {
|
168
|
162
|
throw new RuntimeException(phoneNumber + "用户不存在");
|
|
@@ -204,11 +198,6 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
204
|
198
|
throw new RuntimeException(phoneNumber + "用户不存在或密码错误");
|
205
|
199
|
}
|
206
|
200
|
} else if (String.valueOf(AppUserLoginTypeEnum.CAPTCHA.getCode()).equals(loginType)) {
|
207
|
|
- // 手机验证码登录
|
208
|
|
- String captchaCode = map.get("captchaCode");
|
209
|
|
- if (checkCaptchaCode(phoneNumber, captchaCode)) {
|
210
|
|
- throw new RuntimeException("验证码错误");
|
211
|
|
- }
|
212
|
201
|
SysUser sysUser = getPCUserByPhoneNumber(phoneNumber);
|
213
|
202
|
if (Objects.isNull(sysUser)) {
|
214
|
203
|
throw new RuntimeException(phoneNumber + "用户不存在");
|
|
@@ -237,8 +226,6 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
237
|
226
|
//生成JWt的令牌
|
238
|
227
|
String token = JWTUtil.getToken(payload, secretKey);
|
239
|
228
|
payload.put("token", token);
|
240
|
|
- // 删除验证码
|
241
|
|
- delCaptchaCode(appUser.getPhoneNumber());
|
242
|
229
|
return payload;
|
243
|
230
|
}
|
244
|
231
|
|
|
@@ -253,13 +240,10 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
253
|
240
|
Map<String, String> payload = new HashMap<>();
|
254
|
241
|
payload.put("id", userId);
|
255
|
242
|
payload.put("phoneNumber", user.getPhonenumber());
|
256
|
|
-
|
257
|
243
|
String secretKey = PatientBaseUtil.getSecretKey(userId);
|
258
|
244
|
//生成JWt的令牌
|
259
|
245
|
String token = JWTUtil.getToken(payload, secretKey);
|
260
|
246
|
payload.put("token", token);
|
261
|
|
- // 删除验证码
|
262
|
|
- delCaptchaCode(user.getPhonenumber());
|
263
|
247
|
return payload;
|
264
|
248
|
}
|
265
|
249
|
|
|
@@ -325,9 +309,6 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
325
|
309
|
if (Objects.isNull(appUser)) {
|
326
|
310
|
return AjaxResult.error("用户不存在");
|
327
|
311
|
}
|
328
|
|
- if (checkCaptchaCode(phoneNumber, captchaCode)) {
|
329
|
|
- return AjaxResult.error("验证码错误");
|
330
|
|
- }
|
331
|
312
|
if (!password.equals(confirmPassword)) {
|
332
|
313
|
return AjaxResult.error("两次密码不一致");
|
333
|
314
|
}
|
|
@@ -337,8 +318,6 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
337
|
318
|
.eq(AppUser::getId, appUser.getId())
|
338
|
319
|
.set(AppUser::getPassword, SecurityUtils.encryptPassword(password)));
|
339
|
320
|
|
340
|
|
- // 删除验证码
|
341
|
|
- delCaptchaCode(phoneNumber);
|
342
|
321
|
return AjaxResult.success();
|
343
|
322
|
}
|
344
|
323
|
|
|
@@ -366,9 +345,6 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
366
|
345
|
if (StringUtils.isEmpty(captchaCode)) {
|
367
|
346
|
return AjaxResult.error("验证码不能为空");
|
368
|
347
|
}
|
369
|
|
- if (checkCaptchaCode(phoneNumber, captchaCode)) {
|
370
|
|
- return AjaxResult.error("验证码错误");
|
371
|
|
- }
|
372
|
348
|
// 注册过的手机号不允许绑定
|
373
|
349
|
if (appUserService.count(Wrappers.<AppUser>lambdaQuery().eq(AppUser::getPhoneNumber, phoneNumber)) > 0) {
|
374
|
350
|
return AjaxResult.error("您所设置的手机号已绑定");
|
|
@@ -390,8 +366,6 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
390
|
366
|
.eq(AppUser::getId, JWTUtil.getAppUserId())
|
391
|
367
|
.set(AppUser::getPhoneNumber, phoneNumber));
|
392
|
368
|
|
393
|
|
- // 删除验证码
|
394
|
|
- delCaptchaCode(phoneNumber);
|
395
|
369
|
return AjaxResult.success();
|
396
|
370
|
}
|
397
|
371
|
|
|
@@ -583,16 +557,10 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
583
|
557
|
@Override
|
584
|
558
|
public boolean register(Map<String, String> map) {
|
585
|
559
|
String phoneNumber = map.get("phoneNumber");
|
586
|
|
- if (checkCaptchaCode(phoneNumber, map.get("captchaCode"))) {
|
587
|
|
- throw new IllegalArgumentException("验证码错误");
|
588
|
|
- }
|
589
|
560
|
if (Objects.nonNull(getAppUserByPhoneNumber(phoneNumber))) {
|
590
|
561
|
throw new IllegalArgumentException("手机号已注册");
|
591
|
562
|
}
|
592
|
563
|
|
593
|
|
- // 删除验证码
|
594
|
|
- delCaptchaCode(phoneNumber);
|
595
|
|
-
|
596
|
564
|
// 添加用户
|
597
|
565
|
AppUser appUser = new AppUser();
|
598
|
566
|
appUser.setPhoneNumber(phoneNumber);
|
|
@@ -673,15 +641,27 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
673
|
641
|
*
|
674
|
642
|
* @param phoneNumber 手机号
|
675
|
643
|
* @param captchaCode 录入的验证码
|
676
|
|
- * @return 是否相同 已经取反
|
677
|
644
|
*/
|
678
|
|
- public boolean checkCaptchaCode(String phoneNumber, String captchaCode) {
|
|
645
|
+ @Override
|
|
646
|
+ public void checkCaptchaCode(String phoneNumber, String captchaCode) {
|
|
647
|
+ if (StringUtils.isEmpty(phoneNumber)) {
|
|
648
|
+ throw new IllegalArgumentException("手机号不能为空");
|
|
649
|
+ }
|
|
650
|
+ if (StringUtils.isEmpty(captchaCode)) {
|
|
651
|
+ throw new IllegalArgumentException("验证码不能为空");
|
|
652
|
+ }
|
|
653
|
+
|
679
|
654
|
String key = PatientConstant.ERM_APP_CAPTCHA_CODE + phoneNumber;
|
680
|
655
|
if (redisCache.hasKey(key)) {
|
681
|
656
|
int code = redisCache.getCacheObject(key);
|
682
|
|
- return !String.valueOf(code).equals(captchaCode);
|
|
657
|
+ boolean b = String.valueOf(code).equals(captchaCode);
|
|
658
|
+ if (b) {
|
|
659
|
+ // 删除验证码
|
|
660
|
+ delCaptchaCode(phoneNumber);
|
|
661
|
+ return;
|
|
662
|
+ }
|
683
|
663
|
}
|
684
|
|
- return true;
|
|
664
|
+ throw new IllegalArgumentException("验证码错误");
|
685
|
665
|
}
|
686
|
666
|
|
687
|
667
|
/**
|