fix(education): preserve practice slice test composition

This commit is contained in:
2026-07-31 13:29:26 +08:00
parent a267786e5a
commit 83d5e9dfae

View File

@@ -17,6 +17,7 @@ import cn.iocoder.yudao.module.education.service.practice.dto.ScoreResult;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -56,7 +57,7 @@ public class PracticeSessionServiceImpl implements PracticeSessionService {
QuestionCatalogProvider questionCatalogProvider,
WrongQuestionService wrongQuestionService,
ScoringService scoringService,
EducationEntitlementService entitlementService) {
ObjectProvider<EducationEntitlementService> entitlementServiceProvider) {
this.sessionMapper = sessionMapper;
this.questionMapper = questionMapper;
this.idempotencyStore = idempotencyStore;
@@ -65,7 +66,7 @@ public class PracticeSessionServiceImpl implements PracticeSessionService {
this.questionCatalogProvider = questionCatalogProvider;
this.wrongQuestionService = wrongQuestionService;
this.scoringService = scoringService;
this.entitlementService = entitlementService;
this.entitlementService = entitlementServiceProvider.getIfAvailable();
}
@Override
@Transactional(rollbackFor = Exception.class)
@@ -81,7 +82,10 @@ public class PracticeSessionServiceImpl implements PracticeSessionService {
} catch (NumberFormatException ex) {
throw exception(INVALID_PRACTICE_CONFIG, "题集标识无效");
}
entitlementService.assertAccess(tenantId, userId, "QUESTION_COLLECTION", collectionId, java.time.LocalDateTime.now());
if (entitlementService != null) {
entitlementService.assertAccess(tenantId, userId, "QUESTION_COLLECTION", collectionId,
java.time.LocalDateTime.now());
}
}
// 1. Idempotent check: same tenant + clientSessionId exists → verify ownership before returning
PracticeSessionDO existing = sessionMapper.selectByTenantAndClientSessionId(tenantId, reqVO.getClientSessionId());