From b3df7ddbd4cfda6781efdd9bf4e942ec8d5cdc5d Mon Sep 17 00:00:00 2001 From: xiaoCJ <406612557@qq.com> Date: Sat, 11 Jan 2025 17:13:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A0=B9=E6=8D=AE=E7=AB=A0?= =?UTF-8?q?=E8=8A=82IDlist=E8=BF=9E=E8=A1=A8=E6=9F=A5=E8=AF=A2=E6=AD=A5?= =?UTF-8?q?=E9=AA=A4=E5=AF=B9=E8=B1=A1=E6=8E=A5=E5=8F=A3=EF=BC=8C=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E4=BA=8C=E7=BA=A7=E7=9B=AE=E5=BD=95IDList=E6=9F=A5?= =?UTF-8?q?=E5=AF=BB=E6=89=80=E6=9C=89=E4=B8=89=E7=BA=A7=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/api/CaseApi.java | 32 +++++++++++++++++-- .../controller/api/CourseApi.java | 25 +++++++++++++++ .../mapper/SysCaseQuestionStepMapper.java | 2 +- .../mapper/SysCaseQuestionStepMapper.xml | 2 +- 4 files changed, 57 insertions(+), 4 deletions(-) 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