From 3407c10808d75f2f9340a030f90191ecafa055a2 Mon Sep 17 00:00:00 2001
From: hjl <1657978663@qq.com>
Date: 星期五, 07 六月 2024 19:22:35 +0800
Subject: [PATCH] feat: 修复学习端bug

---
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java       |   23 +-
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/domain/TGame.java                         |    6 
 ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TGameMapper.xml                         |   12 +
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/mapper/TGameMapper.java                   |    9 +
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITStoryListenService.java         |   10 +
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/dto/CompleteGameDTO.java                  |    8 -
 ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TStudyMapper.xml                        |   40 +++-
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITGameService.java                |   21 ++
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStoryListenServiceImpl.java |    6 
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TGameServiceImpl.java        |   16 +
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java          |  200 +++++++++++++++++++---------
 ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TStoryListenMapper.xml                  |    4 
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/mapper/TStoryListenMapper.java            |   11 +
 ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/Constants.java        |   20 ++
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/vo/StudyStoryListenResultVO.java          |   16 +
 15 files changed, 286 insertions(+), 116 deletions(-)

diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/Constants.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/Constants.java
index a97c9c4..cb8ae8a 100644
--- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/Constants.java
+++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/Constants.java
@@ -159,6 +159,16 @@
     public static final Integer SIXTY = 60;
 
     /**
+     * - 前缀
+     */
+    public static final String REDUCE = "-";
+
+    /**
+     * 空字符串
+     */
+    public static final String EMPTY_STR = "";
+
+    /**
      * 0数字
      */
     public static final Integer ZERO = 0;
@@ -285,4 +295,14 @@
      */
     public static final String COMPLETE_STORY= "完成听故事";
 
+    /**
+     * 超级听力
+     */
+    public static final String HEARING= "超级听力";
+
+    /**
+     * 超级听力
+     */
+    public static final String MEMORY= "超级记忆";
+
 }
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java
index 8fd86f9..c21c71f 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java
@@ -4,7 +4,6 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 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;
 import com.ruoyi.common.core.web.page.PageInfo;
@@ -28,7 +27,6 @@
 
 import javax.annotation.Resource;
 import java.util.*;
-import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 /**
@@ -658,9 +656,6 @@
     }
 
 
-
-
-
     /**
      * 可兑换商品推荐
      */
@@ -669,6 +664,7 @@
     public R<List<TGoodsVO>> studySchedule() {
         return R.ok(goodsClient.goodRecommend().getData());
     }
+
     /**
      * 首次页面加载时调用,获取学习进度及学习时长等信息
      *
@@ -685,6 +681,7 @@
         TUserStudy result = studyService.studySchedule(String.valueOf(tokenService.getLoginUserStudy().getUserid()), week);
         return R.ok(result);
     }
+
     /**
      * 查询周目列表
      *
@@ -701,6 +698,7 @@
         List<StudyWeekDTO> result = studyService.weekList(type, quarter);
         return R.ok(result);
     }
+
     /**
      * 进入题组后,获取题组学习进度信息
      *
@@ -948,72 +946,112 @@
     @GetMapping("/gameHearing")
     @ApiOperation(value = "自主游戏1-超级听力", tags = {"学习端-听-自主游戏"})
     @ApiImplicitParams({
+            @ApiImplicitParam(value = "季度", name = "quarter", dataType = "Integer", required = true),
             @ApiImplicitParam(value = "难度(0入门、1中级、2困难)", name = "difficulty", dataType = "Integer", required = true),
             @ApiImplicitParam(value = "所属周目", name = "week", dataType = "Integer", required = true)
     })
-    public R<StudyGamerResultVO> gameHearing(@RequestParam Integer difficulty, @RequestParam Integer week) {
-        TGame game = gameService.lambdaQuery().eq(TGame::getWeek, week)
-                .eq(TGame::getDisabled, 0).one();
+    public R<StudyGamerResultVO> gameHearing(@RequestParam Integer quarter, @RequestParam Integer difficulty, @RequestParam Integer week) {
+        TGame game = gameService.gameHearing(quarter, week);
+        if (null == game) {
+            throw new GlobalException("当前季度该周目暂无配置游戏数据!");
+        }
         game.setIntegral(game.getIntegral().split(",")[difficulty]);
         game.setTime(game.getTime().split(",")[difficulty]);
         // 检验是否完成难度
         studyService.checkDifficulty(difficulty, week, game);
         List<String> subjectId = getSubjectId(week);
+        List<String> newSubjectId = subjectId.stream().map(data -> {
+            if (data.startsWith(Constants.REDUCE)) {
+                data = data.replace(Constants.REDUCE, Constants.EMPTY_STR);
+            }
+            return data;
+        }).distinct().collect(Collectors.toList());
         // 判断周目下题目是否足够
-        if (subjectId.size() < game.getCount()) {
+        if (newSubjectId.size() < game.getCount()) {
             throw new GlobalException("当前周目下day1 - day5题目不足!");
         }
         // 根据游戏设置数量获取图片及语音
         List<String> subjectData = new ArrayList<>();
         Random random = new Random();
         // 获取列表大小
-        int dataSize = subjectId.size();
+        int dataSize = newSubjectId.size();
         // 生成随机索引并获取数据
         for (int i = 0; i < game.getCount(); i++) {
             // 生成随机索引
             int randomIndex = random.nextInt(dataSize);
             // 获取对应的数据并加入结果列表
-            subjectData.add(subjectId.get(randomIndex));
+            subjectData.add(newSubjectId.get(randomIndex));
+            newSubjectId.remove(randomIndex);
+            dataSize = newSubjectId.size();
         }
-        return R.ok(new StudyGamerResultVO(game,
-                subjectService.lambdaQuery().in(TSubject::getId, subjectData).eq(TSubject::getState, 1).list()));
+        List<TSubject> subjectList = getSubjectList(subjectData);
+        return R.ok(new StudyGamerResultVO(game, subjectList));
     }
 
     /**
      * 自主游戏2-超级记忆
      *
-     * @param difficulty 难度(0入门、1中级、2困难)
-     * @param week       所属周目
+     * @param quarter 季度
+     * @param week    所属周目
      */
     @GetMapping("/gameMemory")
     @ApiOperation(value = "自主游戏2-超级记忆", tags = {"学习端-听-自主游戏"})
     @ApiImplicitParams({
-            @ApiImplicitParam(value = "难度(0入门、1中级、2困难)", name = "difficulty", dataType = "Integer", required = true),
+            @ApiImplicitParam(value = "季度", name = "quarter", dataType = "Integer", required = true),
             @ApiImplicitParam(value = "所属周目", name = "week", dataType = "Integer", required = true)
     })
-    public R<StudyGamerResultVO> gameMemory(@RequestParam Integer difficulty, @RequestParam Integer week) {
-        TGame game = gameService.lambdaQuery().eq(TGame::getWeek, week).eq(TGame::getDisabled, 0).one();
-        // 检验是否完成难度
-        studyService.checkDifficulty(difficulty, week, game);
+    public R<StudyGamerResultVO> gameMemory(@RequestParam Integer quarter, @RequestParam Integer week) {
+        TGame game = gameService.gameHearing(quarter, week);
+        if (null == game) {
+            throw new GlobalException("当前季度该周目暂无配置游戏数据!");
+        }
         List<String> subjectId = getSubjectId(week);
+        List<String> newSubjectId = subjectId.stream().map(data -> {
+            if (data.startsWith(Constants.REDUCE)) {
+                data = data.replace(Constants.REDUCE, Constants.EMPTY_STR);
+            }
+            return data;
+        }).distinct().collect(Collectors.toList());
         // 判断周目下题目是否足够
-        if (subjectId.size() < game.getCount()) {
+        if (newSubjectId.size() < game.getAnswerCount()) {
             throw new GlobalException("当前周目下day1 - day5题目不足!");
         }
         // 根据游戏设置数量获取图片及语音
         List<String> subjectData = new ArrayList<>();
         Random random = new Random();
         // 获取列表大小
-        int dataSize = subjectId.size();
+        int dataSize = newSubjectId.size();
         // 生成随机索引并获取数据
         for (int i = 0; i < game.getCount(); i++) {
             // 生成随机索引
             int randomIndex = random.nextInt(dataSize);
             // 获取对应的数据并加入结果列表
-            subjectData.add(subjectId.get(randomIndex));
+            subjectData.add(newSubjectId.get(randomIndex));
+            newSubjectId.remove(randomIndex);
+            dataSize = newSubjectId.size();
         }
-        return R.ok(new StudyGamerResultVO(game,
-                subjectService.lambdaQuery().in(TSubject::getId, subjectData).eq(TSubject::getState, 1).list()));
+        List<TSubject> subjectList = getSubjectList(subjectData);
+        // 格子翻倍,前端需要做连连看
+        List<TSubject> resultList = new ArrayList<>();
+        for (int i = 0; i < Constants.TWO; i++) {
+            resultList.addAll(subjectList);
+        }
+        // 框架记忆数量翻倍,前端需要根据数量画格子
+        game.setAnswerCount(game.getAnswerCount() * 2);
+        return R.ok(new StudyGamerResultVO(game, resultList));
+    }
+
+    private List<TSubject> getSubjectList(List<String> subjectData) {
+        List<TSubject> subjectList = new ArrayList<>();
+        for (String subjectDatum : subjectData) {
+            if (subjectDatum.startsWith("-")) {
+                subjectDatum = subjectDatum.replace("-", "");
+            }
+            TSubject subject = subjectService.lambdaQuery().eq(TSubject::getId, subjectDatum)
+                    .eq(TSubject::getState, 1).one();
+            subjectList.add(subject);
+        }
+        return subjectList;
     }
 
     /**
@@ -1031,11 +1069,25 @@
          * 例如:游戏配置的积分是100,他的正确率是50%那么拿50分,下次他再玩这个游戏 正确率是60% 那么他该获得60分 但是上次已经拿了50 所以这次就只给他加10积分
          */
         Integer userid = tokenService.getLoginUserStudy().getUserid();
-        TGame game = gameService.getById(completeStudy.getGameId());
+        TGame game = gameService.lambdaQuery().eq(TGame::getId, completeStudy.getGameId()).eq(TGame::getDisabled, 0).one();
+        if (null == game) {
+            throw new GlobalException("游戏信息异常!");
+        }
         // 积分明细
         List<TIntegralRecord> integralRecordList = integralRecordService.lambdaQuery().eq(TIntegralRecord::getUserId, userid)
                 .eq(TIntegralRecord::getGameId, game.getId()).eq(TIntegralRecord::getDisabled, 0).list();
-        Integer availableIntegral = gameService.countIntegral(userid, game, completeStudy, integralRecordList);
+        // 本次游戏总共能获取的积分数量
+        Integer integral;
+        if (completeStudy.getGameName().equals(Constants.HEARING)) {
+            // 本次游戏总积分
+            integral = Integer.parseInt(game.getIntegral().split(",")[completeStudy.getDifficulty()]);
+        } else if (completeStudy.getGameName().equals(Constants.MEMORY)) {
+            integral = game.getAnswerIntegral();
+        } else {
+            throw new GlobalException("该次游戏积分计算异常!");
+        }
+        int gameAvailableIntegral = integral * (completeStudy.getAccuracy() / 100);
+        Integer availableIntegral = gameService.countIntegral(userid, game, completeStudy, gameAvailableIntegral, integralRecordList);
         // 游戏测试记录
         Boolean add = gameRecordService.add(completeStudy);
         // 可获得积分不为null时,才添加积分明细记录
@@ -1051,27 +1103,31 @@
 
     private List<String> getSubjectId(Integer week) {
         // 当前week下day1 - day5所有题目
-        List<String> subjectId = redisService.getCacheList(RedisConstants.HEARING_TREE);
-        if (null == subjectId || subjectId.isEmpty()) {
-            List<String> listenSubject = studyListenService.lambdaQuery().eq(TStudyListen::getWeek, week)
-                    .eq(TStudyListen::getDisabled, 0).list().stream().map(TStudyListen::getSubject).collect(Collectors.toList());
-            List<String> inductionSubject = studyInductionService.lambdaQuery().eq(TStudyInduction::getWeek, week)
-                    .eq(TStudyInduction::getDisabled, 0).list().stream().map(TStudyInduction::getSubject).collect(Collectors.toList());
-            List<String> lookSubject = studyLookService.lambdaQuery().eq(TStudyLook::getWeek, week)
-                    .eq(TStudyLook::getDisabled, 0).list().stream().map(TStudyLook::getSubject).collect(Collectors.toList());
-            List<String> pairSubject = studyPairService.lambdaQuery().eq(TStudyPair::getWeek, week)
-                    .eq(TStudyPair::getDisabled, 0).list().stream().map(TStudyPair::getSubject).collect(Collectors.toList());
-            listenSubject.addAll(inductionSubject);
-            listenSubject.addAll(lookSubject);
-            listenSubject.addAll(pairSubject);
-            // 获取具体subject信息
-            subjectId = new ArrayList<>();
-            for (String subject : listenSubject) {
-                subjectId.addAll(Arrays.asList(subject.split(",")));
-            }
-            redisService.setCacheList(RedisConstants.HEARING_TREE, subjectId);
-            redisService.expire(RedisConstants.HEARING_TREE, RedisConstants.THIRTY, TimeUnit.MINUTES);
+        List<String> subjectId = new ArrayList<>();
+        List<String> listenSubject = studyListenService.lambdaQuery().eq(TStudyListen::getWeek, week)
+                .eq(TStudyListen::getDisabled, 0).list().stream().map(TStudyListen::getSubject).collect(Collectors.toList());
+        List<String> inductionSubject = studyInductionService.lambdaQuery().eq(TStudyInduction::getWeek, week)
+                .eq(TStudyInduction::getDisabled, 0).list().stream().map(TStudyInduction::getSubject).collect(Collectors.toList());
+        List<String> lookSubject = studyLookService.lambdaQuery().eq(TStudyLook::getWeek, week)
+                .eq(TStudyLook::getDisabled, 0).list().stream().map(TStudyLook::getSubject).collect(Collectors.toList());
+        List<String> pairSubject = studyPairService.lambdaQuery().eq(TStudyPair::getWeek, week)
+                .eq(TStudyPair::getDisabled, 0).list().stream().map(TStudyPair::getSubject).collect(Collectors.toList());
+        List<String> studyAnswerList = studyAnswerService.lambdaQuery().eq(TStudyAnswer::getWeek, week)
+                .eq(TStudyAnswer::getDisabled, 0).list().stream().map(data -> String.valueOf(data.getSubject())).collect(Collectors.toList());
+        // 自主学习1-4需要单独处理
+        for (String s : listenSubject) {
+            subjectId.addAll(Arrays.stream(s.split(",")).collect(Collectors.toList()));
         }
+        for (String s : inductionSubject) {
+            subjectId.addAll(Arrays.stream(s.split(",")).collect(Collectors.toList()));
+        }
+        for (String s : lookSubject) {
+            subjectId.addAll(Arrays.stream(s.split(",")).collect(Collectors.toList()));
+        }
+        for (String s : pairSubject) {
+            subjectId.addAll(Arrays.stream(s.split(",")).collect(Collectors.toList()));
+        }
+        subjectId.addAll(studyAnswerList);
         return subjectId;
     }
 
@@ -1083,16 +1139,16 @@
     @GetMapping("/lookPictureDbu")
     @ApiOperation(value = "自主故事1-看图配音", tags = {"学习端-听-自主故事"})
     @ApiImplicitParams({
+            @ApiImplicitParam(value = "所属季度", name = "quarter", dataType = "Integer", required = true),
             @ApiImplicitParam(value = "所属周目", name = "week", dataType = "Integer", required = true)
     })
-    public R<StudyStoryListenResultVO> lookPictureDbu(@RequestParam Integer week) {
+    public R<StudyStoryListenResultVO> lookPictureDbu(@RequestParam Integer quarter, @RequestParam Integer week) {
         // 看图配音信息
-        TStoryListen listen = storyListenService.lambdaQuery().eq(TStoryListen::getWeek, week).one();
-        // 获取对应图片语音
+        TStoryListen listen = gettStoryListen(quarter, week);
         List<String> list = Arrays.asList(listen.getLookStory().split(","));
-        List<TSubject> subjectList;
+        List<TStory> subjectList;
         if (!list.isEmpty()) {
-            subjectList = subjectService.lambdaQuery().in(TSubject::getId, list).eq(TSubject::getState, 1).list();
+            subjectList = storyService.lambdaQuery().in(TStory::getId, list).eq(TStory::getDisabled, 0).list();
         } else {
             subjectList = new ArrayList<>();
         }
@@ -1107,20 +1163,38 @@
     @GetMapping("/frameworkMemory")
     @ApiOperation(value = "自主故事2-框架记忆", tags = {"学习端-听-自主故事"})
     @ApiImplicitParams({
+            @ApiImplicitParam(value = "所属季度", name = "quarter", dataType = "Integer", required = true),
             @ApiImplicitParam(value = "所属周目", name = "week", dataType = "Integer", required = true)
     })
-    public R<StudyStoryListenResultVO> frameworkMemory(@RequestParam Integer week) {
-        // 看图配音信息
-        TStoryListen listen = storyListenService.lambdaQuery().eq(TStoryListen::getWeek, week).one();
+    public R<StudyStoryListenResultVO> frameworkMemory(@RequestParam Integer quarter, @RequestParam Integer week) {
+        TStoryListen listen = gettStoryListen(quarter, week);
         // 获取对应图片语音
         List<String> list = Arrays.asList(listen.getStory().split(","));
-        List<TSubject> subjectList;
+        List<TStory> subjectList;
         if (!list.isEmpty()) {
-            subjectList = subjectService.lambdaQuery().in(TSubject::getId, list).eq(TSubject::getState, 1).list();
+            subjectList = storyService.lambdaQuery().in(TStory::getId, list).eq(TStory::getDisabled, 0).list();
         } else {
             subjectList = new ArrayList<>();
         }
         return R.ok(new StudyStoryListenResultVO(listen, subjectList));
+    }
+
+    private TStoryListen gettStoryListen(Integer quarter, Integer week) {
+        // 看图配音信息
+        List<TStoryListen> storyListenList = storyListenService.storyDetail(quarter, week);
+        if (storyListenList.isEmpty()) {
+            throw new GlobalException("当前季度该周目下未配置故事信息!");
+        }
+        // 获取对应图片语音
+        TStoryListen listen;
+        if (storyListenList.size() == Constants.ONE) {
+            listen = storyListenList.get(Constants.ZERO);
+        } else {
+            // 随机获取一组题
+            Random rand = new Random();
+            listen = storyListenList.get(rand.nextInt(storyListenList.size()));
+        }
+        return listen;
     }
 
     /**
@@ -1181,11 +1255,11 @@
         TUserStudy studyRecord = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userId)
                 .eq(TUserStudy::getDisabled, 0).one();
         // 查询剩余周目
-        if (studyRecord!=null){
+        if (studyRecord != null) {
             int size = studyService.list(new QueryWrapper<TStudy>()
                     .eq("type", 1)).size();
-            studyRecord.setSurplus(size-studyRecord.getWeek());
-        }else{
+            studyRecord.setSurplus(size - studyRecord.getWeek());
+        } else {
             TUserStudy tUserStudy = new TUserStudy();
             tUserStudy.setSurplus(studyService.list(new QueryWrapper<TStudy>()
                     .eq("type", 1)).size());
@@ -1235,9 +1309,9 @@
             @ApiImplicitParam(value = "每页显示条数", name = "pageSize", dataType = "Integer", required = true)
     })
     public R<IPage<TIntegralRecord>> integralDetailParent(String time,
-                                                    @RequestParam("pageNum") Integer pageNum,
-                                                    @RequestParam("pageSize") Integer pageSize) {
-        if(tokenService.getLoginUser1() == null){
+                                                          @RequestParam("pageNum") Integer pageNum,
+                                                          @RequestParam("pageSize") Integer pageSize) {
+        if (tokenService.getLoginUser1() == null) {
             return R.tokenError("登录失效");
         }
 
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/domain/TGame.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/domain/TGame.java
index 332594e..081d770 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/domain/TGame.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/domain/TGame.java
@@ -39,17 +39,17 @@
     /**
      * 题目数量
      */
-    @ApiModelProperty("题目数量")
+    @ApiModelProperty("超级听力题目数量")
     private Integer count;
     /**
      * 积分逗号隔开 第一个对应入门第二个对应中级...
      */
-    @ApiModelProperty("对应可获取积分数量(第一个为入门难度;第二个为中级难度;第三个为困难难度)")
+    @ApiModelProperty("超级听力对应可获取积分数量(第一个为入门难度;第二个为中级难度;第三个为困难难度)")
     private String integral;
     /**
      * 时间逗号隔开 第一个对应入门第二个对应中级...
      */
-    @ApiModelProperty("时间范围(第一个为入门难度;第二个为中级难度;第三个为困难难度)")
+    @ApiModelProperty("超级听力时间范围(第一个为入门难度;第二个为中级难度;第三个为困难难度)")
     private String time;
 
     /**
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/dto/CompleteGameDTO.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/dto/CompleteGameDTO.java
index 6a09955..40eba2b 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/dto/CompleteGameDTO.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/dto/CompleteGameDTO.java
@@ -32,7 +32,7 @@
     /**
      * 游戏名称
      */
-    @ApiModelProperty("游戏名称")
+    @ApiModelProperty("游戏名称(超级听力/超级记忆)")
     private String gameName;
 
     /**
@@ -40,11 +40,5 @@
      */
     @ApiModelProperty("正确率")
     private Integer accuracy;
-
-    /**
-     * 根据正确率计算可获得积分数量
-     */
-    @ApiModelProperty("根据正确率计算可获得积分数量")
-    private Integer availableIntegral;
 
 }
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/mapper/TGameMapper.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/mapper/TGameMapper.java
index 337549b..c29c3fc 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/mapper/TGameMapper.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/mapper/TGameMapper.java
@@ -2,6 +2,7 @@
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ruoyi.study.domain.TGame;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * <p>
@@ -13,4 +14,12 @@
  */
 public interface TGameMapper extends BaseMapper<TGame> {
 
+    /**
+     * 获取游戏详情
+     *
+     * @param quarter    季度
+     * @param week       所属周目
+     * @return 游戏信息
+     */
+    TGame gameHearing(@Param("quarter") Integer quarter, @Param("week") Integer week);
 }
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/mapper/TStoryListenMapper.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/mapper/TStoryListenMapper.java
index b91e13a..676f5f7 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/mapper/TStoryListenMapper.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/mapper/TStoryListenMapper.java
@@ -2,6 +2,9 @@
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ruoyi.study.domain.TStoryListen;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +16,12 @@
  */
 public interface TStoryListenMapper extends BaseMapper<TStoryListen> {
 
+    /**
+     * 获取故事详情
+     *
+     * @param quarter 季度
+     * @param week    周
+     * @return 故事信息
+     */
+    List<TStoryListen> storyDetail(@Param("quarter") Integer quarter, @Param("week") Integer week);
 }
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITGameService.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITGameService.java
index 0265f5b..5036416 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITGameService.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITGameService.java
@@ -20,11 +20,22 @@
     /**
      * 根据正确率计算用户本次游戏可获得的积分数量
      *
-     * @param userid 用户id
-     * @param game           游戏信息
-     * @param integralRecordList 积分明细信息
-     * @param completeStudy  游戏测试信息
+     * @param userid                用户id
+     * @param game                  游戏信息
+     * @param integralRecordList    积分明细信息
+     * @param completeStudy         游戏测试信息
+     * @param gameAvailableIntegral 本次游戏可获得积分数量
      * @return 可获得积分数量
      */
-    Integer countIntegral(Integer userid ,TGame game, CompleteGameDTO completeStudy, List<TIntegralRecord> integralRecordList);
+    Integer countIntegral(Integer userid, TGame game, CompleteGameDTO completeStudy,
+                          Integer gameAvailableIntegral, List<TIntegralRecord> integralRecordList);
+
+    /**
+     * 获取游戏详情
+     *
+     * @param quarter 季度
+     * @param week    所属周目
+     * @return 游戏信息
+     */
+    TGame gameHearing(Integer quarter, Integer week);
 }
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITStoryListenService.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITStoryListenService.java
index f942092..f447847 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITStoryListenService.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITStoryListenService.java
@@ -3,6 +3,8 @@
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.study.domain.TStoryListen;
 
+import java.util.List;
+
 /**
  * <p>
  * 听故事 服务类
@@ -13,4 +15,12 @@
  */
 public interface ITStoryListenService extends IService<TStoryListen> {
 
+    /**
+     * 获取故事详情
+     *
+     * @param quarter 季度
+     * @param week    周
+     * @return 故事信息
+     */
+    List<TStoryListen> storyDetail(Integer quarter, Integer week);
 }
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TGameServiceImpl.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TGameServiceImpl.java
index 9a5dc18..3eb6401 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TGameServiceImpl.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TGameServiceImpl.java
@@ -23,22 +23,26 @@
 public class TGameServiceImpl extends ServiceImpl<TGameMapper, TGame> implements ITGameService {
 
     @Override
-    public Integer countIntegral(Integer userid, TGame game, CompleteGameDTO completeStudy, List<TIntegralRecord> integralRecordList) {
-        // 本次游戏可获得积分数量
-        Integer availableIntegral = completeStudy.getAvailableIntegral();
+    public Integer countIntegral(Integer userid, TGame game, CompleteGameDTO completeStudy,
+                                 Integer gameAvailableIntegral, List<TIntegralRecord> integralRecordList) {
         // 积分明细集合为空,当前为第一次完成游戏
         if (integralRecordList.isEmpty()) {
-            return availableIntegral;
+            return gameAvailableIntegral;
         } else {
             // 积分明细不为空,根据正确率及已获取积分数量计算本次答题可获取的积分数量
             List<Integer> integralList = integralRecordList.stream().map(TIntegralRecord::getIntegral).collect(Collectors.toList())
                     .stream().map(Integer::parseInt).collect(Collectors.toList());
             int sumIntegral = integralList.stream().mapToInt(Integer::intValue).sum();
-            if (availableIntegral > sumIntegral) {
-                return availableIntegral - sumIntegral;
+            if (gameAvailableIntegral > sumIntegral) {
+                return gameAvailableIntegral - sumIntegral;
             } else {
                 return null;
             }
         }
     }
+
+    @Override
+    public TGame gameHearing(Integer quarter, Integer week) {
+        return baseMapper.gameHearing(quarter, week);
+    }
 }
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStoryListenServiceImpl.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStoryListenServiceImpl.java
index 743907e..893be5c 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStoryListenServiceImpl.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStoryListenServiceImpl.java
@@ -6,6 +6,8 @@
 import com.ruoyi.study.mapper.TStoryListenMapper;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 听故事 服务实现类
@@ -17,4 +19,8 @@
 @Service
 public class TStoryListenServiceImpl extends ServiceImpl<TStoryListenMapper, TStoryListen> implements ITStoryListenService {
 
+    @Override
+    public List<TStoryListen> storyDetail(Integer quarter, Integer week) {
+        return baseMapper.storyDetail(quarter, week);
+    }
 }
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java
index e1cb646..3fe0e68 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java
@@ -1,6 +1,7 @@
 package com.ruoyi.study.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.core.constant.Constants;
 import com.ruoyi.common.core.exception.GlobalException;
 import com.ruoyi.common.core.utils.bean.BeanUtils;
 import com.ruoyi.common.security.service.TokenService;
@@ -58,16 +59,18 @@
     @Override
     public void checkDifficulty(Integer difficulty, Integer week, TGame game) {
         // 判断用户是否完成上一个等级
-        Integer level = GAME_DIFFICULTY_MAP.get(String.valueOf(difficulty));
-        if (null == level) {
-            throw new GlobalException("游戏等级异常,请重试!");
-        }
-        // 获取用户游戏进度
-        Integer userId = tokenService.getLoginUserStudy().getUserid();
-        List<TGameRecord> list = gameRecordService.lambdaQuery().eq(TGameRecord::getUserId, userId).eq(TGameRecord::getGameId, game.getId()).list();
-        boolean contains = list.stream().map(TGameRecord::getGameDifficulty).collect(Collectors.toList()).contains(level);
-        if (!contains) {
-            throw new GlobalException("请先完成上一难度再挑战当前难度!");
+        if (!Constants.ZERO.equals(difficulty)) {
+            Integer level = GAME_DIFFICULTY_MAP.get(String.valueOf(difficulty));
+            if (null == level) {
+                throw new GlobalException("游戏等级异常,请重试!");
+            }
+            // 获取用户游戏进度
+            Integer userId = tokenService.getLoginUserStudy().getUserid();
+            List<TGameRecord> list = gameRecordService.lambdaQuery().eq(TGameRecord::getUserId, userId).eq(TGameRecord::getGameId, game.getId()).list();
+            boolean contains = list.stream().map(TGameRecord::getGameDifficulty).collect(Collectors.toList()).contains(level);
+            if (!contains) {
+                throw new GlobalException("请先完成上一难度再挑战当前难度!");
+            }
         }
     }
 
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/vo/StudyStoryListenResultVO.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/vo/StudyStoryListenResultVO.java
index 582cab2..0b8f12b 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/vo/StudyStoryListenResultVO.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/vo/StudyStoryListenResultVO.java
@@ -1,11 +1,10 @@
 package com.ruoyi.study.vo;
 
+import com.ruoyi.study.domain.TStory;
 import com.ruoyi.study.domain.TStoryListen;
-import com.ruoyi.study.domain.TSubject;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
-import lombok.EqualsAndHashCode;
 
 import java.util.List;
 
@@ -14,10 +13,9 @@
  * @version 1.0
  * @since 2024-05-22 14:39
  */
-@EqualsAndHashCode(callSuper = true)
 @Data
 @ApiModel(value = "自主故事-看图配音&&框架记忆返回信息类")
-public class StudyStoryListenResultVO extends StudyModelVO {
+public class StudyStoryListenResultVO {
 
     /**
      * 自主故事-看图配音&&框架记忆题目信息
@@ -25,8 +23,14 @@
     @ApiModelProperty("自主故事-看图配音&&框架记忆题目信息")
     private TStoryListen data;
 
-    public StudyStoryListenResultVO(TStoryListen data, List<TSubject> subjectList) {
+    /**
+     * 自主学习题目所包含录音图片等
+     */
+    @ApiModelProperty("故事列表")
+    private List<TStory> storyList;
+
+    public StudyStoryListenResultVO(TStoryListen data, List<TStory> storyList) {
         this.data = data;
-        super.setSubjectList(subjectList);
+        this.storyList = storyList;
     }
 }
diff --git a/ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TGameMapper.xml b/ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TGameMapper.xml
index e068c76..be3255d 100644
--- a/ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TGameMapper.xml
+++ b/ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TGameMapper.xml
@@ -1,7 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.study.mapper.TGameMapper">
-
-
-
+    <select id="gameHearing" resultType="com.ruoyi.study.domain.TGame">
+        select g.*
+        from t_game g
+                 left join t_study s on g.studyId = s.id
+        where g.disabled = 0
+          and s.disabled = 0
+          and g.week = #{week}
+          and s.quarter = #{quarter}
+    </select>
 </mapper>
diff --git a/ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TStoryListenMapper.xml b/ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TStoryListenMapper.xml
index f04c4ea..55fceb1 100644
--- a/ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TStoryListenMapper.xml
+++ b/ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TStoryListenMapper.xml
@@ -17,4 +17,8 @@
         id, week, story, sort, lookStory, lookSort
     </sql>
 
+    <select id="storyDetail" resultMap="BaseResultMap">
+        select  * from t_story_listen sl left join t_study s on sl.studyId = s.id
+        where sl.disabled = 0 and s.disabled = 0 and sl.week = #{week} and s.quarter = #{quarter}
+    </select>
 </mapper>
diff --git a/ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TStudyMapper.xml b/ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TStudyMapper.xml
index b4c83f5..bc436bf 100644
--- a/ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TStudyMapper.xml
+++ b/ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TStudyMapper.xml
@@ -1,22 +1,28 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.study.mapper.TStudyMapper">
-
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.ruoyi.study.domain.TStudy">
-        <id column="id" property="id" />
-        <result column="week" property="week" />
-        <result column="day" property="day" />
-        <result column="listen" property="listen" />
-        <result column="type" property="type" />
-        <result column="integral" property="integral" />
-        <result column="sort" property="sort" />
-        <result column="title" property="title" />
+        <id column="id" property="id"/>
+        <result column="week" property="week"/>
+        <result column="day" property="day"/>
+        <result column="listen" property="listen"/>
+        <result column="type" property="type"/>
+        <result column="integral" property="integral"/>
+        <result column="sort" property="sort"/>
+        <result column="title" property="title"/>
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, week, day, listen, type, integral, sort, title
+        id,
+        week,
+        day,
+        listen,
+        type,
+        integral,
+        sort,
+        title
     </sql>
 
     <select id="weekList" resultType="com.ruoyi.study.dto.StudyWeekDTO">
@@ -36,10 +42,18 @@
                  LEFT JOIN t_story_listen sl ON s.id = sl.studyId
                  LEFT JOIN t_game g ON s.id = g.studyId
         <where>
-            <if test="quarter != null">
-                s.quarter = #{quarter}
+            s.disabled = 0
+              and sa.disabled = 0
+              and si.disabled = 0
+              and st.disabled = 0
+              and sk.disabled = 0
+              and sp.disabled = 0
+              and sl.disabled = 0
+              and g.disabled = 0
+            <if test="quarter != null and quarter != ''">
+                and s.quarter = #{quarter}
             </if>
-            <if test="type != null">
+            <if test="type != null and quarter != ''">
                 and s.type = #{type}
             </if>
         </where>

--
Gitblit v1.7.1