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

master
xiaoCJ 7 months ago
parent 72cabf956f
commit 1d46dec343

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

Loading…
Cancel
Save