新增根据章节IDlist连表查询步骤对象接口,根据二级目录IDList查寻所有三级目录信息接口

master
xiaoCJ 2 months ago
parent b1cb09dd5c
commit b3df7ddbd4

@ -18,7 +18,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream;
@RestController @RestController
@Api(tags = "案例题方面API") @Api(tags = "案例题方面API")
@ -322,12 +324,38 @@ public class CaseApi {
example.createCriteria().andThreeIdEqualTo(threeId); example.createCriteria().andThreeIdEqualTo(threeId);
List<SysTopicAndCourse> topicAndCourseList = topicAndCourseMapper.selectByExample(example); List<SysTopicAndCourse> topicAndCourseList = topicAndCourseMapper.selectByExample(example);
List<String> caseIdList = topicAndCourseList.stream().map(SysTopicAndCourse::getTopicId).collect(Collectors.toList()); List<String> caseIdList = topicAndCourseList.stream().map(SysTopicAndCourse::getTopicId).collect(Collectors.toList());
SysCaseQuestionExample caseQuestionExample =new SysCaseQuestionExample();
caseQuestionExample.createCriteria().andCaseIdIn(caseIdList);
caseQuestionExample.setOrderByClause("create_time");
List<SysCaseQuestion> list = caseQuestionMapper.selectByExampleWithBLOBs(caseQuestionExample);
List<String> ids = list.stream().map(SysCaseQuestion::getCaseId).collect(Collectors.toList());
SysCaseQuestionStepExample caseQuestionStepExample = new SysCaseQuestionStepExample(); SysCaseQuestionStepExample caseQuestionStepExample = new SysCaseQuestionStepExample();
caseQuestionStepExample.createCriteria().andCaseIdIn(caseIdList); caseQuestionStepExample.createCriteria().andCaseIdIn(ids);
List<SysCaseQuestionStepWithBLOBs> sysCaseQuestionStepWithBLOBs = caseQuestionStepMapper.selectByExampleWithBLOBs(caseQuestionStepExample); List<SysCaseQuestionStepWithBLOBs> sysCaseQuestionStepWithBLOBs = caseQuestionStepMapper.selectByExampleWithBLOBs(caseQuestionStepExample);
return sysCaseQuestionStepWithBLOBs; // 获取原 caseId 的顺序列表
Map<String, Integer> indexMap = IntStream.range(0, ids.size())
.boxed()
.collect(Collectors.toMap(ids::get, Function.identity()));
// 根据 indexMap 顺序排序
List<SysCaseQuestionStepWithBLOBs> sortedSteps = sysCaseQuestionStepWithBLOBs.stream()
.sorted(Comparator.comparingInt(step -> indexMap.get(step.getCaseId())))
.collect(Collectors.toList());
return sortedSteps;
} }
@PostMapping("selectCaseStepByThreeIds")
@ApiOperation("查询案例题步骤")
@AnonymousAccess
public List<SysCaseQuestionStepWithBLOBs> selectCaseStepByThreeIds(@RequestBody List<String> threeIds) {
List<SysCaseQuestionStepWithBLOBs> list= caseQuestionStepMapper.selectCaseStepByThreeIds(threeIds);
return list;
}
@PostMapping("selectCaseStepListBatchByIdList") @PostMapping("selectCaseStepListBatchByIdList")
@ApiOperation("查询案例题步骤") @ApiOperation("查询案例题步骤")
@AnonymousAccess @AnonymousAccess

@ -69,6 +69,22 @@ public class CourseApi {
return sysThreeCatalogs; return sysThreeCatalogs;
} }
@PostMapping("selectThreeCatalogListByTwoIdList")
@ApiOperation("根据二级目录IDList查寻所有三级目录信息")
@AnonymousAccess
public List<SysThreeCatalog> selectThreeCatalogListByTwoIdList(@RequestBody List<String> twoIds, @RequestParam String schoolId) {
SysThreeCatalogExample example = new SysThreeCatalogExample();
ArrayList<String> list = new ArrayList<>();
list.add(schoolId);
list.add(Constant.ADMIN);
example.createCriteria().andTwoIdIn(twoIds).andCreatorIn(list);
example.setOrderByClause("sort asc");
List<SysThreeCatalog> sysThreeCatalogs = threeCatalogMapper.selectByExample(example);
return sysThreeCatalogs;
}
//增加二级目录 SysTwoCatalog systemOwner //增加二级目录 SysTwoCatalog systemOwner
@AnonymousAccess @AnonymousAccess
@ApiOperation("添加二级目录") @ApiOperation("添加二级目录")
@ -248,6 +264,15 @@ public class CourseApi {
return threeCatalogMapper.selectByPrimaryKey(chapterId); return threeCatalogMapper.selectByPrimaryKey(chapterId);
} }
@AnonymousAccess
@ApiOperation("根据章节ID集合查询List")
@PostMapping("selectChapterByIdList")
public List<SysThreeCatalog> selectChapterByIdList(@RequestBody List<String> chapterIds) {
SysThreeCatalogExample example =new SysThreeCatalogExample();
example.createCriteria().andThreeIdIn(chapterIds);
return threeCatalogMapper.selectByExample(example);
}
/** /**
* *

@ -50,5 +50,5 @@ public interface SysCaseQuestionStepMapper {
List<SysCaseQuestionStepWithBLOBs> getCaseStepByIds(@Param("ids") List<String> ids); List<SysCaseQuestionStepWithBLOBs> getCaseStepByIds(@Param("ids") List<String> ids);
List<SysCaseQuestionStepWithBLOBs> selectCaseStepListBatchByIdListAndSort(@Param("threeId") String threeId); List<SysCaseQuestionStepWithBLOBs> selectCaseStepListBatchByIdListAndSort(@Param("threeId") String threeId);
List<SysCaseQuestionStepWithBLOBs> selectCaseStepListBatchByIdList(@Param("list") List<String> list); List<SysCaseQuestionStepWithBLOBs> selectCaseStepByThreeIds(@Param("list") List<String> list);
} }

@ -445,7 +445,7 @@
</foreach> </foreach>
</select> </select>
<select id="selectCaseStepListBatchByIdList" resultMap="ResultMapWithBLOBs"> <select id="selectCaseStepByThreeIds" resultMap="ResultMapWithBLOBs">
SELECT st.three_id,sc.* SELECT st.three_id,sc.*
from sys_case_question_steps sc from sys_case_question_steps sc
left join sys_case_questions s left join sys_case_questions s

Loading…
Cancel
Save