修改实训演练查询接口返回逻辑

master
xiaoCJ 7 months ago
parent 72cabf956f
commit 1d46dec343

@ -44,7 +44,7 @@ public class ExerciseExperimentalTraining {
@ApiOperation("**获取案例题基础信息")
@AnonymousAccess
public ResultEntity<TestSysCaseQuestion> getCaseInfo(@RequestParam String chapterId) {
List<TestSysCaseQuestion> sysCaseQuestions= null;
List<TestSysCaseQuestion> sysCaseQuestions = null;
try {
sysCaseQuestions = CaseApi.selectCaseByChapterId(chapterId);
} catch (IOException e) {
@ -108,7 +108,7 @@ public class ExerciseExperimentalTraining {
@AnonymousAccess
@ApiOperation("实训演练页面查询")
@PostMapping("getCourseChapter")
public ResultEntity<List<SysCourseDto>> getIndexTheoryTest(@RequestParam String userId,@RequestParam String systemOwner) {
public ResultEntity<List<SysCourseDto>> getIndexTheoryTest(@RequestParam String userId, @RequestParam String systemOwner) {
// List<SysCourse> sysCourseList = sysCourseMapper.getBySchoolId();
List<SysTwoCatalog> sysCourseList = null;
try {
@ -116,12 +116,11 @@ public class ExerciseExperimentalTraining {
} catch (IOException e) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心获取内置二级目录失败");
}
if(sysCourseList.isEmpty()){
if (sysCourseList.isEmpty()) {
return null;
}
List<SysCourseDto> dtoList = new ArrayList<>();
// 批量查询所有章节
List<String> courseIds = sysCourseList.stream()
.map(SysTwoCatalog::getTwoId)
@ -132,14 +131,23 @@ public class ExerciseExperimentalTraining {
} catch (IOException e) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心根据课程IDList查询章节集合失败");
}
if(sysCourseChapters.isEmpty()){
return null;
if (sysCourseChapters.isEmpty()) {
//三级为空返回二级的信息
for (SysTwoCatalog sysTwoCatalog : sysCourseList) {
SysCourseDto newDto = new SysCourseDto();
newDto.setCourseId(sysTwoCatalog.getTwoId());
newDto.setSequence(sysTwoCatalog.getSort());
newDto.setCourseName(sysTwoCatalog.getTwoName());
newDto.setSchoolId(sysTwoCatalog.getCreator());
dtoList.add(newDto);
return new ResultEntity<List<SysCourseDto>>(dtoList);
}
}
// 批量查询所有案例题步骤
SysCaseQuestionStepExample stepExample = new SysCaseQuestionStepExample();
stepExample.setOrderByClause("sort");
List<TestTestSysCaseQuestionStepWithBLOBs> sysCaseQuestionSteps= null;
List<TestTestSysCaseQuestionStepWithBLOBs> sysCaseQuestionSteps = null;
try {
sysCaseQuestionSteps = CaseApi.selectAllStepBySystemOwner(systemOwner);
} catch (IOException e) {
@ -152,7 +160,7 @@ public class ExerciseExperimentalTraining {
// 批量查询案例题ID
Map<String, List<String>> caseIdMap = null;
try {
caseIdMap = CaseApi.getMapChapterIdAndCaseIdsByCourseIdAndChapterId(sysCourseChapters,systemOwner);
caseIdMap = CaseApi.getMapChapterIdAndCaseIdsByCourseIdAndChapterId(sysCourseChapters, systemOwner);
} catch (IOException e) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心查询失败");
}
@ -161,7 +169,7 @@ public class ExerciseExperimentalTraining {
List<StuTraining> progressByChapterIds = stuTrainingMapper.getByUserIdAndChapterIds(userId,
sysCourseChapters.stream().map(SysThreeCatalog::getThreeId).collect(Collectors.toList()));
Map<String, BigDecimal> progressMap = progressByChapterIds.stream()
.collect(Collectors.toMap(StuTraining::getChapterId,stuTraining -> Optional.ofNullable(stuTraining.getProgress()).orElse(BigDecimal.ZERO), (p1, p2) -> p1));
.collect(Collectors.toMap(StuTraining::getChapterId, stuTraining -> Optional.ofNullable(stuTraining.getProgress()).orElse(BigDecimal.ZERO), (p1, p2) -> p1));
// 构建结果列表
for (SysTwoCatalog sysCourse : sysCourseList) {
@ -187,12 +195,12 @@ public class ExerciseExperimentalTraining {
// 获取案例题步骤信息
List<String> caseIds = caseIdMap.get(chapter.getThreeId());
if (caseIds != null && !caseIds.isEmpty()) {
List<AAA>list =new ArrayList<>();
List<AAA> list = new ArrayList<>();
for (String caseId : caseIds) {
List<TestTestSysCaseQuestionStepWithBLOBs> steps = caseStepsMap.get(caseId);
if (steps != null && !steps.isEmpty()) {
for (TestTestSysCaseQuestionStepWithBLOBs step : steps) {
AAA aaa =new AAA();
AAA aaa = new AAA();
aaa.setStepID(step.getCaseStepId());
aaa.setTitle(step.getTitle());
aaa.setSort(step.getSort());
@ -245,9 +253,9 @@ public class ExerciseExperimentalTraining {
} catch (IOException e) {
return false;
}
if(resourceDataList.size()>0){
if (resourceDataList.size() > 0) {
return true;
}else {
} else {
return false;
}
}

Loading…
Cancel
Save