From 99aca080742a1256bd08d07ee7cb6bc0cec1c3e0 Mon Sep 17 00:00:00 2001 From: "@t2652009480" <2652009480@qq.com> Date: Mon, 29 Jul 2024 17:34:26 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E7=BB=84=E4=BB=B6=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=AD=A6=E7=94=9F=E7=AB=AF=E5=8A=A8=E6=80=81=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E3=80=81=E8=B6=85=E7=AE=A1=E7=AB=AF=E6=94=AF=E6=8C=81=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=BF=AE=E6=94=B9(jupyter)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/AdminComponentCodeController.java | 10 +++---- .../entity/admin/UpdateAdminDataDTO.java | 26 +++++++++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/sztzjy/resource_center/entity/admin/UpdateAdminDataDTO.java diff --git a/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminComponentCodeController.java b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminComponentCodeController.java index e450083..3c71e12 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminComponentCodeController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminComponentCodeController.java @@ -130,11 +130,11 @@ public class AdminComponentCodeController { @ApiOperation("编辑") @AnonymousAccess @Transactional - public ResultEntity 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 updateAdminData(@ApiParam("案例ID") @RequestParam Integer id, + @ApiParam("代码内容")@RequestParam(required = false) String codeContent, + @ApiParam("参数释义")@RequestParam(required = false) String parameterContent, + @ApiParam("步骤名称(一级标签)")@RequestParam(required = false) String stepName, + @ApiParam("案例名称(二级标签)")@RequestParam(required = false) String caseName) { //编辑 try { AdminComponentCodeWithBLOBs adminComponentCode = new AdminComponentCodeWithBLOBs(); diff --git a/src/main/java/com/sztzjy/resource_center/entity/admin/UpdateAdminDataDTO.java b/src/main/java/com/sztzjy/resource_center/entity/admin/UpdateAdminDataDTO.java new file mode 100644 index 0000000..2ee6eae --- /dev/null +++ b/src/main/java/com/sztzjy/resource_center/entity/admin/UpdateAdminDataDTO.java @@ -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; +} From fbec9a24afbb8dc20aa53a1f15a99442dbafc64b Mon Sep 17 00:00:00 2001 From: "@t2652009480" <2652009480@qq.com> Date: Mon, 29 Jul 2024 18:11:00 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E7=BB=84=E4=BB=B6=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=AD=A6=E7=94=9F=E7=AB=AF=E5=8A=A8=E6=80=81=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E3=80=81=E8=B6=85=E7=AE=A1=E7=AB=AF=E6=94=AF=E6=8C=81=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=BF=AE=E6=94=B9(jupyter)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/AdminComponentCodeController.java | 123 ++++++++++-------- 1 file changed, 71 insertions(+), 52 deletions(-) diff --git a/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminComponentCodeController.java b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminComponentCodeController.java index 3c71e12..63898a3 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminComponentCodeController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminComponentCodeController.java @@ -33,13 +33,11 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; +import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.UUID; +import java.util.*; /** * @author tz @@ -130,19 +128,15 @@ public class AdminComponentCodeController { @ApiOperation("编辑") @AnonymousAccess @Transactional - public ResultEntity updateAdminData(@ApiParam("案例ID") @RequestParam Integer id, - @ApiParam("代码内容")@RequestParam(required = false) String codeContent, - @ApiParam("参数释义")@RequestParam(required = false) String parameterContent, - @ApiParam("步骤名称(一级标签)")@RequestParam(required = false) String stepName, - @ApiParam("案例名称(二级标签)")@RequestParam(required = false) String caseName) { + public ResultEntity 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()); //修改时间 @@ -240,44 +234,49 @@ public class AdminComponentCodeController { } + @ApiOperation("后端根据名字创建notebook") @GetMapping("/createNoteBook") @AnonymousAccess public ResultEntity createNoteBook(@ApiParam("参数为:案例名") String name, - @ApiParam("代码内容") String codeContent){ + @ApiParam("代码内容") String codeContent) throws IOException { //判断有无这个案例 -// -// String path = "/usr/local/tianzeProject/jupyter/tch"; -// -// // 创建表示该目录的 File 对象 -// File directory = new File(path); -// -// // 获取目录中的所有文件和子目录 -// File[] filesList = directory.listFiles(); -// -// -// if (filesList != null) { -// // 使用流查找目标文件 -// Optional targetFile = Arrays.stream(filesList) -// .filter(file -> file.getName().equals(name)) -// .findFirst(); -// -// if (targetFile.isPresent()) { -// return new ResultEntity<>(HttpStatus.OK,"文件已存在"); -// } -// } + String path = "/usr/local/tianzeProject/jupyter/tch/"; + + // 创建表示该目录的 File 对象 + File directory = new File(path); + + // 获取目录中的所有文件和子目录 + File[] filesList = directory.listFiles(); - //没有就创建 + if (filesList != null) { + // 使用流查找目标文件 + Optional targetFile = Arrays.stream(filesList) + .filter(file -> file.getName().equals(name)) + .findFirst(); + if (targetFile.isPresent()) { + // 找到目标文件 + File file = targetFile.get(); + // 删除文件 + boolean deleted = file.delete(); + if (deleted) { + System.out.println("文件已删除: " + file.getAbsolutePath()); + } else { + System.out.println("删除文件失败: " + file.getAbsolutePath()); + } + } + } + + //没有就创建 AdminJupyterTokenExample tokenExample = new AdminJupyterTokenExample(); tokenExample.createCriteria().andTypeEqualTo(1); List adminJupyterTokenList = adminJupyterTokenMapper.selectByExample(tokenExample); - if (adminJupyterTokenList.isEmpty()) - { - return new ResultEntity<>(HttpStatus.BAD_REQUEST,"Token不存在!"); + if (adminJupyterTokenList.isEmpty()) { + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "Token不存在!"); } try (CloseableHttpClient client = HttpClients.createDefault()) { @@ -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\": [" + "{" @@ -336,15 +343,8 @@ public class AdminComponentCodeController { + "}"; - - - - // 在根目录下创建新的笔记本 - HttpPut createNotebookRequest = new HttpPut(JUPYTER_URL + "/api/contents/"+name+".ipynb"); - - - + HttpPut createNotebookRequest = new HttpPut(JUPYTER_URL + "/api/contents/" + name + ".ipynb"); createNotebookRequest.addHeader("Authorization", "token " + adminJupyterTokenList.get(0).getToken()); createNotebookRequest.addHeader("Content-Type", "application/json charset=UTF-8"); //createNotebookRequest.setEntity(new StringEntity("{\"type\": \"notebook\", \"content\": " + notebookContent + "}")); @@ -354,17 +354,36 @@ public class AdminComponentCodeController { int statusCode = createNotebookResponse.getStatusLine().getStatusCode(); if (statusCode == 201) { System.out.println("Notebook created successfully!"); - return new ResultEntity<>(HttpStatus.OK,"创建成功!"); + + + String toPath = "/usr/local/tianzeProject/jupyter/stu/" + name + ".ipynb"; + + String[] commandMove = {"cp", "-f", path + name + ".ipynb", toPath}; + + + Process process = Runtime.getRuntime().exec(commandMove); + + + // 等待进程执行完成 + int exitCodeInfo = process.waitFor(); + System.out.println(exitCodeInfo); + if (exitCodeInfo == 0) { + return new ResultEntity<>(HttpStatus.OK, "创建成功", true); + } else { + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "创建失败!请联系管理员", false); + } } else { String responseBody = EntityUtils.toString(createNotebookResponse.getEntity()); System.out.println("Failed to create notebook: " + responseBody); - return new ResultEntity<>(HttpStatus.OK,"已经存在,不用重复创建"); + return new ResultEntity<>(HttpStatus.OK, "已经存在,不用重复创建"); } + } catch (IOException e) { + throw new RuntimeException(e); + } catch (InterruptedException e) { + throw new RuntimeException(e); } - } catch (IOException e) { - throw new RuntimeException(e); - } + } } } From 805ce431aab6f67214702b611bd8bddc48d41c87 Mon Sep 17 00:00:00 2001 From: xiaoCJ <406612557@qq.com> Date: Tue, 30 Jul 2024 15:19:23 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A1=88=E4=BE=8B?= =?UTF-8?q?=E9=A2=98=E6=A8=A1=E6=9D=BF=E4=B8=8B=E8=BD=BD=E5=92=8C=E6=89=93?= =?UTF-8?q?=E5=8C=85=E5=8E=8B=E7=BC=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CourseTagManageController.java | 98 ++++++++++++------- .../controller/api/CourseApi.java | 22 ++++- 2 files changed, 80 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/sztzjy/resource_center/controller/CourseTagManageController.java b/src/main/java/com/sztzjy/resource_center/controller/CourseTagManageController.java index 49fb103..dc693bd 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/CourseTagManageController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/CourseTagManageController.java @@ -43,6 +43,13 @@ 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 +105,11 @@ public class CourseTagManageController { List 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 sysTopicAndCourses = sysTopicAndCourseMapper.selectByExample(example1); List 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 +122,11 @@ public class CourseTagManageController { List 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 sysTopicAndCourses = sysTopicAndCourseMapper.selectByExample(example1); List collect = sysTopicAndCourses.stream().map(SysTopicAndCourse::getId).collect(Collectors.toList()); - sysTopicAndCourseMapper.batchUpdateThreeName(collect,name); + sysTopicAndCourseMapper.batchUpdateThreeName(collect, name); } return new ResultEntity<>(HttpStatus.OK, "修改成功"); } @@ -133,58 +140,73 @@ public class CourseTagManageController { try { if (type == 2) { sysTwoCatalogMapper.deleteByPrimaryKey(id); - //删除资源 + //删除资源关系表 SysResourceAndCourseExample example1 = new SysResourceAndCourseExample(); example1.createCriteria().andTwoIdEqualTo(id); sysResourceAndCourseMapper.deleteByExample(example1); - //删除题目 + //删除资源 + SysResourceExample sysResourceExample = new SysResourceExample(); + sysResourceExample.createCriteria().andTwoTagEqualTo(id); + sysResourceMapper.deleteByExample(sysResourceExample); + + //删除题目关系表 SysTopicAndCourseExample example = new SysTopicAndCourseExample(); example.createCriteria().andTwoIdEqualTo(id); + List topicAndCourseList = sysTopicAndCourseMapper.selectByExample(example); + List topicIds = topicAndCourseList.stream().map(SysTopicAndCourse::getTopicId).collect(Collectors.toList()); sysTopicAndCourseMapper.deleteByExample(example); + + + //删除案例题 + 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); + sysResourceAndCourseMapper.deleteByExample(sysResourceAndCourseExample); + //删除资源 - SysResourceAndCourseExample example1 = new SysResourceAndCourseExample(); - example1.createCriteria().andThreeIdEqualTo(id); - sysResourceAndCourseMapper.deleteByExample(example1); + SysResourceExample sysResourceExample = new SysResourceExample(); + sysResourceExample.createCriteria().andThreeTagEqualTo(id); + 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 topicAndCourseList = sysTopicAndCourseMapper.selectByExample(sysTopicAndCourseExample); + List topicIds = topicAndCourseList.stream().map(SysTopicAndCourse::getTopicId).collect(Collectors.toList()); + + sysTopicAndCourseMapper.deleteByExample(sysTopicAndCourseExample); + + //删除案例题 + 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 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 diff --git a/src/main/java/com/sztzjy/resource_center/controller/api/CourseApi.java b/src/main/java/com/sztzjy/resource_center/controller/api/CourseApi.java index edb3483..5d96869 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/api/CourseApi.java +++ b/src/main/java/com/sztzjy/resource_center/controller/api/CourseApi.java @@ -123,15 +123,33 @@ public class CourseApi { return false; } twoCatalogMapper.deleteByPrimaryKey(twoId); - //删除资源 + //删除资源关系表 SysResourceAndCourseExample example1 = new SysResourceAndCourseExample(); example1.createCriteria().andTwoIdEqualTo(twoId); sysResourceAndCourseMapper.deleteByExample(example1); - //删除题目 + //删除资源 + SysResourceExample sysResourceExample = new SysResourceExample(); + sysResourceExample.createCriteria().andTwoTagEqualTo(twoId); + sysResourceMapper.deleteByExample(sysResourceExample); + + //删除题目关系表 SysTopicAndCourseExample example = new SysTopicAndCourseExample(); example.createCriteria().andTwoIdEqualTo(twoId); + List topicAndCourseList = sysTopicAndCourseMapper.selectByExample(example); + List topicIds = topicAndCourseList.stream().map(SysTopicAndCourse::getTopicId).collect(Collectors.toList()); sysTopicAndCourseMapper.deleteByExample(example); + + + //删除案例题 + 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(); From 986315e0770064423296890a4dc661215806d56a Mon Sep 17 00:00:00 2001 From: xiaoCJ <406612557@qq.com> Date: Tue, 30 Jul 2024 17:31:30 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A1=88=E4=BE=8B?= =?UTF-8?q?=E9=A2=98=E6=A8=A1=E6=9D=BF=E4=B8=8B=E8=BD=BD=E5=92=8C=E6=89=93?= =?UTF-8?q?=E5=8C=85=E5=8E=8B=E7=BC=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CaseController.java | 7 +- .../controller/CourseTagManageController.java | 64 +++++++++++-------- .../controller/TopicResourceController.java | 2 +- .../controller/api/CourseApi.java | 29 +++++---- .../controller/api/ResourceDataApi.java | 2 +- 5 files changed, 63 insertions(+), 41 deletions(-) diff --git a/src/main/java/com/sztzjy/resource_center/controller/CaseController.java b/src/main/java/com/sztzjy/resource_center/controller/CaseController.java index 1138e73..8ab676c 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/CaseController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/CaseController.java @@ -151,8 +151,9 @@ public class CaseController { @ApiOperation("案例题编辑") @PostMapping("updateCase") public ResultEntity updateCase(@RequestBody SysCaseQuestion sysCaseQuestion, - @ApiParam("谁调的请求,传管理员/学校ID") @RequestParam String source) { - List sysTopicAndCourses = getSysTopicAndCourses(sysCaseQuestion.getCaseId(), sysCaseQuestion.getOneId()); + @ApiParam("谁调的请求,传管理员/学校ID") @RequestParam String source, + @ApiParam("修改前旧的oneId") @RequestParam String oldOneId) { + List 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()); diff --git a/src/main/java/com/sztzjy/resource_center/controller/CourseTagManageController.java b/src/main/java/com/sztzjy/resource_center/controller/CourseTagManageController.java index dc693bd..2a65854 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/CourseTagManageController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/CourseTagManageController.java @@ -51,7 +51,6 @@ public class CourseTagManageController { private SysObjectiveQuestionsMapper sysObjectiveQuestionsMapper; - @AnonymousAccess @ApiOperation("添加二级目录") @PostMapping("insertSysTwoCatalog") @@ -143,12 +142,18 @@ public class CourseTagManageController { //删除资源关系表 SysResourceAndCourseExample example1 = new SysResourceAndCourseExample(); example1.createCriteria().andTwoIdEqualTo(id); + + List sysResourceAndCourses = sysResourceAndCourseMapper.selectByExample(example1); + List resourceIds = sysResourceAndCourses.stream().map(SysResourceAndCourse::getResourceId).collect(Collectors.toList()); + sysResourceAndCourseMapper.deleteByExample(example1); //删除资源 - SysResourceExample sysResourceExample = new SysResourceExample(); - sysResourceExample.createCriteria().andTwoTagEqualTo(id); - sysResourceMapper.deleteByExample(sysResourceExample); + if (!resourceIds.isEmpty()) { + SysResourceExample sysResourceExample = new SysResourceExample(); + sysResourceExample.createCriteria().andResourceIdIn(resourceIds); + sysResourceMapper.deleteByExample(sysResourceExample); + } //删除题目关系表 SysTopicAndCourseExample example = new SysTopicAndCourseExample(); @@ -159,27 +164,33 @@ public class CourseTagManageController { //删除案例题 - SysCaseQuestionExample sysCaseQuestionExample = new SysCaseQuestionExample(); - sysCaseQuestionExample.createCriteria().andCaseIdIn(topicIds); - sysCaseQuestionMapper.deleteByExample(sysCaseQuestionExample); - - //删除客观题 - SysObjectiveQuestionsExample sysObjectiveQuestionsExample =new SysObjectiveQuestionsExample(); - sysObjectiveQuestionsExample.createCriteria().andObjectiveIdIn(topicIds); - sysObjectiveQuestionsMapper.deleteByExample(sysObjectiveQuestionsExample); + 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); - sysResourceAndCourseMapper.deleteByExample(sysResourceAndCourseExample); - //删除资源 - SysResourceExample sysResourceExample = new SysResourceExample(); - sysResourceExample.createCriteria().andThreeTagEqualTo(id); - sysResourceMapper.deleteByExample(sysResourceExample); + List sysResourceAndCourses = sysResourceAndCourseMapper.selectByExample(sysResourceAndCourseExample); + List resourceIds = sysResourceAndCourses.stream().map(SysResourceAndCourse::getResourceId).collect(Collectors.toList()); + sysResourceAndCourseMapper.deleteByExample(sysResourceAndCourseExample); + //删除资源 + if (!resourceIds.isEmpty()) { + SysResourceExample sysResourceExample = new SysResourceExample(); + sysResourceExample.createCriteria().andResourceIdIn(resourceIds); + sysResourceMapper.deleteByExample(sysResourceExample); + } //删除题目关系表 SysTopicAndCourseExample sysTopicAndCourseExample = new SysTopicAndCourseExample(); @@ -191,14 +202,16 @@ public class CourseTagManageController { sysTopicAndCourseMapper.deleteByExample(sysTopicAndCourseExample); //删除案例题 - SysCaseQuestionExample sysCaseQuestionExample = new SysCaseQuestionExample(); - sysCaseQuestionExample.createCriteria().andCaseIdIn(topicIds); - sysCaseQuestionMapper.deleteByExample(sysCaseQuestionExample); - - //删除客观题 - SysObjectiveQuestionsExample sysObjectiveQuestionsExample =new SysObjectiveQuestionsExample(); - sysObjectiveQuestionsExample.createCriteria().andObjectiveIdIn(topicIds); - sysObjectiveQuestionsMapper.deleteByExample(sysObjectiveQuestionsExample); + 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(); @@ -208,7 +221,6 @@ public class CourseTagManageController { } - @AnonymousAccess @ApiOperation("一级目录重新排序") @PostMapping("setOneCatalogueRank") diff --git a/src/main/java/com/sztzjy/resource_center/controller/TopicResourceController.java b/src/main/java/com/sztzjy/resource_center/controller/TopicResourceController.java index e8acfa2..e186c1a 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/TopicResourceController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/TopicResourceController.java @@ -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 diff --git a/src/main/java/com/sztzjy/resource_center/controller/api/CourseApi.java b/src/main/java/com/sztzjy/resource_center/controller/api/CourseApi.java index 5d96869..85db12b 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/api/CourseApi.java +++ b/src/main/java/com/sztzjy/resource_center/controller/api/CourseApi.java @@ -126,13 +126,18 @@ public class CourseApi { //删除资源关系表 SysResourceAndCourseExample example1 = new SysResourceAndCourseExample(); example1.createCriteria().andTwoIdEqualTo(twoId); + + List sysResourceAndCourses = sysResourceAndCourseMapper.selectByExample(example1); + List resourceIds = sysResourceAndCourses.stream().map(SysResourceAndCourse::getResourceId).collect(Collectors.toList()); + sysResourceAndCourseMapper.deleteByExample(example1); //删除资源 - SysResourceExample sysResourceExample = new SysResourceExample(); - sysResourceExample.createCriteria().andTwoTagEqualTo(twoId); - sysResourceMapper.deleteByExample(sysResourceExample); - + if (!resourceIds.isEmpty()) { + SysResourceExample sysResourceExample = new SysResourceExample(); + sysResourceExample.createCriteria().andResourceIdIn(resourceIds); + sysResourceMapper.deleteByExample(sysResourceExample); + } //删除题目关系表 SysTopicAndCourseExample example = new SysTopicAndCourseExample(); example.createCriteria().andTwoIdEqualTo(twoId); @@ -142,14 +147,16 @@ public class CourseApi { //删除案例题 - SysCaseQuestionExample sysCaseQuestionExample = new SysCaseQuestionExample(); - sysCaseQuestionExample.createCriteria().andCaseIdIn(topicIds); - sysCaseQuestionMapper.deleteByExample(sysCaseQuestionExample); + 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); + //删除客观题 + SysObjectiveQuestionsExample sysObjectiveQuestionsExample = new SysObjectiveQuestionsExample(); + sysObjectiveQuestionsExample.createCriteria().andObjectiveIdIn(topicIds); + sysObjectiveQuestionsMapper.deleteByExample(sysObjectiveQuestionsExample); + } return true; } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/com/sztzjy/resource_center/controller/api/ResourceDataApi.java b/src/main/java/com/sztzjy/resource_center/controller/api/ResourceDataApi.java index 02cdc14..674590f 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/api/ResourceDataApi.java +++ b/src/main/java/com/sztzjy/resource_center/controller/api/ResourceDataApi.java @@ -121,7 +121,7 @@ public class ResourceDataApi { @AnonymousAccess @ApiOperation("数据集下载") @GetMapping("downloadResourceData") - private void selectResourceDataList(@RequestParam String resourceId, + private void downloadResourceData(@RequestParam String resourceId, HttpServletResponse response) { try { SysResourceData sysResourceData = sysResourceDataMapper.selectByPrimaryKey(resourceId); From 630fc6fd1c4c050766c855194ad4efead4005c97 Mon Sep 17 00:00:00 2001 From: xiaoCJ <406612557@qq.com> Date: Tue, 30 Jul 2024 18:25:12 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A1=88=E4=BE=8B?= =?UTF-8?q?=E9=A2=98=E6=A8=A1=E6=9D=BF=E4=B8=8B=E8=BD=BD=E5=92=8C=E6=89=93?= =?UTF-8?q?=E5=8C=85=E5=8E=8B=E7=BC=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/api/ResourceDataApi.java | 41 ++++++++++--------- .../mapper/SysResourceDataMapper.java | 3 ++ .../mapper/SysResourceDataMapper.xml | 8 ++++ 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/sztzjy/resource_center/controller/api/ResourceDataApi.java b/src/main/java/com/sztzjy/resource_center/controller/api/ResourceDataApi.java index 674590f..d802ce9 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/api/ResourceDataApi.java +++ b/src/main/java/com/sztzjy/resource_center/controller/api/ResourceDataApi.java @@ -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 downloadResourceData(@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 ids, HttpServletResponse response) { + this.downloadFile(ids, response); + } + + + public void downloadFile(List ids, HttpServletResponse response) { + if (ids != null && !ids.isEmpty()) { + List> filePaths = sysResourceDataMapper.getByIds(ids); + String zipName = "TZ_" + ((int) (Math.random() * 10000)) + ".zip"; + String zipPath = filePath + "/" + zipName; + CompressUtil.compress(filePaths, zipPath, false); + File pocZipFile = new File(zipPath); + CompressUtil.downloadZip(response, zipName, pocZipFile); + pocZipFile.delete(); } } + } diff --git a/src/main/java/com/sztzjy/resource_center/mapper/SysResourceDataMapper.java b/src/main/java/com/sztzjy/resource_center/mapper/SysResourceDataMapper.java index 5f8129c..6feb42c 100644 --- a/src/main/java/com/sztzjy/resource_center/mapper/SysResourceDataMapper.java +++ b/src/main/java/com/sztzjy/resource_center/mapper/SysResourceDataMapper.java @@ -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> getByIds(@Param("ids") List ids); } \ No newline at end of file diff --git a/src/main/resources/mapper/SysResourceDataMapper.xml b/src/main/resources/mapper/SysResourceDataMapper.xml index 5178c53..40164ea 100644 --- a/src/main/resources/mapper/SysResourceDataMapper.xml +++ b/src/main/resources/mapper/SysResourceDataMapper.xml @@ -223,4 +223,12 @@ source = #{source,jdbcType=VARCHAR} where resource_data_id = #{resourceDataId,jdbcType=VARCHAR} + \ No newline at end of file From 0fbd48b4492499dd2a5dd274d1a4ee8489b2945c Mon Sep 17 00:00:00 2001 From: xiaoCJ <406612557@qq.com> Date: Wed, 31 Jul 2024 13:28:18 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E7=AB=AF=E6=A1=88=E4=BE=8B=E9=A2=98=E6=AD=A5=E9=AA=A4=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CaseStepController.java | 4 +- .../controller/api/CaseApi.java | 9 ++-- .../controller/api/ResourceDataApi.java | 2 +- .../mapper/SysCaseQuestionStepMapper.java | 2 + .../resource_center/util/CompressUtil.java | 46 ++++++++++++++++++- .../mapper/SysCaseQuestionStepMapper.xml | 14 +++++- 6 files changed, 66 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/sztzjy/resource_center/controller/CaseStepController.java b/src/main/java/com/sztzjy/resource_center/controller/CaseStepController.java index f078878..b631845 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/CaseStepController.java +++ b/src/main/java/com/sztzjy/resource_center/controller/CaseStepController.java @@ -55,7 +55,7 @@ public class CaseStepController { @PostMapping("updateCase") public ResultEntity updateCase(@RequestBody SysCaseQuestionStepWithBLOBs caseQuestionStepWithBLOBs, @ApiParam("谁调的请求,传管理员/学校ID") @RequestParam String source) { - List sysTopicAndCourses = getSysTopicAndCourses(caseQuestionStepWithBLOBs.getCaseId()); +// List 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, "权限不足!"); 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 9b2c28d..989b15e 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 @@ -293,6 +293,7 @@ public class CaseApi { SysCaseQuestionExample example1 = new SysCaseQuestionExample(); example1.createCriteria().andCaseIdIn(collect).andSourceEqualTo("管理员"); + example1.setOrderByClause("create_time"); List list = caseQuestionMapper.selectByExampleWithBLOBs(example1); return list; } @@ -307,12 +308,8 @@ public class CaseApi { @PostMapping("selectCaseStepListBatchByIdListAndSort") @ApiOperation("查询案例题步骤并排序") @AnonymousAccess - public List selectCaseStepListBatchByIdListAndSort(@RequestBody List caseIdList) { - SysCaseQuestionStepExample example = new SysCaseQuestionStepExample(); - example.createCriteria().andCaseIdIn(caseIdList); - example.setOrderByClause("sort"); - List sysCaseQuestionStepWithBLOBs = caseQuestionStepMapper.selectByExampleWithBLOBs(example); - return sysCaseQuestionStepWithBLOBs; + public List selectCaseStepListBatchByIdListAndSort(@RequestParam String threeId) { + return caseQuestionStepMapper.selectCaseStepListBatchByIdListAndSort(threeId); } diff --git a/src/main/java/com/sztzjy/resource_center/controller/api/ResourceDataApi.java b/src/main/java/com/sztzjy/resource_center/controller/api/ResourceDataApi.java index d802ce9..9487714 100644 --- a/src/main/java/com/sztzjy/resource_center/controller/api/ResourceDataApi.java +++ b/src/main/java/com/sztzjy/resource_center/controller/api/ResourceDataApi.java @@ -126,7 +126,7 @@ public class ResourceDataApi { List> 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(); diff --git a/src/main/java/com/sztzjy/resource_center/mapper/SysCaseQuestionStepMapper.java b/src/main/java/com/sztzjy/resource_center/mapper/SysCaseQuestionStepMapper.java index 007d1ec..69b44c5 100644 --- a/src/main/java/com/sztzjy/resource_center/mapper/SysCaseQuestionStepMapper.java +++ b/src/main/java/com/sztzjy/resource_center/mapper/SysCaseQuestionStepMapper.java @@ -45,4 +45,6 @@ public interface SysCaseQuestionStepMapper { List selectTrainingByIds(@Param("list") List caseStepIdList); List getCaseStepByIds(@Param("ids") List ids); + + List selectCaseStepListBatchByIdListAndSort(@Param("threeId") String threeId); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/resource_center/util/CompressUtil.java b/src/main/java/com/sztzjy/resource_center/util/CompressUtil.java index 40ba6f6..8748cf9 100644 --- a/src/main/java/com/sztzjy/resource_center/util/CompressUtil.java +++ b/src/main/java/com/sztzjy/resource_center/util/CompressUtil.java @@ -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> 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) { diff --git a/src/main/resources/mapper/SysCaseQuestionStepMapper.xml b/src/main/resources/mapper/SysCaseQuestionStepMapper.xml index 0a95801..809df3a 100644 --- a/src/main/resources/mapper/SysCaseQuestionStepMapper.xml +++ b/src/main/resources/mapper/SysCaseQuestionStepMapper.xml @@ -421,7 +421,8 @@ + + \ No newline at end of file