无关风月
2024-07-02 fb9f95e888411a348652f4bd210bd998fee01afd
ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java
@@ -111,7 +111,7 @@
                wrapper.isNotNull("error");
                List<TStory> list1 = storyService.list(wrapper);
                for (TStory tStory : list1) {
                    if (tStory.getError()!=null && (!tStory.equals(""))){
                    if (tStory.getError()!=null && (!tStory.getError().isEmpty())){
                        tStories.add(tStory);
                    }
                }
@@ -738,6 +738,7 @@
            int sum = gameRecordList.stream().map(TGameRecord::getUseTime).mapToInt(Integer::intValue).sum();
            Integer totalStudy = studyRecord.getTotalStudy();
            studyRecord.setTotalStudy(Math.round((float) (totalStudy + sum) / 3600));
            studyRecord = studyService.studySchedule(studyRecord,week);
        }
        return R.ok(studyRecord);
    }
@@ -962,6 +963,31 @@
    }
    /**
     * 退出游戏/故事学习
     */
    @GetMapping("/exitGameOrStory")
    @ApiOperation(value = "退出游戏/故事学习", tags = {"学习端-题目"})
    public R<Boolean> exitGameOrStory(@RequestParam Integer studyTime) {
        LoginUserParent loginStudy = tokenService.getLoginUserStudy();
        if (null == loginStudy) {
            return R.tokenError("登录失效!");
        }
        Integer userid = loginStudy.getUserid();
        // 判断当前week和day是否已完成学习
        TUserStudy userStudy = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userid)
                .eq(TUserStudy::getDisabled, 0).one();
        if (null == userStudy) {
            userStudy = createUserStudy(userid);
        }
        // 学习时长更新
        userStudy.setTotalStudy(userStudy.getTotalStudy() + studyTime);
        userStudy.setTodayStudy(userStudy.getTodayStudy() + studyTime);
        userStudy.setWeekStudy(userStudy.getWeekStudy() + studyTime);
        userStudy.setMonthStudy(userStudy.getMonthStudy() + studyTime);
        return R.ok(userStudyService.updateById(userStudy));
    }
    /**
     * 自主学习1-听音选图
     *
     * @param week 周目