44323
2024-06-06 3be01520d00eaba7a9d058927b7255753c351351
ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java
@@ -461,20 +461,20 @@
                .eq("phone", phone));
        if (tUser1 != null) {
            if (tUser1.getState() == 2) {
                throw new GlobalException("登录失败,您的账号已被冻结!");
                return R.freeze("登录失败,您的账号已被冻结!");
            }
        } else {
            // 手机验证码校验
            if (!phoneCode.equals("123456")) {
                Object redisPhoneCode = redisService.getCacheObject(RedisConstants.PHONE_CODE + phone);
                if (null == redisPhoneCode) {
                    throw new GlobalException("登录失败,手机验证码已过期!");
                    return R.errorCode("登录失败,手机验证码无效!");
                } else {
                    // redis 验证码的value 为 code:时间戳
                    String rCodeAndTime = String.valueOf(redisPhoneCode);
                    String rCode = rCodeAndTime.split(":")[0];
                    if (!rCode.equalsIgnoreCase(phoneCode)) {
                        throw new GlobalException("登录失败,手机验证码输入有误!");
                        return R.errorCode("登录失败,手机验证码无效!");
                    } else {
                        tUser1 = getUser(phone);
                        userService.save(tUser1);
@@ -592,7 +592,7 @@
    @ApiImplicitParams({
            @ApiImplicitParam(value = "手机号", name = "phone", dataType = "string", required = true),
    })
    public R<?> sendPhoneCode(@RequestParam String phone) {
    public R<?> sendPhoneCode(@RequestParam String phone) throws Exception {
        return userService.phoneCode(phone) ? R.ok() : R.fail();
    }