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 2ede1a0..7bc3250 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 @@ -17,9 +17,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import java.util.Date; -import java.util.List; -import java.util.UUID; +import java.util.*; import java.util.stream.Collectors; @RestController @@ -383,4 +381,46 @@ public class CaseApi { List trainingDtos = caseQuestionStepMapper.selectTrainingByIds(caseStepIdList); return trainingDtos; } + + //* 单独接口 +//* 获取所有内置案例题步骤信息 + @AnonymousAccess + @ApiOperation("获取所有内置案例题步骤信息") + @PostMapping("selectAllStepBySystemOwner") + public List selectAllStepBySystemOwner(@RequestParam String systemOwner) { + SysOneCatalog sysOneCatalogs = getSysOneCatalogs(systemOwner); + + List ids = topicAndCourseMapper.getCaseIdsBySourceIsAdmin(sysOneCatalogs.getOneId()); + SysCaseQuestionStepExample example1 = new SysCaseQuestionStepExample(); + example1.createCriteria().andCaseIdIn(ids); + return caseQuestionStepMapper.selectByExampleWithBLOBs(example1); + } + + + //* 单独接口 + @AnonymousAccess + @ApiOperation("获取三级ID和案例题ID") + @PostMapping("getMapChapterIdAndCaseIdsByCourseIdAndChapterId") + public Map> getMapChapterIdAndCaseIdsByCourseIdAndChapterId(@RequestBody List sysThreeCatalogs, + @RequestParam String systemOwner) { + // 批量查询案例题ID + Map> caseIdMap = new HashMap<>(); + List courseIdList = new ArrayList<>(); + List chapterIdList = new ArrayList<>(); + for (SysThreeCatalog chapter : sysThreeCatalogs) { + courseIdList.add(chapter.getTwoId()); + chapterIdList.add(chapter.getThreeId()); + } + + List> results = caseQuestionMapper.selectCaseIdByCourseAndChapterIds(courseIdList, chapterIdList); + for (Map result : results) { + String chapterId = (String) result.get("chapter_id"); + String caseId = (String) result.get("case_id"); + if (!caseIdMap.containsKey(chapterId)) { + caseIdMap.put(chapterId, new ArrayList<>()); + } + caseIdMap.get(chapterId).add(caseId); + } + return caseIdMap; + } } diff --git a/src/main/java/com/sztzjy/resource_center/mapper/SysCaseQuestionMapper.java b/src/main/java/com/sztzjy/resource_center/mapper/SysCaseQuestionMapper.java index 4867070..73ee095 100644 --- a/src/main/java/com/sztzjy/resource_center/mapper/SysCaseQuestionMapper.java +++ b/src/main/java/com/sztzjy/resource_center/mapper/SysCaseQuestionMapper.java @@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Map; @Mapper public interface SysCaseQuestionMapper { @@ -42,4 +43,6 @@ public interface SysCaseQuestionMapper { @Param("source") String source); List selectCaseByConditionsByBind(@Param("title") String title); + + List> selectCaseIdByCourseAndChapterIds(@Param("courseIdList") List courseIdList, @Param("chapterIdList") List chapterIdList); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/resource_center/mapper/SysTopicAndCourseMapper.java b/src/main/java/com/sztzjy/resource_center/mapper/SysTopicAndCourseMapper.java index 648d0ef..42dcc60 100644 --- a/src/main/java/com/sztzjy/resource_center/mapper/SysTopicAndCourseMapper.java +++ b/src/main/java/com/sztzjy/resource_center/mapper/SysTopicAndCourseMapper.java @@ -4,6 +4,7 @@ import com.sztzjy.resource_center.entity.SysTopicAndCourse; import com.sztzjy.resource_center.entity.SysTopicAndCourseExample; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; import java.util.List; @@ -40,4 +41,7 @@ public interface SysTopicAndCourseMapper { void batchUpdateThreeName(@Param("idList") List ids, @Param("threeName") String threeName); + + @Select("select sq.case_id from sys_topic_and_course sc LEFT JOIN sys_case_questions sq on sc.topic_id = sq.case_id where sq.source = '管理员' and sc.one_id = #{oneId}") + List getCaseIdsBySourceIsAdmin(@Param("oneId") String oneId); } \ No newline at end of file diff --git a/src/main/resources/mapper/SysCaseQuestionMapper.xml b/src/main/resources/mapper/SysCaseQuestionMapper.xml index 9d45f04..89b68e6 100644 --- a/src/main/resources/mapper/SysCaseQuestionMapper.xml +++ b/src/main/resources/mapper/SysCaseQuestionMapper.xml @@ -470,4 +470,17 @@ order by s.create_time + + \ No newline at end of file