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/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/CourseTagManageController.java b/src/main/java/com/sztzjy/resource_center/controller/CourseTagManageController.java index 49fb103..2a65854 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,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 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 +121,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,59 +139,87 @@ public class CourseTagManageController { try { if (type == 2) { sysTwoCatalogMapper.deleteByPrimaryKey(id); - //删除资源 + //删除资源关系表 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); - //删除题目 + //删除资源 + if (!resourceIds.isEmpty()) { + SysResourceExample sysResourceExample = new SysResourceExample(); + sysResourceExample.createCriteria().andResourceIdIn(resourceIds); + 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); + + + //删除案例题 + 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 sysResourceAndCourses = sysResourceAndCourseMapper.selectByExample(sysResourceAndCourseExample); + List 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 topicAndCourseList = sysTopicAndCourseMapper.selectByExample(sysTopicAndCourseExample); + List 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 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("一级目录重新排序") 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/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/CourseApi.java b/src/main/java/com/sztzjy/resource_center/controller/api/CourseApi.java index edb3483..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 @@ -123,15 +123,40 @@ public class CourseApi { return false; } twoCatalogMapper.deleteByPrimaryKey(twoId); - //删除资源 + //删除资源关系表 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); - //删除题目 + //删除资源 + if (!resourceIds.isEmpty()) { + SysResourceExample sysResourceExample = new SysResourceExample(); + sysResourceExample.createCriteria().andResourceIdIn(resourceIds); + 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); + + + //删除案例题 + 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(); 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..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 @@ -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 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.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/controller/new_module/admin/AdminComponentCodeController.java b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminComponentCodeController.java index 3aff635..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,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 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 dataFile) { @@ -121,23 +123,20 @@ public class AdminComponentCodeController { } + @PostMapping("updateAdminData") @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(@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 = 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(); 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; +} 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/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/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 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