From 72d4afb7b0f12753846ffb9baf0d593635df55a3 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期二, 18 六月 2024 15:47:55 +0800 Subject: [PATCH] bug修改 --- ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java | 71 ++++++++++++++++++++++------------- 1 files changed, 45 insertions(+), 26 deletions(-) diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java index 9e3043c..5017009 100644 --- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java +++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java @@ -3,6 +3,7 @@ import com.alipay.api.AlipayApiException; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.common.core.constant.Constants; import com.ruoyi.common.core.constant.RedisConstants; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.exception.GlobalException; @@ -104,6 +105,7 @@ @Autowired private PayMoneyUtil payMoneyUtil; + @PostMapping("/pay") @ApiOperation(value = "购买会员支付操作", tags = {"家长端-个人中心"}) @ApiImplicitParams({ @@ -132,6 +134,7 @@ } return AjaxResult.success(); } + @PostMapping("/order") @ApiOperation(value = "购买会员下单操作", tags = {"家长端-个人中心"}) @ApiImplicitParams({ @@ -422,6 +425,7 @@ } return R.ok(data); } + @PostMapping("/useGuideGetInfo") @ApiOperation(value = "查看详情", tags = {"家长端-使用指南"}) public R useGuideGetInfo(Integer id) { @@ -430,7 +434,7 @@ useGuideQuery.setPageSize(300); PageInfo<TUseGuide> data = managementClient.useGuide1(useGuideQuery).getData(); for (TUseGuide record : data.getRecords()) { - if (record.getId() == id){ + if (record.getId() == id) { return R.ok(record.getAnswer()); } } @@ -506,6 +510,19 @@ public R<Map<String, Object>> studyLogin(@RequestBody RegisterPhoneRequest phoneRequest) { 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("登录失败,验证码无效!"); + } + } + // 获取手机号所注册用户信息 TUser user = userService.getOne(new QueryWrapper<TUser>() .ne("state", 3) .eq("phone", phone)); @@ -514,26 +531,8 @@ return R.freeze("登录失败,您的账号已被冻结!"); } } else { - if (!phoneCode.equals("123456")) { - // 手机验证码校验 - 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("登录失败,验证码无效!"); - } else { - user = getUser(phone); - userService.save(user); - } - } - } else { - user = getUser(phone); - userService.save(user); - } + user = getUser(phone); + userService.save(user); } // 生成登录用户信息 LoginUserParent loginUserParent = new LoginUserParent(); @@ -542,8 +541,27 @@ loginUserParent.setPhone(user.getPhone()); loginUserParent.setLoginTime(System.currentTimeMillis()); HashMap<String, Object> map = new HashMap<>(); - map.put("token", tokenService.createTokenStudy(loginUserParent)); // 获取登录token + map.put("token", tokenService.createTokenStudy(loginUserParent)); + // 学习进度检查 + TUserStudy userStudy = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, user.getId()) + .eq(TUserStudy::getDisabled, 0).one(); + if (null == userStudy) { + TUserStudy study = new TUserStudy(); + study.setUserId(user.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); } @@ -661,9 +679,10 @@ */ @GetMapping("/userInfo") @ApiOperation(value = "用户详情", tags = {"学习端-用户详情"}) - public R<TUser> userInfo() { - - return R.ok(userService.lambdaQuery().eq(TUser::getId, tokenService.getLoginUserStudy().getUserid()).one()); + public R<UserPersonalCenterVO> userInfo() { + TUser user = userService.lambdaQuery().eq(TUser::getId, tokenService.getLoginUserStudy().getUserid()).one(); + TUserStudy userStudy = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, user.getId()).eq(TUserStudy::getDisabled, 0).one(); + return R.ok(new UserPersonalCenterVO(user, userStudy)); } @PostMapping("/deleteUser") @@ -733,7 +752,7 @@ byId.setPhone(phone); } // 手机验证码校验 - if (StringUtils.hasLength(phoneCode)){ + if (StringUtils.hasLength(phoneCode)) { if (!phoneCode.equals("123456")) { Object redisPhoneCode = redisService.getCacheObject(RedisConstants.PHONE_CODE + phone); if (null == redisPhoneCode) { -- Gitblit v1.7.1