hjl
2024-07-18 9c417afa127156025810f8637a6eb99f9233469f
ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java
@@ -83,6 +83,68 @@
    @Resource
    private ITUserPresentRecordService userPresentRecordService;
    @PostMapping("/testAddData")
    @ApiOperation(value = "测试分片", tags = {"测试分片"})
    public R<Object> testAddData() {
        TIntegralRecord tIntegralRecord = new TIntegralRecord();
        tIntegralRecord.setIntegral("1");
        tIntegralRecord.setMethod("1");
        tIntegralRecord.setUserId(23);
        tIntegralRecord.setGameId(1);
        tIntegralRecord.setGameDifficulty(1);
        tIntegralRecord.setStoryId(1);
        tIntegralRecord.setStoryType(1);
        integralRecordService.save(tIntegralRecord);
        TGameRecord tGameRecord = new TGameRecord();
        tGameRecord.setUserId(33);
        tGameRecord.setAccuracy(0);
        tGameRecord.setGameName("");
        tGameRecord.setUseTime(0);
        tGameRecord.setUseTime1("");
        tGameRecord.setGameId(0);
        tGameRecord.setGameDifficulty(0);
        tGameRecord.setTime("");
        tGameRecord.setDisabled(false);
        tGameRecord.setCreateBy("");
        tGameRecord.setCreateTime(new Date());
        tGameRecord.setUpdateBy("");
        tGameRecord.setUpdateTime(new Date());
        gameRecordService.save(tGameRecord);
        TSubjectRecord tSubjectRecord = new TSubjectRecord();
        tSubjectRecord.setUserId(22);
        tSubjectRecord.setWeek(0);
        tSubjectRecord.setDay(0);
        tSubjectRecord.setBeforeSubject("");
        tSubjectRecord.setType(0);
        tSubjectRecord.setCompleteSubject("");
        tSubjectRecord.setAnswerNumber(0);
        tSubjectRecord.setCorrectNumber(0);
        tSubjectRecord.setDisabled(false);
        tSubjectRecord.setCreateBy("");
        tSubjectRecord.setCreateTime(new Date());
        tSubjectRecord.setUpdateBy("");
        tSubjectRecord.setUpdateTime(new Date());
        subjectRecordService.save(tSubjectRecord);
        TUserPresentRecord tUserPresentRecord = new TUserPresentRecord();
        tUserPresentRecord.setUserId(44);
        tUserPresentRecord.setPresentTime(new Date());
        tUserPresentRecord.setIsDelete(0);
        userPresentRecordService.save(tUserPresentRecord);
        TUserStudyRecord tUserStudyRecord = new TUserStudyRecord();
        tUserStudyRecord.setUserId(17);
        tUserStudyRecord.setQuarter(0);
        tUserStudyRecord.setWeek(0);
        tUserStudyRecord.setDay(0);
        tUserStudyRecord.setObtainedIntegral(0);
        tUserStudyRecord.setType(0);
        tUserStudyRecord.setStudyType(0);
        tUserStudyRecord.setStoryId(0);
        studyRecordService.save(tUserStudyRecord);
        return R.ok();
    }
    @PostMapping("/storyList")
//    @ApiOperation(value = "配置学习类型选择故事", tags = {"题目管理"})
    public R<PageInfo<TStory>> storyList(@RequestBody ChoiceStory query) {
@@ -702,6 +764,22 @@
    @ApiOperation(value = "获取正确及错误提示音效", tags = {"学习端-首页"})
    public R<TSysSet> promptVoice() {
        return R.ok(managementClient.promptVoice().getData());
    }
    /**
     * 获取当前季度游戏难度
     */
    @GetMapping("/userGameDifficulty")
    @ApiOperation(value = "获取当前季度游戏难度", tags = {"学习端-首页"})
    public R<Integer> userGameDifficulty(@RequestParam Integer week) {
        LoginUserParent loginStudy = tokenService.getLoginUserStudy();
        if (null == loginStudy) {
            return R.tokenError("登录失效!");
        }
        Integer userid = loginStudy.getUserid();
        TUserStudy studyRecord = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userid)
                .eq(TUserStudy::getDisabled, 0).one();
        return R.ok(studyService.userGameDifficulty(studyRecord, week));
    }
    /**
@@ -1731,6 +1809,7 @@
                .eq(TGameRecord::getDisabled, 0)
                .orderByDesc(TGameRecord::getCreateTime)
                .list();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm");
        if (null != studyRecord) {
            // 学习时长格式转换
            Integer todayStudy = studyRecord.getTodayStudy();
@@ -1743,6 +1822,9 @@
            int sum = gameRecordList.stream().map(TGameRecord::getUseTime).mapToInt(Integer::intValue).sum();
            Integer totalStudy = studyRecord.getTotalStudy();
            studyRecord.setTotalStudy(Math.round((float) (totalStudy) / 3600));
            for (TGameRecord tGameRecord : gameRecordList) {
                tGameRecord.setTime(simpleDateFormat.format(tGameRecord.getCreateTime()));
            }
            // 剩余周目
            List<TStudy> studyList = studyService.lambdaQuery().eq(TStudy::getDisabled, 0)
                    .eq(TStudy::getType, Constants.ONE)
@@ -1839,6 +1921,9 @@
    @GetMapping("/getIntegral")
    @ApiOperation(value = "获取剩余积分", tags = {"家长端-获取剩余积分"})
    public R<Integer> getIntegral() {
        if (tokenService.getLoginUser1() == null) {
            return R.tokenError("登录失效");
        }
        Integer userId = tokenService.getLoginUser1().getUserid();
        return R.ok(userService.getById(userId).getIntegral());
    }