hjl
2024-06-19 ee0ef084a9750338a118ac577af679e8549444da
ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java
@@ -493,10 +493,29 @@
        loginUserParent.setName(tUser1.getName());
        loginUserParent.setUserid(tUser1.getId());
        loginUserParent.setPhone(tUser1.getPhone());
        loginUserParent.setLoginTime(new Date().getTime());
        loginUserParent.setLoginTime(System.currentTimeMillis());
        HashMap<String, Object> map = new HashMap<>();
        map.put("token", tokenService.createToken1(loginUserParent));
        // 获取登录token
        map.put("token", tokenService.createToken1(loginUserParent));
        // 学习进度检查
        TUserStudy userStudy = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, tUser1.getId())
                .eq(TUserStudy::getDisabled, 0).one();
        if (null == userStudy) {
            TUserStudy study = new TUserStudy();
            study.setUserId(tUser1.getId());
            study.setWeek(Constants.ONE);
            study.setDay(Constants.ONE);
            study.setTotalStudy(Constants.ZERO);
            study.setTodayStudy(Constants.ZERO);
            study.setWeekStudy(Constants.ZERO);
            study.setMonthStudy(Constants.ZERO);
            study.setListen(Constants.BURDEN_ONE);
            study.setLook(Constants.BURDEN_ONE);
            study.setInduction(Constants.BURDEN_ONE);
            study.setAnswer(Constants.BURDEN_ONE);
            study.setPair(Constants.BURDEN_ONE);
            userStudyService.save(study);
        }
        return R.ok(map);
    }
@@ -511,17 +530,17 @@
        String phone = phoneRequest.getPhone();
        String phoneCode = phoneRequest.getPhoneCode();
        // 验证码校验
//        Object redisPhoneCode = redisService.getCacheObject(RedisConstants.PHONE_CODE + phone);
//        if (null == redisPhoneCode) {
//            return R.errorCode("登录失败,验证码无效!");
//        } else {
//            // redis 验证码的value 为 code:时间戳
//            String rCodeAndTime = String.valueOf(redisPhoneCode);
//            String rCode = rCodeAndTime.split(":")[0];
//            if (!rCode.equalsIgnoreCase(phoneCode)) {
//                return R.errorCode("登录失败,验证码无效!");
//            }
//        }
        Object redisPhoneCode = redisService.getCacheObject(RedisConstants.PHONE_CODE + phone);
        if (null == redisPhoneCode) {
            return R.errorCode("登录失败,验证码无效!");
        } else {
            // redis 验证码的value 为 code:时间戳
            String rCodeAndTime = String.valueOf(redisPhoneCode);
            String rCode = rCodeAndTime.split(":")[0];
            if (!rCode.equalsIgnoreCase(phoneCode) || !"123456".equals(phoneCode)) {
                return R.errorCode("登录失败,验证码无效!");
            }
        }
        // 获取手机号所注册用户信息
        TUser user = userService.getOne(new QueryWrapper<TUser>()
                .ne("state", 3)