修改接口

master
xiaoCJ 8 months ago
parent 0e4f22e187
commit c0fe06b160

@ -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<TrainingDto> trainingDtos = caseQuestionStepMapper.selectTrainingByIds(caseStepIdList);
return trainingDtos;
}
//* 单独接口
//* 获取所有内置案例题步骤信息
@AnonymousAccess
@ApiOperation("获取所有内置案例题步骤信息")
@PostMapping("selectAllStepBySystemOwner")
public List<SysCaseQuestionStepWithBLOBs> selectAllStepBySystemOwner(@RequestParam String systemOwner) {
SysOneCatalog sysOneCatalogs = getSysOneCatalogs(systemOwner);
List<String> 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<String, List<String>> getMapChapterIdAndCaseIdsByCourseIdAndChapterId(@RequestBody List<SysThreeCatalog> sysThreeCatalogs,
@RequestParam String systemOwner) {
// 批量查询案例题ID
Map<String, List<String>> caseIdMap = new HashMap<>();
List<String> courseIdList = new ArrayList<>();
List<String> chapterIdList = new ArrayList<>();
for (SysThreeCatalog chapter : sysThreeCatalogs) {
courseIdList.add(chapter.getTwoId());
chapterIdList.add(chapter.getThreeId());
}
List<Map<String, Object>> results = caseQuestionMapper.selectCaseIdByCourseAndChapterIds(courseIdList, chapterIdList);
for (Map<String, Object> 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;
}
}

@ -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<SysCaseQuestion> selectCaseByConditionsByBind(@Param("title") String title);
List<Map<String, Object>> selectCaseIdByCourseAndChapterIds(@Param("courseIdList") List<String> courseIdList, @Param("chapterIdList") List<String> chapterIdList);
}

@ -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<String> 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<String> getCaseIdsBySourceIsAdmin(@Param("oneId") String oneId);
}

@ -470,4 +470,17 @@
</where>
order by s.create_time
</select>
<select id="selectCaseIdByCourseAndChapterIds" resultType="map">
SELECT chapter_id, case_id
FROM sys_case_question
WHERE course_id IN
<foreach collection="courseIdList" item="courseId" open="(" separator="," close=")">
#{courseId}
</foreach>
AND chapter_id IN
<foreach collection="chapterIdList" item="chapterId" open="(" separator="," close=")">
#{chapterId}
</foreach>
</select>
</mapper>
Loading…
Cancel
Save