修改学生端案例题步骤展示接口

master
xiaoCJ
parent 630fc6fd1c
commit 0fbd48b449

@ -55,7 +55,7 @@ public class CaseStepController {
@PostMapping("updateCase")
public ResultEntity<HttpStatus> updateCase(@RequestBody SysCaseQuestionStepWithBLOBs caseQuestionStepWithBLOBs,
@ApiParam("谁调的请求,传管理员/学校ID") @RequestParam String source) {
List<SysTopicAndCourse> sysTopicAndCourses = getSysTopicAndCourses(caseQuestionStepWithBLOBs.getCaseId());
// List<SysTopicAndCourse> sysTopicAndCourses = getSysTopicAndCourses(caseQuestionStepWithBLOBs.getCaseId());
// if (!sysTopicAndCourses.isEmpty()) {
// return new ResultEntity<>(HttpStatus.BAD_REQUEST, "该案例题正在被使用!");
// }
@ -63,7 +63,7 @@ public class CaseStepController {
//todo 管理员任意修改,老师只能改自己的
SysCaseQuestion sysCaseQuestion = sysCaseQuestionMapper.selectByPrimaryKey(caseQuestionStepWithBLOBs.getCaseId());
if ("管理员".equals(source) || source.equals(sysCaseQuestion.getSource())) {
caseQuestionStepMapper.updateByPrimaryKey(caseQuestionStepWithBLOBs);
caseQuestionStepMapper.updateByPrimaryKeyWithBLOBs(caseQuestionStepWithBLOBs);
return new ResultEntity<>(HttpStatus.OK, "编辑成功!");
} else {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "权限不足!");

@ -293,6 +293,7 @@ public class CaseApi {
SysCaseQuestionExample example1 = new SysCaseQuestionExample();
example1.createCriteria().andCaseIdIn(collect).andSourceEqualTo("管理员");
example1.setOrderByClause("create_time");
List<SysCaseQuestion> list = caseQuestionMapper.selectByExampleWithBLOBs(example1);
return list;
}
@ -307,12 +308,8 @@ public class CaseApi {
@PostMapping("selectCaseStepListBatchByIdListAndSort")
@ApiOperation("查询案例题步骤并排序")
@AnonymousAccess
public List<SysCaseQuestionStepWithBLOBs> selectCaseStepListBatchByIdListAndSort(@RequestBody List<String> caseIdList) {
SysCaseQuestionStepExample example = new SysCaseQuestionStepExample();
example.createCriteria().andCaseIdIn(caseIdList);
example.setOrderByClause("sort");
List<SysCaseQuestionStepWithBLOBs> sysCaseQuestionStepWithBLOBs = caseQuestionStepMapper.selectByExampleWithBLOBs(example);
return sysCaseQuestionStepWithBLOBs;
public List<SysCaseQuestionStepWithBLOBs> selectCaseStepListBatchByIdListAndSort(@RequestParam String threeId) {
return caseQuestionStepMapper.selectCaseStepListBatchByIdListAndSort(threeId);
}

@ -126,7 +126,7 @@ public class ResourceDataApi {
List<Map<String, String>> filePaths = sysResourceDataMapper.getByIds(ids);
String zipName = "TZ_" + ((int) (Math.random() * 10000)) + ".zip";
String zipPath = filePath + "/" + zipName;
CompressUtil.compress(filePaths, zipPath, false);
CompressUtil.compress11(filePaths, zipPath, false);
File pocZipFile = new File(zipPath);
CompressUtil.downloadZip(response, zipName, pocZipFile);
pocZipFile.delete();

@ -45,4 +45,6 @@ public interface SysCaseQuestionStepMapper {
List<TrainingDto> selectTrainingByIds(@Param("list") List<String> caseStepIdList);
List<SysCaseQuestionStepWithBLOBs> getCaseStepByIds(@Param("ids") List<String> ids);
List<SysCaseQuestionStepWithBLOBs> selectCaseStepListBatchByIdListAndSort(@Param("threeId") String threeId);
}

@ -48,7 +48,51 @@ public class CompressUtil {
if (keepDirStructure != null && keepDirStructure) {
zos.putNextEntry(new ZipEntry(relativePath));
} else {
zos.putNextEntry(new ZipEntry(i + "_" + relativeName));
zos.putNextEntry(new ZipEntry(relativeName));
}
int len;
while ((len = fis.read(buf)) > 0) {
zos.write(buf, 0, len);
}
zos.closeEntry();
// zos.close();
}
zos.close();
if (!zipFile.exists()) {
zipFile.createNewFile();
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* zip
* @param filePaths
* @param zipFilePath
* @param keepDirStructure
*/
public static void compress11(List<Map<String, String>> filePaths, String zipFilePath, Boolean keepDirStructure) {
byte[] buf = new byte[1024];
File zipFile = new File(zipFilePath);
try {
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile));
for (int i = 0; i < filePaths.size(); i++) {
String relativeName = filePaths.get(i).get("resource_name");
String relativePath = filePath+filePaths.get(i).get("url");
if (StringUtils.isEmpty(relativePath)) {
continue;
}
File sourceFile = new File(relativePath);
if (sourceFile == null || !sourceFile.exists()) {
continue;
}
FileInputStream fis = new FileInputStream(sourceFile);
if (keepDirStructure != null && keepDirStructure) {
zos.putNextEntry(new ZipEntry(relativePath));
} else {
zos.putNextEntry(new ZipEntry(relativeName));
}
int len;
while ((len = fis.read(buf)) > 0) {

@ -421,7 +421,8 @@
</resultMap>
<select id="selectTrainingByIds" resultMap="DtoBaseResultMap">
SELECT SUM(sqs.score) AS total_steps_score, sqs.case_id,COUNT(sqs.case_step_id) AS total_steps_count, sq.title, s3.three_name
SELECT SUM(sqs.score) AS total_steps_score, sqs.case_id,COUNT(sqs.case_step_id) AS total_steps_count, sq.title,
s3.three_name
FROM sys_case_question_steps sqs
JOIN sys_case_questions sq ON sqs.case_id = sq.case_id
JOIN sys_topic_and_course s3 ON sq.case_id = s3.topic_id
@ -440,4 +441,15 @@
#{item}
</foreach>
</select>
<select id="selectCaseStepListBatchByIdListAndSort" resultMap="ResultMapWithBLOBs">
SELECT sc.*
from sys_case_question_steps sc
left join sys_case_questions s
on sc.case_id = s.case_id
left join sys_topic_and_course st
on st.topic_id = s.case_id
where st.three_id = #{threeId}
order by s.create_time ,sc.sort
</select>
</mapper>
Loading…
Cancel
Save