diff --git a/src/main/java/com/sztzjy/resource_center/controller/api/CaseApi.java b/src/main/java/com/sztzjy/resource_center/controller/api/CaseApi.java index 3721fe6..eeec593 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/api/CaseApi.java +++ b/src/main/java/com/sztzjy/resource_center/controller/api/CaseApi.java @@ -18,7 +18,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; +import java.util.stream.IntStream; @RestController @Api(tags = "案例题方面API") @@ -322,12 +324,38 @@ public class CaseApi { example.createCriteria().andThreeIdEqualTo(threeId); List topicAndCourseList = topicAndCourseMapper.selectByExample(example); List caseIdList = topicAndCourseList.stream().map(SysTopicAndCourse::getTopicId).collect(Collectors.toList()); + + SysCaseQuestionExample caseQuestionExample =new SysCaseQuestionExample(); + caseQuestionExample.createCriteria().andCaseIdIn(caseIdList); + caseQuestionExample.setOrderByClause("create_time"); + + List list = caseQuestionMapper.selectByExampleWithBLOBs(caseQuestionExample); + List ids = list.stream().map(SysCaseQuestion::getCaseId).collect(Collectors.toList()); SysCaseQuestionStepExample caseQuestionStepExample = new SysCaseQuestionStepExample(); - caseQuestionStepExample.createCriteria().andCaseIdIn(caseIdList); + caseQuestionStepExample.createCriteria().andCaseIdIn(ids); List sysCaseQuestionStepWithBLOBs = caseQuestionStepMapper.selectByExampleWithBLOBs(caseQuestionStepExample); - return sysCaseQuestionStepWithBLOBs; + // 获取原 caseId 的顺序列表 + Map indexMap = IntStream.range(0, ids.size()) + .boxed() + .collect(Collectors.toMap(ids::get, Function.identity())); + + // 根据 indexMap 顺序排序 + List sortedSteps = sysCaseQuestionStepWithBLOBs.stream() + .sorted(Comparator.comparingInt(step -> indexMap.get(step.getCaseId()))) + .collect(Collectors.toList()); + return sortedSteps; } + + @PostMapping("selectCaseStepByThreeIds") + @ApiOperation("查询案例题步骤") + @AnonymousAccess + public List selectCaseStepByThreeIds(@RequestBody List threeIds) { + List list= caseQuestionStepMapper.selectCaseStepByThreeIds(threeIds); + return list; + } + + @PostMapping("selectCaseStepListBatchByIdList") @ApiOperation("查询案例题步骤") @AnonymousAccess diff --git a/src/main/java/com/sztzjy/resource_center/controller/api/CourseApi.java b/src/main/java/com/sztzjy/resource_center/controller/api/CourseApi.java index 85db12b..c19c79a 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/api/CourseApi.java +++ b/src/main/java/com/sztzjy/resource_center/controller/api/CourseApi.java @@ -69,6 +69,22 @@ public class CourseApi { return sysThreeCatalogs; } + + @PostMapping("selectThreeCatalogListByTwoIdList") + @ApiOperation("根据二级目录IDList查寻所有三级目录信息") + @AnonymousAccess + public List selectThreeCatalogListByTwoIdList(@RequestBody List twoIds, @RequestParam String schoolId) { + SysThreeCatalogExample example = new SysThreeCatalogExample(); + ArrayList list = new ArrayList<>(); + list.add(schoolId); + list.add(Constant.ADMIN); + example.createCriteria().andTwoIdIn(twoIds).andCreatorIn(list); + example.setOrderByClause("sort asc"); + List sysThreeCatalogs = threeCatalogMapper.selectByExample(example); + return sysThreeCatalogs; + } + + //增加二级目录 SysTwoCatalog systemOwner @AnonymousAccess @ApiOperation("添加二级目录") @@ -248,6 +264,15 @@ public class CourseApi { return threeCatalogMapper.selectByPrimaryKey(chapterId); } + @AnonymousAccess + @ApiOperation("根据章节ID集合查询List") + @PostMapping("selectChapterByIdList") + public List selectChapterByIdList(@RequestBody List chapterIds) { + SysThreeCatalogExample example =new SysThreeCatalogExample(); + example.createCriteria().andThreeIdIn(chapterIds); + return threeCatalogMapper.selectByExample(example); + } + /** * 查询章节名称集合 diff --git a/src/main/java/com/sztzjy/resource_center/mapper/SysCaseQuestionStepMapper.java b/src/main/java/com/sztzjy/resource_center/mapper/SysCaseQuestionStepMapper.java index 85cf3f6..faab779 100644 --- a/src/main/java/com/sztzjy/resource_center/mapper/SysCaseQuestionStepMapper.java +++ b/src/main/java/com/sztzjy/resource_center/mapper/SysCaseQuestionStepMapper.java @@ -50,5 +50,5 @@ public interface SysCaseQuestionStepMapper { List getCaseStepByIds(@Param("ids") List ids); List selectCaseStepListBatchByIdListAndSort(@Param("threeId") String threeId); - List selectCaseStepListBatchByIdList(@Param("list") List list); + List selectCaseStepByThreeIds(@Param("list") List list); } \ No newline at end of file diff --git a/src/main/resources/mapper/SysCaseQuestionStepMapper.xml b/src/main/resources/mapper/SysCaseQuestionStepMapper.xml index 078c693..f7fea62 100644 --- a/src/main/resources/mapper/SysCaseQuestionStepMapper.xml +++ b/src/main/resources/mapper/SysCaseQuestionStepMapper.xml @@ -445,7 +445,7 @@ - SELECT st.three_id,sc.* from sys_case_question_steps sc left join sys_case_questions s