From a7d177dd48ca8c8a7e154573f7306e2b86dd1a77 Mon Sep 17 00:00:00 2001
From: hjl <1657978663@qq.com>
Date: 星期二, 18 六月 2024 15:18:00 +0800
Subject: [PATCH] fix: 学习端bug
---
ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java | 47 +++++++++++++++++++++++++++++++++--------------
1 files changed, 33 insertions(+), 14 deletions(-)
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 ffcf068..1e3f7f7 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
@@ -4,8 +4,8 @@
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;
import com.ruoyi.study.domain.*;
+import com.ruoyi.study.dto.CompleteGameDTO;
import com.ruoyi.study.dto.StudyWeekDTO;
import com.ruoyi.study.mapper.TStudyMapper;
import com.ruoyi.study.service.*;
@@ -33,8 +33,6 @@
private ITSubjectService subjectService;
@Resource
private ITGameRecordService gameRecordService;
- @Resource
- private TokenService tokenService;
@Resource
private ITStudyAnswerService studyAnswerService;
@Resource
@@ -72,23 +70,38 @@
// 有问有答
List<TStudyAnswer> answerList = studyAnswerService.lambdaQuery().eq(TStudyAnswer::getStudyId, id)
.eq(TStudyAnswer::getDisabled, 0).list();
- total += answerList.stream().map(TStudyAnswer::getIntegral).mapToInt(Integer::intValue).sum();
+ Optional<TStudyAnswer> answerOptional = answerList.stream().findAny();
+ if (answerOptional.isPresent()) {
+ total += answerOptional.get().getIntegral();
+ }
// 归纳判断
List<TStudyInduction> inductionList = studyInductionService.lambdaQuery().eq(TStudyInduction::getStudyId, id)
.eq(TStudyInduction::getDisabled, 0).list();
- total += inductionList.stream().map(TStudyInduction::getIntegral).mapToInt(Integer::intValue).sum();
+ Optional<TStudyInduction> inductionOptional = inductionList.stream().findAny();
+ if (inductionOptional.isPresent()) {
+ total += inductionOptional.get().getIntegral();
+ }
// 看图选音
List<TStudyLook> lookList = studyLookService.lambdaQuery().eq(TStudyLook::getStudyId, id)
.eq(TStudyLook::getDisabled, 0).list();
- total += lookList.stream().map(TStudyLook::getIntegral).mapToInt(Integer::intValue).sum();
+ Optional<TStudyLook> lookOptional = lookList.stream().findAny();
+ if (lookOptional.isPresent()) {
+ total += lookOptional.get().getIntegral();
+ }
// 听音选图
List<TStudyListen> listenList = studyListenService.lambdaQuery().eq(TStudyListen::getStudyId, id)
.eq(TStudyListen::getDisabled, 0).list();
- total += listenList.stream().map(TStudyListen::getIntegral).mapToInt(Integer::intValue).sum();
+ Optional<TStudyListen> listenOptional = listenList.stream().findAny();
+ if (listenOptional.isPresent()) {
+ total += listenOptional.get().getIntegral();
+ }
// 音图相配
List<TStudyPair> pairList = studyPairService.lambdaQuery().eq(TStudyPair::getStudyId, id)
.eq(TStudyPair::getDisabled, 0).list();
- total += pairList.stream().map(TStudyPair::getIntegral).mapToInt(Integer::intValue).sum();
+ Optional<TStudyPair> pairOptional = pairList.stream().findAny();
+ if (pairOptional.isPresent()) {
+ total += pairOptional.get().getIntegral();
+ }
// 自主游戏
List<TGame> gameList = gameService.lambdaQuery().eq(TGame::getStudyId, id)
.eq(TGame::getDisabled, 0).list();
@@ -118,23 +131,24 @@
}
@Override
- public TUserStudy studySchedule(String userId, Integer week) {
- return userStudyService.studySchedule(userId, week);
+ public TUserStudy studySchedule(String userId) {
+ return userStudyService.studySchedule(userId);
}
@Override
- public void checkDifficulty(Integer difficulty, Integer week, TGame game) {
+ public void checkDifficulty(Integer difficulty, Integer week, TGame game, Integer userid) {
// 判断用户是否完成上一个等级
if (!Constants.ZERO.equals(difficulty)) {
Integer level = GAME_DIFFICULTY_MAP.get(difficulty);
if (null == level) {
throw new GlobalException("游戏等级异常,请重试!");
}
+ // 游戏通关率
+ String clearanceRate = game.getRate().split(",")[level];
// 获取用户游戏进度
- Integer userId = tokenService.getLoginUserStudy().getUserid();
- List<TGameRecord> list = gameRecordService.lambdaQuery().eq(TGameRecord::getUserId, userId)
+ List<TGameRecord> list = gameRecordService.lambdaQuery().eq(TGameRecord::getUserId, userid)
.eq(TGameRecord::getGameId, game.getId())
- .eq(TGameRecord::getAccuracy, 100)
+ .ge(TGameRecord::getAccuracy, clearanceRate)
.eq(TGameRecord::getGameDifficulty, level).list();
if (list.isEmpty()) {
throw new GlobalException("请先完成上一难度再挑战当前难度!");
@@ -438,4 +452,9 @@
return (int) (sum * ((double) accuracy / 100));
}
+ @Override
+ public void checkRate(TGame game, Integer userid, CompleteGameDTO completeStudy) {
+
+ }
+
}
--
Gitblit v1.7.1