whb 8 months ago
commit d251f63a91

@ -151,8 +151,9 @@ public class CaseController {
@ApiOperation("案例题编辑")
@PostMapping("updateCase")
public ResultEntity<HttpStatus> updateCase(@RequestBody SysCaseQuestion sysCaseQuestion,
@ApiParam("谁调的请求,传管理员/学校ID") @RequestParam String source) {
List<SysTopicAndCourse> sysTopicAndCourses = getSysTopicAndCourses(sysCaseQuestion.getCaseId(), sysCaseQuestion.getOneId());
@ApiParam("谁调的请求,传管理员/学校ID") @RequestParam String source,
@ApiParam("修改前旧的oneId") @RequestParam String oldOneId) {
List<SysTopicAndCourse> sysTopicAndCourses = getSysTopicAndCourses(sysCaseQuestion.getCaseId(), oldOneId);
// if (!sysTopicAndCourses.isEmpty()) {
// return new ResultEntity<>(HttpStatus.BAD_REQUEST, "该案例题正在被使用!");
// } else {
@ -160,6 +161,8 @@ public class CaseController {
if ("管理员".equals(source) || source.equals(sysCaseQuestion.getSource())) {
if (!sysTopicAndCourses.isEmpty()) {
SysTopicAndCourse sysTopicAndCourse = sysTopicAndCourses.get(0);
sysTopicAndCourse.setOneId(sysCaseQuestion.getOneId());
sysTopicAndCourse.setOneName(sysCaseQuestion.getOneName());
sysTopicAndCourse.setTwoId(sysCaseQuestion.getTwoId());
sysTopicAndCourse.setThreeId(sysCaseQuestion.getThreeId());
sysTopicAndCourse.setTwoName(sysCaseQuestion.getTwoName());

@ -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, "权限不足!");

@ -43,6 +43,12 @@ public class CourseTagManageController {
private SysTopicAndCourseMapper sysTopicAndCourseMapper;
@Autowired
private SysResourceAndCourseMapper sysResourceAndCourseMapper;
@Autowired
private SysResourceMapper sysResourceMapper;
@Autowired
private SysCaseQuestionMapper sysCaseQuestionMapper;
@Autowired
private SysObjectiveQuestionsMapper sysObjectiveQuestionsMapper;
@AnonymousAccess
@ -98,11 +104,11 @@ public class CourseTagManageController {
List<String> ids = sysResourceAndCourses.stream().map(SysResourceAndCourse::getId).collect(Collectors.toList());
sysResourceAndCourseMapper.batchUpdateTwoName(ids, name);
SysTopicAndCourseExample example1 =new SysTopicAndCourseExample();
SysTopicAndCourseExample example1 = new SysTopicAndCourseExample();
example1.createCriteria().andTwoIdEqualTo(id);
List<SysTopicAndCourse> sysTopicAndCourses = sysTopicAndCourseMapper.selectByExample(example1);
List<String> collect = sysTopicAndCourses.stream().map(SysTopicAndCourse::getId).collect(Collectors.toList());
sysTopicAndCourseMapper.batchUpdateTwoName(collect,name);
sysTopicAndCourseMapper.batchUpdateTwoName(collect, name);
} else {
SysThreeCatalog sysThreeCatalog = sysThreeCatalogMapper.selectByPrimaryKey(id);
@ -115,11 +121,11 @@ public class CourseTagManageController {
List<String> ids = sysResourceAndCourses.stream().map(SysResourceAndCourse::getId).collect(Collectors.toList());
sysResourceAndCourseMapper.batchUpdateThreeName(ids, name);
SysTopicAndCourseExample example1 =new SysTopicAndCourseExample();
SysTopicAndCourseExample example1 = new SysTopicAndCourseExample();
example1.createCriteria().andThreeIdEqualTo(id);
List<SysTopicAndCourse> sysTopicAndCourses = sysTopicAndCourseMapper.selectByExample(example1);
List<String> collect = sysTopicAndCourses.stream().map(SysTopicAndCourse::getId).collect(Collectors.toList());
sysTopicAndCourseMapper.batchUpdateThreeName(collect,name);
sysTopicAndCourseMapper.batchUpdateThreeName(collect, name);
}
return new ResultEntity<>(HttpStatus.OK, "修改成功");
}
@ -133,59 +139,87 @@ public class CourseTagManageController {
try {
if (type == 2) {
sysTwoCatalogMapper.deleteByPrimaryKey(id);
//删除资源
//删除资源关系表
SysResourceAndCourseExample example1 = new SysResourceAndCourseExample();
example1.createCriteria().andTwoIdEqualTo(id);
List<SysResourceAndCourse> sysResourceAndCourses = sysResourceAndCourseMapper.selectByExample(example1);
List<String> resourceIds = sysResourceAndCourses.stream().map(SysResourceAndCourse::getResourceId).collect(Collectors.toList());
sysResourceAndCourseMapper.deleteByExample(example1);
//删除题目
//删除资源
if (!resourceIds.isEmpty()) {
SysResourceExample sysResourceExample = new SysResourceExample();
sysResourceExample.createCriteria().andResourceIdIn(resourceIds);
sysResourceMapper.deleteByExample(sysResourceExample);
}
//删除题目关系表
SysTopicAndCourseExample example = new SysTopicAndCourseExample();
example.createCriteria().andTwoIdEqualTo(id);
List<SysTopicAndCourse> topicAndCourseList = sysTopicAndCourseMapper.selectByExample(example);
List<String> topicIds = topicAndCourseList.stream().map(SysTopicAndCourse::getTopicId).collect(Collectors.toList());
sysTopicAndCourseMapper.deleteByExample(example);
//删除案例题
if (!topicIds.isEmpty()) {
SysCaseQuestionExample sysCaseQuestionExample = new SysCaseQuestionExample();
sysCaseQuestionExample.createCriteria().andCaseIdIn(topicIds);
sysCaseQuestionMapper.deleteByExample(sysCaseQuestionExample);
//删除客观题
SysObjectiveQuestionsExample sysObjectiveQuestionsExample = new SysObjectiveQuestionsExample();
sysObjectiveQuestionsExample.createCriteria().andObjectiveIdIn(topicIds);
sysObjectiveQuestionsMapper.deleteByExample(sysObjectiveQuestionsExample);
}
} else {
sysThreeCatalogMapper.deleteByPrimaryKey(id);
//删除资源关系表
SysResourceAndCourseExample sysResourceAndCourseExample = new SysResourceAndCourseExample();
sysResourceAndCourseExample.createCriteria().andThreeIdEqualTo(id);
List<SysResourceAndCourse> sysResourceAndCourses = sysResourceAndCourseMapper.selectByExample(sysResourceAndCourseExample);
List<String> resourceIds = sysResourceAndCourses.stream().map(SysResourceAndCourse::getResourceId).collect(Collectors.toList());
sysResourceAndCourseMapper.deleteByExample(sysResourceAndCourseExample);
//删除资源
SysResourceAndCourseExample example1 = new SysResourceAndCourseExample();
example1.createCriteria().andThreeIdEqualTo(id);
sysResourceAndCourseMapper.deleteByExample(example1);
if (!resourceIds.isEmpty()) {
SysResourceExample sysResourceExample = new SysResourceExample();
sysResourceExample.createCriteria().andResourceIdIn(resourceIds);
sysResourceMapper.deleteByExample(sysResourceExample);
}
//删除题目
SysTopicAndCourseExample example = new SysTopicAndCourseExample();
example.createCriteria().andThreeIdEqualTo(id);
sysTopicAndCourseMapper.deleteByExample(example);
sysThreeCatalogMapper.deleteByPrimaryKey(id);
//删除题目关系表
SysTopicAndCourseExample sysTopicAndCourseExample = new SysTopicAndCourseExample();
sysTopicAndCourseExample.createCriteria().andThreeIdEqualTo(id);
List<SysTopicAndCourse> topicAndCourseList = sysTopicAndCourseMapper.selectByExample(sysTopicAndCourseExample);
List<String> topicIds = topicAndCourseList.stream().map(SysTopicAndCourse::getTopicId).collect(Collectors.toList());
sysTopicAndCourseMapper.deleteByExample(sysTopicAndCourseExample);
//删除案例题
if (!topicIds.isEmpty()) {
SysCaseQuestionExample sysCaseQuestionExample = new SysCaseQuestionExample();
sysCaseQuestionExample.createCriteria().andCaseIdIn(topicIds);
sysCaseQuestionMapper.deleteByExample(sysCaseQuestionExample);
//删除客观题
SysObjectiveQuestionsExample sysObjectiveQuestionsExample = new SysObjectiveQuestionsExample();
sysObjectiveQuestionsExample.createCriteria().andObjectiveIdIn(topicIds);
sysObjectiveQuestionsMapper.deleteByExample(sysObjectiveQuestionsExample);
}
}
} catch (Exception e) {
e.printStackTrace();
return new ResultEntity<>(HttpStatus.INTERNAL_SERVER_ERROR,"删除失败,请联系管理员");
return new ResultEntity<>(HttpStatus.INTERNAL_SERVER_ERROR, "删除失败,请联系管理员");
}
return new ResultEntity<>(HttpStatus.OK, "删除成功");
}
// @AnonymousAccess
// @ApiOperation("排序")
// @PostMapping("setRank") //修改成LIST
// public ResultEntity<String> setRank(@ApiParam("一级传1/二级传2/三级传3") @RequestParam int type,
// @RequestParam String id,
// @RequestParam int rank) {
// if (type == 1) {
// SysOneCatalog sysOneCatalog = sysOneCatalogMapper.selectByPrimaryKey(id);
// sysOneCatalog.setSort(rank);
// sysOneCatalogMapper.updateByPrimaryKey(sysOneCatalog);
// return new ResultEntity<>(HttpStatus.OK, "排序成功");
// } else if (type == 2) {
// SysTwoCatalog sysTwoCatalog = sysTwoCatalogMapper.selectByPrimaryKey(id);
// sysTwoCatalog.setSort(rank);
// sysTwoCatalogMapper.updateByPrimaryKey(sysTwoCatalog);
// return new ResultEntity<>(HttpStatus.OK, "排序成功");
// } else {
// SysThreeCatalog sysThreeCatalog = sysThreeCatalogMapper.selectByPrimaryKey(id);
// sysThreeCatalog.setSort(rank);
// sysThreeCatalogMapper.updateByPrimaryKey(sysThreeCatalog);
// return new ResultEntity<>(HttpStatus.OK, "排序成功");
// }
// }
@AnonymousAccess
@ApiOperation("一级目录重新排序")

@ -234,7 +234,7 @@ public class TopicResourceController {
SysObjectiveQuestions newData = new SysObjectiveQuestions();
BeanUtils.copyProperties(dto, newData);
sysObjectiveQuestionMapper.updateByPrimaryKey(newData);
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "编辑完成!");
return new ResultEntity<>(HttpStatus.OK, "编辑完成!");
}
@AnonymousAccess

@ -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);
}

@ -123,15 +123,40 @@ public class CourseApi {
return false;
}
twoCatalogMapper.deleteByPrimaryKey(twoId);
//删除资源
//删除资源关系表
SysResourceAndCourseExample example1 = new SysResourceAndCourseExample();
example1.createCriteria().andTwoIdEqualTo(twoId);
List<SysResourceAndCourse> sysResourceAndCourses = sysResourceAndCourseMapper.selectByExample(example1);
List<String> resourceIds = sysResourceAndCourses.stream().map(SysResourceAndCourse::getResourceId).collect(Collectors.toList());
sysResourceAndCourseMapper.deleteByExample(example1);
//删除题目
//删除资源
if (!resourceIds.isEmpty()) {
SysResourceExample sysResourceExample = new SysResourceExample();
sysResourceExample.createCriteria().andResourceIdIn(resourceIds);
sysResourceMapper.deleteByExample(sysResourceExample);
}
//删除题目关系表
SysTopicAndCourseExample example = new SysTopicAndCourseExample();
example.createCriteria().andTwoIdEqualTo(twoId);
List<SysTopicAndCourse> topicAndCourseList = sysTopicAndCourseMapper.selectByExample(example);
List<String> topicIds = topicAndCourseList.stream().map(SysTopicAndCourse::getTopicId).collect(Collectors.toList());
sysTopicAndCourseMapper.deleteByExample(example);
//删除案例题
if (!topicIds.isEmpty()) {
SysCaseQuestionExample sysCaseQuestionExample = new SysCaseQuestionExample();
sysCaseQuestionExample.createCriteria().andCaseIdIn(topicIds);
sysCaseQuestionMapper.deleteByExample(sysCaseQuestionExample);
//删除客观题
SysObjectiveQuestionsExample sysObjectiveQuestionsExample = new SysObjectiveQuestionsExample();
sysObjectiveQuestionsExample.createCriteria().andObjectiveIdIn(topicIds);
sysObjectiveQuestionsMapper.deleteByExample(sysObjectiveQuestionsExample);
}
return true;
} catch (Exception e) {
e.printStackTrace();

@ -1,32 +1,24 @@
package com.sztzjy.resource_center.controller.api;
import cn.hutool.core.util.CharsetUtil;
import com.sztzjy.resource_center.annotation.AnonymousAccess;
import com.sztzjy.resource_center.entity.SysCaseQuestion;
import com.sztzjy.resource_center.entity.SysResourceData;
import com.sztzjy.resource_center.entity.SysResourceDataExample;
import com.sztzjy.resource_center.mapper.SysCaseQuestionMapper;
import com.sztzjy.resource_center.mapper.SysResourceDataMapper;
import com.sztzjy.resource_center.util.CompressUtil;
import com.sztzjy.resource_center.util.file.IFileUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@RestController
@ -40,7 +32,8 @@ public class ResourceDataApi {
private SysCaseQuestionMapper caseQuestionMapper;
@Autowired
IFileUtil fileUtil;
@Value("${file.path}")
private String filePath;
/**
*
@ -91,6 +84,8 @@ public class ResourceDataApi {
}
/**
*
* deleteResourceData
@ -120,14 +115,22 @@ public class ResourceDataApi {
*/
@AnonymousAccess
@ApiOperation("数据集下载")
@GetMapping("downloadResourceData")
private void selectResourceDataList(@RequestParam String resourceId,
HttpServletResponse response) {
try {
SysResourceData sysResourceData = sysResourceDataMapper.selectByPrimaryKey(resourceId);
String resourceName = sysResourceData.getResourceName();
fileUtil.download(response, resourceName, sysResourceData.getUrl());
} catch (Exception e) {
@PostMapping("downloadResourceData")
private void downloadResourceData(@RequestBody List<String> ids, HttpServletResponse response) {
this.downloadFile(ids, response);
}
public void downloadFile(List<String> ids, HttpServletResponse response) {
if (ids != null && !ids.isEmpty()) {
List<Map<String, String>> filePaths = sysResourceDataMapper.getByIds(ids);
String zipName = "TZ_" + ((int) (Math.random() * 10000)) + ".zip";
String zipPath = filePath + "/" + zipName;
CompressUtil.compress11(filePaths, zipPath, false);
File pocZipFile = new File(zipPath);
CompressUtil.downloadZip(response, zipName, pocZipFile);
pocZipFile.delete();
}
}
}

@ -33,7 +33,9 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.*;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.*;
@ -66,7 +68,7 @@ public class AdminComponentCodeController {
@AnonymousAccess
@Transactional
public ResultEntity<String> add(@ApiParam("代码内容") String codeContent,
@ApiParam("参数释义") @RequestParam(required = false) String parameterContent,
@ApiParam("参数释义")@RequestParam(required = false) String parameterContent,
@ApiParam("步骤名称(一级标签)") String stepName,
@ApiParam("案例名称(二级标签)") String caseName,
@RequestParam(required = false) List<MultipartFile> dataFile) {
@ -121,23 +123,20 @@ public class AdminComponentCodeController {
}
@PostMapping("updateAdminData")
@ApiOperation("编辑")
@AnonymousAccess
@Transactional
public ResultEntity<String> updateAdminData(@ApiParam("案例ID") @RequestBody Integer id,
@ApiParam("代码内容") @RequestBody(required = false) String codeContent,
@ApiParam("参数释义") @RequestBody(required = false) String parameterContent,
@ApiParam("步骤名称(一级标签)") @RequestBody(required = false) String stepName,
@ApiParam("案例名称(二级标签)") @RequestBody(required = false) String caseName) {
public ResultEntity<String> updateAdminData(@RequestBody UpdateAdminDataDTO dto) {
//编辑
try {
AdminComponentCodeWithBLOBs adminComponentCode = new AdminComponentCodeWithBLOBs();
adminComponentCode.setId(id);
adminComponentCode.setCourseName(stepName);
adminComponentCode.setChapterName(caseName);
adminComponentCode.setItem(codeContent);
adminComponentCode.setDefinition(parameterContent);
adminComponentCode.setId(dto.getId());
adminComponentCode.setCourseName(dto.getStepName());
adminComponentCode.setChapterName(dto.getCaseName());
adminComponentCode.setItem(dto.getCodeContent());
adminComponentCode.setDefinition(dto.getParameterContent());
adminComponentCode.setStatus(0); //默认下架,发布后上架
adminComponentCode.setCreateTime(new Date()); //修改时间
@ -151,17 +150,19 @@ public class AdminComponentCodeController {
}
@PostMapping("getAdminData")
@ApiOperation("展示")
@AnonymousAccess
@Transactional
public ResultEntity getAdminData(@RequestParam Integer index,
@RequestParam Integer size,
@RequestParam(required = false) String caseName) {
@RequestParam(required = false) String caseName ) {
AdminComponentCodeExample codeExample = new AdminComponentCodeExample();
if (!caseName.isEmpty()) {
codeExample.createCriteria().andChapterNameLike("%" + caseName + "%");
AdminComponentCodeExample codeExample=new AdminComponentCodeExample();
if(!caseName.isEmpty()){
codeExample.createCriteria().andChapterNameLike("%"+caseName+"%");
}
List<AdminComponentCodeWithBLOBs> adminComponentCodeWithBLOBs = adminComponentCodeMapper.selectByExampleWithBLOBs(codeExample);
@ -169,7 +170,7 @@ public class AdminComponentCodeController {
PageInfo pageInfo = PageUtil.pageHelper(adminComponentCodeWithBLOBs, index, size);
return new ResultEntity<>(HttpStatus.OK, "成功!", pageInfo);
return new ResultEntity<>(HttpStatus.OK, "成功!",pageInfo);
}
@PostMapping("addFile")
@ -233,6 +234,7 @@ public class AdminComponentCodeController {
}
@ApiOperation("后端根据名字创建notebook")
@GetMapping("/createNoteBook")
@AnonymousAccess
@ -266,9 +268,6 @@ public class AdminComponentCodeController {
System.out.println("删除文件失败: " + file.getAbsolutePath());
}
}
} else {
// 文件不存在
System.out.println("未找到文件: " + name);
}
//没有就创建
@ -302,6 +301,14 @@ public class AdminComponentCodeController {
// + "\"nbformat_minor\": 2"
// + "}";
if (codeContent.startsWith("```python")) {
codeContent = codeContent.replaceFirst("```python", "");
}
if (codeContent.endsWith("```")) {
codeContent = codeContent.substring(0, codeContent.length() - 3);
}
String notebookContent = "{"
+ "\"cells\": ["
+ "{"
@ -355,11 +362,7 @@ public class AdminComponentCodeController {
Process process = Runtime.getRuntime().exec(commandMove);
// 获取进程的输入流
BufferedReader inputStream = new BufferedReader(new InputStreamReader(process.getInputStream()));
// 获取进程的输出流
BufferedReader errorStream = new BufferedReader(new InputStreamReader(process.getErrorStream()));
// 等待进程执行完成
int exitCodeInfo = process.waitFor();

@ -0,0 +1,26 @@
package com.sztzjy.resource_center.entity.admin;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author tz
* @date 2024/7/29 17:30
*/
@Data
public class UpdateAdminDataDTO {
@ApiModelProperty("案例ID")
private Integer id;
@ApiModelProperty("代码内容")
private String codeContent;
@ApiModelProperty("参数释义")
private String parameterContent;
@ApiModelProperty("步骤名称(一级标签)")
private String stepName;
@ApiModelProperty("案例名称(二级标签)")
private String caseName;
}

@ -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);
}

@ -3,6 +3,7 @@ package com.sztzjy.resource_center.mapper;
import com.sztzjy.resource_center.entity.SysResourceData;
import com.sztzjy.resource_center.entity.SysResourceDataExample;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -29,4 +30,6 @@ public interface SysResourceDataMapper {
int updateByPrimaryKeySelective(SysResourceData record);
int updateByPrimaryKey(SysResourceData record);
List<Map<String, String>> getByIds(@Param("ids") List<String> ids);
}

@ -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>

@ -223,4 +223,12 @@
source = #{source,jdbcType=VARCHAR}
where resource_data_id = #{resourceDataId,jdbcType=VARCHAR}
</update>
<select id="getByIds" parameterType="String" resultType="map">
SELECT af.url,af.resource_name FROM sys_resource_data af
WHERE af.url IS NOT NULL
AND af.resource_data_id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper>
Loading…
Cancel
Save