From a79996fedf6be3af3292495d394e0f0250b71d4c Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期五, 28 六月 2024 17:50:41 +0800 Subject: [PATCH] bug修改 --- ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java | 64 +++++++++++++++++++++---------- 1 files changed, 43 insertions(+), 21 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 4c69795..aa54d0b 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 @@ -381,6 +381,18 @@ } } + @PostMapping("/studyPage") + @ApiOperation(value = "学习端", tags = {"启动页"}) + public R<String> studyPage() { + List<TPage> data = managementClient.getPage1().getData(); + for (TPage datum : data) { + if (datum.getType() == 1) { + return R.ok(datum.getImg()); + } + } + return R.ok(); + } + @PostMapping("/parentPage") @ApiOperation(value = "平板", tags = {"启动页"}) public R<String> parentPage() { @@ -503,7 +515,10 @@ if (null == userStudy) { TUserStudy study = new TUserStudy(); study.setUserId(tUser1.getId()); - study.setWeek(Constants.ONE); + // 学习周目 + TStudy tStudy = studyService.lambdaQuery().eq(TStudy::getQuarter, Constants.ONE) + .orderByAsc(TStudy::getWeek).last("limit 1").one(); + study.setWeek(tStudy.getWeek()); study.setDay(Constants.ONE); study.setTotalStudy(Constants.ZERO); study.setTodayStudy(Constants.ZERO); @@ -564,25 +579,6 @@ HashMap<String, Object> map = new HashMap<>(); // 获取登录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); } @@ -707,6 +703,9 @@ } TUser user = userService.lambdaQuery().eq(TUser::getId, loginUserStudy.getUserid()).one(); TUserStudy userStudy = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, user.getId()).eq(TUserStudy::getDisabled, 0).one(); + if (null == userStudy) { + userStudy = createUserStudy(loginUserStudy.getUserid()); + } // 学习时长格式转换 Integer todayStudy = userStudy.getTodayStudy(); userStudy.setTodayStudy(Math.round((float) todayStudy / 3600)); @@ -722,7 +721,30 @@ Integer totalStudy = userStudy.getTotalStudy(); userStudy.setTotalStudy(Math.round((float) (totalStudy + sum) / 3600)); return R.ok(new UserPersonalCenterVO(user, userStudy)); - }@GetMapping("/userInfoParent") + } + + private TUserStudy createUserStudy(Integer userid) { + TUserStudy userStudy = new TUserStudy(); + userStudy.setUserId(userid); + // 学习周目 + TStudy tStudy = studyService.lambdaQuery().eq(TStudy::getQuarter, Constants.ONE) + .orderByAsc(TStudy::getWeek).last("limit 1").one(); + userStudy.setWeek(tStudy.getWeek()); + userStudy.setDay(Constants.ONE); + userStudy.setTotalStudy(Constants.ZERO); + userStudy.setTodayStudy(Constants.ZERO); + userStudy.setWeekStudy(Constants.ZERO); + userStudy.setMonthStudy(Constants.ZERO); + userStudy.setListen(Constants.BURDEN_ONE); + userStudy.setLook(Constants.BURDEN_ONE); + userStudy.setInduction(Constants.BURDEN_ONE); + userStudy.setAnswer(Constants.BURDEN_ONE); + userStudy.setPair(Constants.BURDEN_ONE); + userStudyService.save(userStudy); + return userStudy; + } + + @GetMapping("/userInfoParent") @ApiOperation(value = "用户详情", tags = {"家长端-用户详情"}) public R<TUser> userInfoParent() { LoginUserParent loginUserStudy = tokenService.getLoginUser1(); -- Gitblit v1.7.1