Browse Source

fix: APP登录、注册、添加就诊人验证短信验证码拆成一个单独的接口

matianxiang 3 months ago
parent
commit
5424370573

+ 7 - 0
eitc-patient-app/src/main/java/com/eitc/patient/controller/AppLoginController.java

@@ -94,6 +94,13 @@ public class AppLoginController extends BaseController {
94
         return appUserService.sendCaptchaCode(phoneNumber);
94
         return appUserService.sendCaptchaCode(phoneNumber);
95
     }
95
     }
96
 
96
 
97
+    @PostMapping("/checkCaptchaCode")
98
+    @ApiOperation("验证短信验证码")
99
+    public AjaxResult checkCaptchaCode(String phoneNumber, String captchaCode) {
100
+        appUserService.checkCaptchaCode(phoneNumber, captchaCode);
101
+        return success();
102
+    }
103
+
97
     /**
104
     /**
98
      * 退出登录
105
      * 退出登录
99
      *
106
      *

+ 2 - 2
eitc-patient-base/src/main/java/com/eitc/patient/domain/NoticeManage.java

@@ -37,13 +37,13 @@ public class NoticeManage extends EitcBaseEntity {
37
 
37
 
38
     @TableField(value = "notice_start_time")
38
     @TableField(value = "notice_start_time")
39
     @ApiModelProperty(value = "公告开始时间", name = "noticeStartTime")
39
     @ApiModelProperty(value = "公告开始时间", name = "noticeStartTime")
40
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
40
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
41
     @NotNull(message = "公告开始时间不能为空")
41
     @NotNull(message = "公告开始时间不能为空")
42
     private Date noticeStartTime;
42
     private Date noticeStartTime;
43
 
43
 
44
     @TableField(value = "notice_end_time")
44
     @TableField(value = "notice_end_time")
45
     @ApiModelProperty(value = "公告结束时间", name = "noticeEndTime")
45
     @ApiModelProperty(value = "公告结束时间", name = "noticeEndTime")
46
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
46
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
47
     @NotNull(message = "公告结束时间不能为空")
47
     @NotNull(message = "公告结束时间不能为空")
48
     private Date noticeEndTime;
48
     private Date noticeEndTime;
49
 
49
 

+ 7 - 2
eitc-patient-base/src/main/java/com/eitc/patient/mapper/AppUserMapper.java

@@ -15,8 +15,13 @@ import org.apache.ibatis.annotations.Update;
15
 @Mapper
15
 @Mapper
16
 public interface AppUserMapper extends BaseMapper<AppUser> {
16
 public interface AppUserMapper extends BaseMapper<AppUser> {
17
 
17
 
18
-
19
-
18
+    /**
19
+     * 回复删除数据
20
+     *
21
+     * @param id id
22
+     * @author mtx
23
+     * @date: 2024/6/13 10:33
24
+     */
20
     int updateRevert(@Param("id") String id);
25
     int updateRevert(@Param("id") String id);
21
 
26
 
22
 }
27
 }

+ 8 - 0
eitc-patient-base/src/main/java/com/eitc/patient/service/IAppUserService.java

@@ -107,6 +107,14 @@ public interface IAppUserService extends IService<AppUser> {
107
     AjaxResult synchronizeData(AppUser beforeAppUser);
107
     AjaxResult synchronizeData(AppUser beforeAppUser);
108
 
108
 
109
     /**
109
     /**
110
+     * 验证短信验证码时候正确
111
+     *
112
+     * @param phoneNumber 手机号
113
+     * @param captchaCode 录入的验证码
114
+     */
115
+    void checkCaptchaCode(String phoneNumber, String captchaCode);
116
+
117
+    /**
110
      * 退出登录
118
      * 退出登录
111
      */
119
      */
112
     void logout();
120
     void logout();

+ 16 - 36
eitc-patient-base/src/main/java/com/eitc/patient/service/impl/AppUserServiceImpl.java

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

+ 3 - 2
eitc-patient-pc/src/main/java/com/eitc/patient/controller/NoticeManageController.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
5
 import com.eitc.common.annotation.Log;
5
 import com.eitc.common.annotation.Log;
6
 import com.eitc.common.core.controller.BaseController;
6
 import com.eitc.common.core.controller.BaseController;
7
 import com.eitc.common.core.domain.AjaxResult;
7
 import com.eitc.common.core.domain.AjaxResult;
8
+import com.eitc.common.core.page.TableDataInfo;
8
 import com.eitc.common.enums.BusinessType;
9
 import com.eitc.common.enums.BusinessType;
9
 import com.eitc.common.utils.StringUtils;
10
 import com.eitc.common.utils.StringUtils;
10
 import com.eitc.patient.domain.NoticeManage;
11
 import com.eitc.patient.domain.NoticeManage;
@@ -44,14 +45,14 @@ public class NoticeManageController extends BaseController {
44
      */
45
      */
45
     @GetMapping("/list")
46
     @GetMapping("/list")
46
     @ApiOperation("查询公告管理")
47
     @ApiOperation("查询公告管理")
47
-    public AjaxResult list(NoticeManage noticeManage) {
48
+    public TableDataInfo list(NoticeManage noticeManage) {
48
         startPage();
49
         startPage();
49
         LambdaQueryWrapper<NoticeManage> wrapper = Wrappers.<NoticeManage>lambdaQuery().orderByDesc(NoticeManage::getCreateDate)
50
         LambdaQueryWrapper<NoticeManage> wrapper = Wrappers.<NoticeManage>lambdaQuery().orderByDesc(NoticeManage::getCreateDate)
50
                 .like(StringUtils.isNotBlank(noticeManage.getNoticeTitle()), NoticeManage::getNoticeTitle, noticeManage.getNoticeTitle())
51
                 .like(StringUtils.isNotBlank(noticeManage.getNoticeTitle()), NoticeManage::getNoticeTitle, noticeManage.getNoticeTitle())
51
                 .like(Objects.nonNull(noticeManage.getPublishStatus()), NoticeManage::getPublishStatus, noticeManage.getPublishStatus())
52
                 .like(Objects.nonNull(noticeManage.getPublishStatus()), NoticeManage::getPublishStatus, noticeManage.getPublishStatus())
52
                 .like(Objects.nonNull(noticeManage.getDisplayStatus()), NoticeManage::getDisplayStatus, noticeManage.getDisplayStatus());
53
                 .like(Objects.nonNull(noticeManage.getDisplayStatus()), NoticeManage::getDisplayStatus, noticeManage.getDisplayStatus());
53
         List<NoticeManage> list = noticeManageService.list(wrapper);
54
         List<NoticeManage> list = noticeManageService.list(wrapper);
54
-        return success(list);
55
+        return getDataTable(list);
55
     }
56
     }
56
 
57
 
57
     /**
58
     /**