ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java
@@ -1240,6 +1240,10 @@ @ApiImplicitParam(value = "所属周目", name = "week", dataType = "Integer", required = true) }) public R<StudyGameMemoryVO> gameMemory(@RequestParam Integer quarter, @RequestParam Integer week) { LoginUserParent userStudy = tokenService.getLoginUserStudy(); if (null == userStudy) { return R.tokenError("登录失效!"); } TGame game = gameService.gameHearing(quarter, week); if (null == game) { throw new GlobalException("当前季度该周目暂无配置游戏数据!"); @@ -1254,6 +1258,8 @@ photoList.add(new GameMemoryPhotoVO(tSubject.getId(), tSubject.getImg())); voiceList.add(new GameMemoryVoiceVO(tSubject.getId(), tSubject.getCorrect())); } // 校验超级听力是否通过 studyService.checkClearance(game,userStudy.getUserid()); // 框架记忆数量翻倍,前端需要根据数量画格子 game.setAnswerCount(game.getAnswerCount() * 2); return R.ok(new StudyGameMemoryVO(game, photoList, voiceList)); ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITStudyService.java
@@ -122,4 +122,12 @@ * @return 剩余周目 */ int residueWeek(TUserStudy studyRecord, List<TStudy> studyList); /** * 校验超级听力是否通过 * * @param game 游戏信息 * @param userid 用户信息 */ void checkClearance(TGame game, Integer userid); } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java
@@ -468,23 +468,23 @@ // 根据五种学习计算进度 Integer listen = result.getListen(); if (!Constants.BURDEN_ONE.equals(listen)) { defaultSchedule += (int)(((double)listen / 100) * 4); defaultSchedule += (int) (((double) listen / 100) * 4); } Integer look = result.getLook(); if (!Constants.BURDEN_ONE.equals(look)) { defaultSchedule += (int)(((double)look / 100) * 4); defaultSchedule += (int) (((double) look / 100) * 4); } Integer induction = result.getInduction(); if (!Constants.BURDEN_ONE.equals(induction)) { defaultSchedule += (int)(((double)induction / 100) * 4); defaultSchedule += (int) (((double) induction / 100) * 4); } Integer answer = result.getAnswer(); if (!Constants.BURDEN_ONE.equals(answer)) { defaultSchedule += (int)(((double)answer / 100) * 4); defaultSchedule += (int) (((double) answer / 100) * 4); } Integer pair = result.getPair(); if (!Constants.BURDEN_ONE.equals(pair)) { defaultSchedule += (int)(((double)pair / 100) * 4); defaultSchedule += (int) (((double) pair / 100) * 4); } } @@ -597,4 +597,17 @@ return studyList.size() - residueWeek; } @Override public void checkClearance(TGame game, Integer userid) { String rate = game.getRate().split(",")[Constants.TWO]; // 获取用户游戏进度 List<TGameRecord> list = gameRecordService.lambdaQuery().eq(TGameRecord::getUserId, userid) .eq(TGameRecord::getGameId, game.getId()) .ge(TGameRecord::getAccuracy, rate) .eq(TGameRecord::getGameDifficulty, Constants.TWO).list(); if (list.isEmpty()) { throw new GlobalException("超级听力暂未通关!"); } } } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TUserStudyServiceImpl.java
@@ -4,15 +4,18 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.core.constant.Constants; import com.ruoyi.study.domain.TGame; import com.ruoyi.study.domain.TGameRecord; import com.ruoyi.study.domain.TStudy; import com.ruoyi.study.domain.TUserStudy; import com.ruoyi.study.dto.CompleteGameDTO; import com.ruoyi.study.dto.CompleteStudyDTO; import com.ruoyi.study.mapper.TUserStudyMapper; import com.ruoyi.study.service.ITGameRecordService; import com.ruoyi.study.service.ITUserStudyService; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -28,6 +31,9 @@ */ @Service public class TUserStudyServiceImpl extends ServiceImpl<TUserStudyMapper, TUserStudy> implements ITUserStudyService { @Resource private ITGameRecordService gameRecordService; /** * 所属day map @@ -200,7 +206,14 @@ TUserStudy userStudy = this.lambdaQuery().eq(TUserStudy::getUserId, userid).one(); // 更新游戏难度学习记录 if (!Constants.TWO.equals(userStudy.getGameDifficulty())) { userStudy.setGameDifficulty(GAME_DIFFICULTY_MAP.get(completeStudy.getDifficulty())); // 获取用户游戏进度 List<TGameRecord> list = gameRecordService.lambdaQuery().eq(TGameRecord::getUserId, userid) .eq(TGameRecord::getGameId, game.getId()) .ge(TGameRecord::getAccuracy, answerRate) .eq(TGameRecord::getGameDifficulty, completeStudy.getDifficulty()).list(); if (!list.isEmpty()) { userStudy.setGameDifficulty(GAME_DIFFICULTY_MAP.get(completeStudy.getDifficulty())); } } this.updateById(userStudy); }