diff --git a/pom.xml b/pom.xml
index f115ca6..16ab815 100644
--- a/pom.xml
+++ b/pom.xml
@@ -218,6 +218,12 @@
ip2region
2.6.5
+
+
+ org.apache.httpcomponents
+ httpmime
+ 4.5.14
+
diff --git a/src/main/java/com/sztzjy/resource_center/config/Constant.java b/src/main/java/com/sztzjy/resource_center/config/Constant.java
index ab81e52..693bd17 100644
--- a/src/main/java/com/sztzjy/resource_center/config/Constant.java
+++ b/src/main/java/com/sztzjy/resource_center/config/Constant.java
@@ -33,4 +33,7 @@ public class Constant {
// public static final String THEORY = "理论考试模块";
// public static final String RESOURCE = "资源中心模块";
+ public static final String JUPYTERHUB_API_URL = "http://120.78.220.29:8000/hub/api";
+ public static final String ADMIN_TOKEN = "170bed30b34242cfb3fda3171e1a111d"; // 替换为你的JupyterHub管理员API令牌
+
}
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..225c595 100644
--- a/src/main/java/com/sztzjy/resource_center/controller/CaseStepController.java
+++ b/src/main/java/com/sztzjy/resource_center/controller/CaseStepController.java
@@ -55,19 +55,19 @@ 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, "该案例题正在被使用!");
// }
// else {
- //todo 管理员任意修改,老师只能改自己的
- SysCaseQuestion sysCaseQuestion = sysCaseQuestionMapper.selectByPrimaryKey(caseQuestionStepWithBLOBs.getCaseId());
- if ("管理员".equals(source) || source.equals(sysCaseQuestion.getSource())) {
- caseQuestionStepMapper.updateByPrimaryKey(caseQuestionStepWithBLOBs);
- return new ResultEntity<>(HttpStatus.OK, "编辑成功!");
- } else {
- return new ResultEntity<>(HttpStatus.BAD_REQUEST, "权限不足!");
- }
+ //todo 管理员任意修改,老师只能改自己的
+ SysCaseQuestion sysCaseQuestion = sysCaseQuestionMapper.selectByPrimaryKey(caseQuestionStepWithBLOBs.getCaseId());
+ if ("管理员".equals(source) || source.equals(sysCaseQuestion.getSource())) {
+ caseQuestionStepMapper.updateByPrimaryKeyWithBLOBs(caseQuestionStepWithBLOBs);
+ return new ResultEntity<>(HttpStatus.OK, "编辑成功!");
+ } else {
+ return new ResultEntity<>(HttpStatus.BAD_REQUEST, "权限不足!");
+ }
// }
}
@@ -77,19 +77,17 @@ public class CaseStepController {
@PostMapping("deleteCase")
public ResultEntity deleteCase(@RequestBody SysCaseQuestionStepWithBLOBs sysCaseQuestionStep,
@ApiParam("哪个用的掉的请求,传管理员/学校ID") @RequestParam String source) {
- List sysTopicAndCourses = getSysTopicAndCourses(sysCaseQuestionStep.getCaseId());
- if (!sysTopicAndCourses.isEmpty()) {
- return new ResultEntity<>(HttpStatus.BAD_REQUEST, "无法删除!该案例题正在被使用!");
- } else {
- //todo 管理员任意删除 老师只能删除自己上传的
- SysCaseQuestion sysCaseQuestion = sysCaseQuestionMapper.selectByPrimaryKey(sysCaseQuestionStep.getCaseId());
- if ("管理员".equals(source) || source.equals(sysCaseQuestion.getSource())) {
- caseQuestionStepMapper.deleteByPrimaryKey(sysCaseQuestionStep.getCaseStepId());
- return new ResultEntity<>(HttpStatus.OK, "删除成功!");
- } else {
- return new ResultEntity<>(HttpStatus.BAD_REQUEST, "权限不足!");
- }
+// List sysTopicAndCourses = getSysTopicAndCourses(sysCaseQuestionStep.getCaseId());
+// if (!sysTopicAndCourses.isEmpty()) {
+// return new ResultEntity<>(HttpStatus.BAD_REQUEST, "无法删除!该案例题正在被使用!"); todo 暂时把判断去掉
+// }
+ //todo 管理员任意删除 老师只能删除自己上传的
+ SysCaseQuestion sysCaseQuestion = sysCaseQuestionMapper.selectByPrimaryKey(sysCaseQuestionStep.getCaseId());
+ if ("管理员".equals(source) || source.equals(sysCaseQuestion.getSource())) {
+ caseQuestionStepMapper.deleteByPrimaryKey(sysCaseQuestionStep.getCaseStepId());
+ return new ResultEntity<>(HttpStatus.OK, "删除成功!");
}
+ return new ResultEntity<>(HttpStatus.BAD_REQUEST, "权限不足!");
}
private List getSysTopicAndCourses(String caseId) {
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