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 1/8] =?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<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 +122,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,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<SysTopicAndCourse> topicAndCourseList = sysTopicAndCourseMapper.selectByExample(example);
+                List<String> 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<SysTopicAndCourse> topicAndCourseList = sysTopicAndCourseMapper.selectByExample(sysTopicAndCourseExample);
+                List<String> 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<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
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<SysTopicAndCourse> topicAndCourseList = sysTopicAndCourseMapper.selectByExample(example);
+            List<String> 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 2/8] =?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<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());
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<SysResourceAndCourse> sysResourceAndCourses = sysResourceAndCourseMapper.selectByExample(example1);
+                List<String> 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<SysResourceAndCourse> sysResourceAndCourses = sysResourceAndCourseMapper.selectByExample(sysResourceAndCourseExample);
+                List<String> 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<SysResourceAndCourse> sysResourceAndCourses = sysResourceAndCourseMapper.selectByExample(example1);
+            List<String> 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 3/8] =?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<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.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<Map<String, String>> getByIds(@Param("ids") List<String> 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}
   </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>
\ 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 4/8] =?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<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, "权限不足!");
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<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);
     }
 
 
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<Map<String, String>> filePaths = sysResourceDataMapper.getByIds(ids);
             String zipName = "TZ_" + ((int) (Math.random() * 10000)) + ".zip";
             String zipPath = filePath + "/" + zipName;
-            CompressUtil.compress(filePaths, zipPath, false);
+            CompressUtil.compress11(filePaths, zipPath, false);
             File pocZipFile = new File(zipPath);
             CompressUtil.downloadZip(response, zipName, pocZipFile);
             pocZipFile.delete();
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<TrainingDto> selectTrainingByIds(@Param("list") List<String> caseStepIdList);
 
     List<SysCaseQuestionStepWithBLOBs> getCaseStepByIds(@Param("ids") List<String> ids);
+
+    List<SysCaseQuestionStepWithBLOBs> 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<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) {
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 @@
     </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>
\ No newline at end of file

From 22e00ec994b81a900ff5a1a4e3d21d5c4a5505f8 Mon Sep 17 00:00:00 2001
From: whb <17803890193@163.com>
Date: Thu, 1 Aug 2024 13:36:19 +0800
Subject: [PATCH 5/8] =?UTF-8?q?=E6=96=87=E4=BB=B6html=E4=B8=8A=E4=BC=A0?=
 =?UTF-8?q?=E5=88=B0=E6=8C=87=E5=AE=9A=E4=BD=8D=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../new_module/stu/StuJupyterController.java  | 54 ++++---------------
 .../resource_center/util/file/IFileUtil.java  |  2 +-
 .../util/file/LocalFileUtil.java              | 25 +++++----
 3 files changed, 26 insertions(+), 55 deletions(-)

diff --git a/src/main/java/com/sztzjy/resource_center/controller/new_module/stu/StuJupyterController.java b/src/main/java/com/sztzjy/resource_center/controller/new_module/stu/StuJupyterController.java
index 44aa672..56758ca 100644
--- a/src/main/java/com/sztzjy/resource_center/controller/new_module/stu/StuJupyterController.java
+++ b/src/main/java/com/sztzjy/resource_center/controller/new_module/stu/StuJupyterController.java
@@ -381,67 +381,33 @@ public class StuJupyterController {
 
 
     //文件查询 ,判断有无文件
-    @ApiOperation("文件上传")
-    @PostMapping("/importIpynb")
+    @ApiOperation("Html文件上传")
+    @PostMapping("/importHtml")
     @AnonymousAccess
-    public ResultEntity importIpynb(@ApiParam("案例名") String caseName,@RequestPart MultipartFile file ) {
-
-
-
+    public ResultEntity importHtml(@ApiParam("案例名") String caseName,@RequestPart MultipartFile file) {
 
         String originalFilename = file.getOriginalFilename();
         int i = originalFilename.lastIndexOf(".");
         String substring = originalFilename.substring(i);
-        if ("html".equals(substring)|| "md".equals(substring))
-        {
-            //            上传到不同文件夹
-            if (!(caseName+".md").equals(file.getOriginalFilename()))
-            {
-                return new ResultEntity<>(HttpStatus.ACCEPTED,"请上传和案例名相同的文件!");
-            }
-            String upload =  localFileUtil.uploadByRelativePath(file,"/usr/local/tianzeProject/jupyter/tch");
+        if ("html".equals(substring)) {
 
-            if (upload!=null)
-            {
-                return new ResultEntity<>(HttpStatus.OK,"上传成功!");
-            }else {
-                return new ResultEntity<>(HttpStatus.BAD_REQUEST,"上传失败!");
-            }
+            String htmlPath = "/usr/local/tianzeProject/jupyter/md/html";
 
-        }
-        if ("ipynb".equals(substring))
-        {
-            //            上传到不同文件夹
-            if (!(caseName+".ipynb").equals(file.getOriginalFilename()))
-            {
-                return new ResultEntity<>(HttpStatus.ACCEPTED,"请上传和案例名相同的文件!");
-            }
-            String upload =  localFileUtil.uploadByRelativePath(file,"/usr/local/tianzeProject/jupyter/tch");
+            String upload = localFileUtil.uploadByRelativePath(file, htmlPath,caseName);
 
-            if (upload!=null)
-            {
-                return new ResultEntity<>(HttpStatus.OK,"上传成功!");
-            }else {
-                return new ResultEntity<>(HttpStatus.BAD_REQUEST,"上传失败!");
+            if (upload != null) {
+                return new ResultEntity<>(HttpStatus.OK, "上传成功!");
+            } else {
+                return new ResultEntity<>(HttpStatus.BAD_REQUEST, "上传失败!");
             }
 
-
         }
 
-
-
-
-
-        //转换出md文件
-
-
         return new ResultEntity<>("上传成功!");
 
-
     }
 
 
-
         // 导入ipynb文件
 
 
diff --git a/src/main/java/com/sztzjy/resource_center/util/file/IFileUtil.java b/src/main/java/com/sztzjy/resource_center/util/file/IFileUtil.java
index 586fd27..266130f 100644
--- a/src/main/java/com/sztzjy/resource_center/util/file/IFileUtil.java
+++ b/src/main/java/com/sztzjy/resource_center/util/file/IFileUtil.java
@@ -84,6 +84,6 @@ public interface IFileUtil {
      */
     String getDiskRelativePath(String fileName, String suffix);
 
-    String uploadByRelativePath(MultipartFile file, String relativePath);
+    String uploadByRelativePath(MultipartFile file, String relativePath,String caseName);
 
 }
diff --git a/src/main/java/com/sztzjy/resource_center/util/file/LocalFileUtil.java b/src/main/java/com/sztzjy/resource_center/util/file/LocalFileUtil.java
index 45ada64..71320f6 100644
--- a/src/main/java/com/sztzjy/resource_center/util/file/LocalFileUtil.java
+++ b/src/main/java/com/sztzjy/resource_center/util/file/LocalFileUtil.java
@@ -176,24 +176,29 @@ public class LocalFileUtil implements IFileUtil{
     }
 
 
-    public String uploadByRelativePath(MultipartFile file, String relativePath) {
+    public String uploadByRelativePath(MultipartFile file, String relativePath,String caseName) {
         Assert.isTrue(!file.isEmpty(), "文件不存在");
-        String originalFilename = file.getOriginalFilename();
 
         try {
-            String filePath;
+            // 创建目录如果不存在
+            File directory = new File(relativePath);
+            if (!directory.exists()) {
+                directory.mkdirs();
+            }
+            // 设置目标文件路径
+            String result =  caseName == null ? file.getOriginalFilename() : caseName;
 
-                relativePath = relativePath.endsWith("/") ? relativePath : relativePath + "/";
-                filePath = relativePath + originalFilename;
+            int i = file.getOriginalFilename().lastIndexOf(".");
+            String substring = file.getOriginalFilename().substring(i);
+
+            File destFile = new File(relativePath + File.separator + result+substring);
 
-            File destFile = new File(getFullPath(filePath));
-            destFile.getParentFile().mkdirs();
             file.transferTo(destFile);
-            return filePath;
+            return "上传成功!";
         } catch (FileNotFoundException e) {
-            throw new IllegalArgumentException("上传文件失败,FileNotFound错误");
+            throw new IllegalArgumentException("上传文件失败,FileNotFound错误", e);
         } catch (IOException e) {
-            throw new IllegalArgumentException("上传文件失败,IO错误");
+            throw new IllegalArgumentException("上传文件失败,IO错误", e);
         }
     }
 }

From 3363ef88c8ba28d02f95ae70855d2c3c1e154f85 Mon Sep 17 00:00:00 2001
From: xiaoCJ <406612557@qq.com>
Date: Thu, 1 Aug 2024 16:45:24 +0800
Subject: [PATCH 6/8] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=88=A0=E9=99=A4?=
 =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86?=
 =?UTF-8?q?=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../controller/CaseStepController.java        |  38 +-
 .../new_module/admin/AdminCaseController.java |  37 +-
 .../new_module/admin/AdminDataController.java |  37 +-
 .../entity/admin/AdminData.java               |   1 -
 .../entity/admin/AdminDataReturnDto.java      |   6 +
 .../entity/admin/AdminDataWithBLOBs.java      |  23 +
 .../mapper/admin/AdminDataMapper.java         |   5 +-
 src/main/resources/application.yml            |   2 +-
 src/main/resources/generatorConfig.xml        |   4 +-
 src/main/resources/mapper/AdminDataMapper.xml | 768 +++++++++---------
 10 files changed, 507 insertions(+), 414 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 b631845..225c595 100644
--- a/src/main/java/com/sztzjy/resource_center/controller/CaseStepController.java
+++ b/src/main/java/com/sztzjy/resource_center/controller/CaseStepController.java
@@ -60,14 +60,14 @@ public class CaseStepController {
 //            return new ResultEntity<>(HttpStatus.BAD_REQUEST, "该案例题正在被使用!");
 //        }
 //        else {
-            //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, "权限不足!");
-            }
+        //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<HttpStatus> deleteCase(@RequestBody SysCaseQuestionStepWithBLOBs sysCaseQuestionStep,
                                                @ApiParam("哪个用的掉的请求,传管理员/学校ID") @RequestParam String source) {
-        List<SysTopicAndCourse> 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<SysTopicAndCourse> 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<SysTopicAndCourse> getSysTopicAndCourses(String caseId) {
diff --git a/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminCaseController.java b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminCaseController.java
index 56a9590..9800f9e 100644
--- a/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminCaseController.java
+++ b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminCaseController.java
@@ -8,6 +8,7 @@ import com.nimbusds.jose.shaded.gson.JsonSyntaxException;
 import com.sztzjy.resource_center.annotation.AnonymousAccess;
 import com.sztzjy.resource_center.entity.admin.*;
 import com.sztzjy.resource_center.mapper.admin.AdminCaseMapper;
+import com.sztzjy.resource_center.mapper.admin.AdminCollectCaseMapper;
 import com.sztzjy.resource_center.mapper.admin.AdminDataLabelMapper;
 import com.sztzjy.resource_center.mapper.admin.AdminFileMapper;
 import com.sztzjy.resource_center.util.PageUtil;
@@ -47,6 +48,8 @@ public class AdminCaseController {
     @Autowired
     private AdminFileMapper adminFileMapper;
     @Autowired
+    private AdminCollectCaseMapper adminCollectCaseMapper;
+    @Autowired
     private IFileUtil fileUtil;
     @Value("${file.path}")
     private String filePath;
@@ -325,25 +328,31 @@ public class AdminCaseController {
     }
 
 
-    @PostMapping("deleteCase")
-    @ApiOperation("删除案例题/管理员使用")
-    private ResultEntity<String> deleteCase(@RequestParam String caseId) {
+    @PostMapping("deleteAdminCase")
+    @ApiOperation("案例集锦/删除")
+    @AnonymousAccess
+    private ResultEntity<HttpStatus> deleteAdminData(@RequestParam String caseId) {
         try {
-            //删除案例绑定文件
-            AdminFileExample example = new AdminFileExample();
-            example.createCriteria().andDataCaseIdEqualTo(caseId);
-            adminFileMapper.deleteByExample(example);
-
-            //删除案例绑定标签
-            AdminDataLabelExample example1 = new AdminDataLabelExample();
-            example1.createCriteria().andDataCaseIdEqualTo(caseId);
-            adminDataLabelMapper.deleteByExample(example1);
+            //删除数据
             adminCaseMapper.deleteByPrimaryKey(caseId);
+
+            //删除标签绑定表
+            AdminDataLabelExample adminDataLabelExample = new AdminDataLabelExample();
+            adminDataLabelExample.createCriteria().andDataCaseIdEqualTo(caseId);
+            adminDataLabelMapper.deleteByExample(adminDataLabelExample);
+
+            AdminFileExample adminFileExample = new AdminFileExample();
+            adminFileExample.createCriteria().andDataCaseIdEqualTo(caseId);
+            adminFileMapper.deleteByExample(adminFileExample);
+
+            AdminCollectCaseExample adminCollectCaseExample = new AdminCollectCaseExample();
+            adminCollectCaseExample.createCriteria().andCaseIdEqualTo(caseId);
+            adminCollectCaseMapper.deleteByExample(adminCollectCaseExample);
         } catch (Exception e) {
             e.printStackTrace();
-            return new ResultEntity<>(HttpStatus.INTERNAL_SERVER_ERROR, "上传失败,请联系管理员!");
+            return new ResultEntity<>(HttpStatus.BAD_REQUEST, "删除失败,请联系管理员!");
         }
-        return new ResultEntity<>(HttpStatus.OK, "删除成功!");
+        return new ResultEntity<HttpStatus>(HttpStatus.OK, "删除成功!");
     }
 
 }
diff --git a/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminDataController.java b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminDataController.java
index d5884ca..e106fdb 100644
--- a/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminDataController.java
+++ b/src/main/java/com/sztzjy/resource_center/controller/new_module/admin/AdminDataController.java
@@ -1,12 +1,12 @@
 package com.sztzjy.resource_center.controller.new_module.admin;
 
 import cn.hutool.core.util.IdUtil;
-import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.nimbusds.jose.shaded.gson.Gson;
 import com.nimbusds.jose.shaded.gson.JsonSyntaxException;
 import com.sztzjy.resource_center.annotation.AnonymousAccess;
 import com.sztzjy.resource_center.entity.admin.*;
+import com.sztzjy.resource_center.mapper.admin.AdminCollectDataMapper;
 import com.sztzjy.resource_center.mapper.admin.AdminDataLabelMapper;
 import com.sztzjy.resource_center.mapper.admin.AdminDataMapper;
 import com.sztzjy.resource_center.mapper.admin.AdminFileMapper;
@@ -46,6 +46,9 @@ public class AdminDataController {
     private AdminFileMapper adminFileMapper;
     @Autowired
     private AdminDataMapper adminDataMapper;
+    @Autowired
+    private AdminCollectDataMapper adminCollectDataMapper;
+
 
     @PostMapping("/add")
     @ApiOperation("新增")
@@ -90,6 +93,8 @@ public class AdminDataController {
         adminDataWithBLOBs.setName(adminDataDto.getName());
         adminDataWithBLOBs.setDataScenarios(adminDataDto.getDataScenarios());
         adminDataWithBLOBs.setFieldDescription(adminDataDto.getFieldDescription());
+        adminDataWithBLOBs.setDataScenariosOriginal(adminDataDto.getDataScenariosOriginal());
+        adminDataWithBLOBs.setFieldDescriptionOriginal(adminDataDto.getFieldDescriptionOriginal());
         adminDataWithBLOBs.setStatus(0); //默认下架,发布后上架
         adminDataWithBLOBs.setCreateTime(new Date());
         if (pictureFile != null) {
@@ -189,7 +194,9 @@ public class AdminDataController {
             adminDataWithBLOBs.setDataId(adminDataDto.getDataId());
             adminDataWithBLOBs.setName(adminDataDto.getName());
             adminDataWithBLOBs.setDataScenarios(adminDataDto.getDataScenarios());
+            adminDataWithBLOBs.setDataScenariosOriginal(adminDataDto.getDataScenariosOriginal());
             adminDataWithBLOBs.setFieldDescription(adminDataDto.getFieldDescription());
+            adminDataWithBLOBs.setFieldDescriptionOriginal(adminDataDto.getFieldDescriptionOriginal());
             adminDataWithBLOBs.setStatus(adminDataDto.getStatus()); //默认下架,发布后上架
             adminDataWithBLOBs.setCreateTime(adminDataDto.getCreateTime());
             // 文件上传并行处理
@@ -269,4 +276,32 @@ public class AdminDataController {
         }
         return new ResultEntity<HttpStatus>(HttpStatus.OK, "删除成功!");
     }
+
+    @PostMapping("deleteAdminData")
+    @ApiOperation("数据仓库/删除")
+    @AnonymousAccess
+    private ResultEntity<HttpStatus> deleteAdminData(@RequestParam String dataId) {
+        try {
+            //删除数据
+            adminDataMapper.deleteByPrimaryKey(dataId);
+
+            //删除标签绑定表
+            AdminDataLabelExample adminDataLabelExample = new AdminDataLabelExample();
+            adminDataLabelExample.createCriteria().andDataCaseIdEqualTo(dataId);
+            adminDataLabelMapper.deleteByExample(adminDataLabelExample);
+
+            AdminFileExample adminFileExample = new AdminFileExample();
+            adminFileExample.createCriteria().andDataCaseIdEqualTo(dataId);
+            adminFileMapper.deleteByExample(adminFileExample);
+
+            AdminCollectDataExample adminCollectDataExample = new AdminCollectDataExample();
+            adminCollectDataExample.createCriteria().andDataIdEqualTo(dataId);
+            adminCollectDataMapper.deleteByExample(adminCollectDataExample);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return new ResultEntity<>(HttpStatus.BAD_REQUEST, "删除失败,请联系管理员!");
+        }
+        return new ResultEntity<HttpStatus>(HttpStatus.OK, "删除成功!");
+    }
+
 }
diff --git a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminData.java b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminData.java
index a47a153..99b8363 100644
--- a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminData.java
+++ b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminData.java
@@ -2,7 +2,6 @@ package com.sztzjy.resource_center.entity.admin;
 
 import java.util.Date;
 
-import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 /**
  *
diff --git a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataReturnDto.java b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataReturnDto.java
index 1d08bf0..98dd734 100644
--- a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataReturnDto.java
+++ b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataReturnDto.java
@@ -31,12 +31,18 @@ public class AdminDataReturnDto {
     @ApiModelProperty("数据应用场景")
     private String dataScenarios;
 
+    @ApiModelProperty("数据应用场景原始数据")
+    private String dataScenariosOriginal;
+
     @ApiModelProperty("收藏ID")
     private String collectId;
 
     @ApiModelProperty("字段描述")
     private String fieldDescription;
 
+    @ApiModelProperty("字段描述原始数据")
+    private String fieldDescriptionOriginal;
+
     @ApiModelProperty("创建时间")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
     private Date createTime;
diff --git a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataWithBLOBs.java b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataWithBLOBs.java
index 0371aad..2961e2e 100644
--- a/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataWithBLOBs.java
+++ b/src/main/java/com/sztzjy/resource_center/entity/admin/AdminDataWithBLOBs.java
@@ -1,5 +1,6 @@
 package com.sztzjy.resource_center.entity.admin;
 
+import com.sztzjy.resource_center.entity.admin.AdminData;
 import io.swagger.annotations.ApiModelProperty;
 /**
  *
@@ -10,9 +11,15 @@ public class AdminDataWithBLOBs extends AdminData {
     @ApiModelProperty("数据应用场景")
     private String dataScenarios;
 
+    @ApiModelProperty("数据应用场景原始数据")
+    private String dataScenariosOriginal;
+
     @ApiModelProperty("字段描述")
     private String fieldDescription;
 
+    @ApiModelProperty("字段描述原始数据")
+    private String fieldDescriptionOriginal;
+
     public String getDataScenarios() {
         return dataScenarios;
     }
@@ -21,6 +28,14 @@ public class AdminDataWithBLOBs extends AdminData {
         this.dataScenarios = dataScenarios == null ? null : dataScenarios.trim();
     }
 
+    public String getDataScenariosOriginal() {
+        return dataScenariosOriginal;
+    }
+
+    public void setDataScenariosOriginal(String dataScenariosOriginal) {
+        this.dataScenariosOriginal = dataScenariosOriginal == null ? null : dataScenariosOriginal.trim();
+    }
+
     public String getFieldDescription() {
         return fieldDescription;
     }
@@ -28,4 +43,12 @@ public class AdminDataWithBLOBs extends AdminData {
     public void setFieldDescription(String fieldDescription) {
         this.fieldDescription = fieldDescription == null ? null : fieldDescription.trim();
     }
+
+    public String getFieldDescriptionOriginal() {
+        return fieldDescriptionOriginal;
+    }
+
+    public void setFieldDescriptionOriginal(String fieldDescriptionOriginal) {
+        this.fieldDescriptionOriginal = fieldDescriptionOriginal == null ? null : fieldDescriptionOriginal.trim();
+    }
 }
\ No newline at end of file
diff --git a/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminDataMapper.java b/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminDataMapper.java
index 19f6732..115a62d 100644
--- a/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminDataMapper.java
+++ b/src/main/java/com/sztzjy/resource_center/mapper/admin/AdminDataMapper.java
@@ -4,11 +4,10 @@ import com.sztzjy.resource_center.entity.admin.AdminData;
 import com.sztzjy.resource_center.entity.admin.AdminDataExample;
 import com.sztzjy.resource_center.entity.admin.AdminDataReturnDto;
 import com.sztzjy.resource_center.entity.admin.AdminDataWithBLOBs;
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Param;
-
 import java.util.List;
 
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 @Mapper
 public interface AdminDataMapper {
     long countByExample(AdminDataExample example);
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index efaf92f..a770766 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -13,7 +13,7 @@ spring:
   application:
     name: trading_system
   profiles:
-    active: dev
+    active: pro
   mvc:
     pathmatch:
       matching-strategy: ant_path_matcher
diff --git a/src/main/resources/generatorConfig.xml b/src/main/resources/generatorConfig.xml
index 5bd6340..718d157 100644
--- a/src/main/resources/generatorConfig.xml
+++ b/src/main/resources/generatorConfig.xml
@@ -46,14 +46,14 @@
 <!--        <table tableName="sys_model_question" domainObjectName="SysModelQuestion" />-->
 <!--        <table tableName="sys_objective_questions" domainObjectName="SysObjectiveQuestions" />-->
 <!--        <table tableName="sys_one_catalog" domainObjectName="SysOneCatalog" />-->
-        <table tableName="sys_resource" domainObjectName="SysResource" />
+<!--        <table tableName="sys_resource" domainObjectName="SysResource" />-->
 <!--        <table tableName="sys_resource_and_course" domainObjectName="SysResourceAndCourse" />-->
 <!--        <table tableName="sys_resource_data" domainObjectName="SysResourceData" />-->
 <!--        <table tableName="sys_school" domainObjectName="SysSchool" />-->
 <!--        <table tableName="sys_three_catalog" domainObjectName="SysThreeCatalog" />-->
 <!--        <table tableName="sys_topic_and_course" domainObjectName="SysTopicAndCourse" />-->
 <!--        <table tableName="admin_case" domainObjectName="AdminCase" />-->
-<!--        <table tableName="admin_data" domainObjectName="AdminData" />-->
+        <table tableName="admin_data" domainObjectName="AdminData" />
 <!--        <table tableName="admin_collect_case" domainObjectName="AdminCollectCase" />-->
 <!--        <table tableName="admin_collect_data" domainObjectName="AdminCollectData" />-->
 <!--        <table tableName="admin_data_label" domainObjectName="AdminDataLabel" />-->
diff --git a/src/main/resources/mapper/AdminDataMapper.xml b/src/main/resources/mapper/AdminDataMapper.xml
index 32fbb32..f70772c 100644
--- a/src/main/resources/mapper/AdminDataMapper.xml
+++ b/src/main/resources/mapper/AdminDataMapper.xml
@@ -1,388 +1,412 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.sztzjy.resource_center.mapper.admin.AdminDataMapper">
-    <resultMap id="BaseResultMap" type="com.sztzjy.resource_center.entity.admin.AdminData">
-        <id column="data_id" jdbcType="VARCHAR" property="dataId"/>
-        <result column="name" jdbcType="VARCHAR" property="name"/>
-        <result column="picture_url" jdbcType="VARCHAR" property="pictureUrl"/>
-        <result column="status" jdbcType="INTEGER" property="status"/>
-        <result column="source" jdbcType="VARCHAR" property="source"/>
-        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
-    </resultMap>
-    <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs"
-               type="com.sztzjy.resource_center.entity.admin.AdminDataWithBLOBs">
-        <result column="data_scenarios" jdbcType="LONGVARCHAR" property="dataScenarios"/>
-        <result column="field_description" jdbcType="LONGVARCHAR" property="fieldDescription"/>
-    </resultMap>
-    <sql id="Example_Where_Clause">
-        <where>
-            <foreach collection="oredCriteria" item="criteria" separator="or">
-                <if test="criteria.valid">
-                    <trim prefix="(" prefixOverrides="and" suffix=")">
-                        <foreach collection="criteria.criteria" item="criterion">
-                            <choose>
-                                <when test="criterion.noValue">
-                                    and ${criterion.condition}
-                                </when>
-                                <when test="criterion.singleValue">
-                                    and ${criterion.condition} #{criterion.value}
-                                </when>
-                                <when test="criterion.betweenValue">
-                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
-                                </when>
-                                <when test="criterion.listValue">
-                                    and ${criterion.condition}
-                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
-                                             separator=",">
-                                        #{listItem}
-                                    </foreach>
-                                </when>
-                            </choose>
-                        </foreach>
-                    </trim>
-                </if>
+  <resultMap id="BaseResultMap" type="com.sztzjy.resource_center.entity.admin.AdminData">
+    <id column="data_id" jdbcType="VARCHAR" property="dataId" />
+    <result column="name" jdbcType="VARCHAR" property="name" />
+    <result column="picture_url" jdbcType="VARCHAR" property="pictureUrl" />
+    <result column="status" jdbcType="INTEGER" property="status" />
+    <result column="source" jdbcType="VARCHAR" property="source" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+  </resultMap>
+  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.sztzjy.resource_center.entity.admin.AdminDataWithBLOBs">
+    <result column="data_scenarios" jdbcType="LONGVARCHAR" property="dataScenarios" />
+    <result column="data_scenarios_original" jdbcType="LONGVARCHAR" property="dataScenariosOriginal" />
+    <result column="field_description" jdbcType="LONGVARCHAR" property="fieldDescription" />
+    <result column="field_description_original" jdbcType="LONGVARCHAR" property="fieldDescriptionOriginal" />
+  </resultMap>
+  <sql id="Example_Where_Clause">
+    <where>
+      <foreach collection="oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
             </foreach>
-        </where>
-    </sql>
-    <sql id="Update_By_Example_Where_Clause">
-        <where>
-            <foreach collection="example.oredCriteria" item="criteria" separator="or">
-                <if test="criteria.valid">
-                    <trim prefix="(" prefixOverrides="and" suffix=")">
-                        <foreach collection="criteria.criteria" item="criterion">
-                            <choose>
-                                <when test="criterion.noValue">
-                                    and ${criterion.condition}
-                                </when>
-                                <when test="criterion.singleValue">
-                                    and ${criterion.condition} #{criterion.value}
-                                </when>
-                                <when test="criterion.betweenValue">
-                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
-                                </when>
-                                <when test="criterion.listValue">
-                                    and ${criterion.condition}
-                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
-                                             separator=",">
-                                        #{listItem}
-                                    </foreach>
-                                </when>
-                            </choose>
-                        </foreach>
-                    </trim>
-                </if>
-            </foreach>
-        </where>
-    </sql>
-    <sql id="Base_Column_List">
-        data_id
-        , name, picture_url, status, source, create_time
-    </sql>
-    <sql id="Blob_Column_List">
-        data_scenarios
-        , field_description
-    </sql>
-    <select id="selectByExampleWithBLOBs" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataExample"
-            resultMap="ResultMapWithBLOBs">
-        select
-        <if test="distinct">
-            distinct
-        </if>
-        <include refid="Base_Column_List"/>
-        ,
-        <include refid="Blob_Column_List"/>
-        from admin_data
-        <if test="_parameter != null">
-            <include refid="Example_Where_Clause"/>
-        </if>
-        <if test="orderByClause != null">
-            order by ${orderByClause}
-        </if>
-    </select>
-    <select id="selectByExample" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataExample"
-            resultMap="BaseResultMap">
-        select
-        <if test="distinct">
-            distinct
-        </if>
-        <include refid="Base_Column_List"/>
-        from admin_data
-        <if test="_parameter != null">
-            <include refid="Example_Where_Clause"/>
+          </trim>
         </if>
-        <if test="orderByClause != null">
-            order by ${orderByClause}
-        </if>
-    </select>
-    <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
-        select
-        <include refid="Base_Column_List"/>
-        ,
-        <include refid="Blob_Column_List"/>
-        from admin_data
-        where data_id = #{dataId,jdbcType=VARCHAR}
-    </select>
-    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
-        delete
-        from admin_data
-        where data_id = #{dataId,jdbcType=VARCHAR}
-    </delete>
-    <delete id="deleteByExample" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataExample">
-        delete from admin_data
-        <if test="_parameter != null">
-            <include refid="Example_Where_Clause"/>
-        </if>
-    </delete>
-    <insert id="insert" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataWithBLOBs">
-        insert into admin_data (data_id, name, picture_url,
-                                status, source, create_time,
-                                data_scenarios, field_description)
-        values (#{dataId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{pictureUrl,jdbcType=VARCHAR},
-                #{status,jdbcType=INTEGER}, #{source,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
-                #{dataScenarios,jdbcType=LONGVARCHAR}, #{fieldDescription,jdbcType=LONGVARCHAR})
-    </insert>
-    <insert id="insertSelective" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataWithBLOBs">
-        insert into admin_data
-        <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="dataId != null">
-                data_id,
-            </if>
-            <if test="name != null">
-                name,
-            </if>
-            <if test="pictureUrl != null">
-                picture_url,
-            </if>
-            <if test="status != null">
-                status,
-            </if>
-            <if test="source != null">
-                source,
-            </if>
-            <if test="createTime != null">
-                create_time,
-            </if>
-            <if test="dataScenarios != null">
-                data_scenarios,
-            </if>
-            <if test="fieldDescription != null">
-                field_description,
-            </if>
-        </trim>
-        <trim prefix="values (" suffix=")" suffixOverrides=",">
-            <if test="dataId != null">
-                #{dataId,jdbcType=VARCHAR},
-            </if>
-            <if test="name != null">
-                #{name,jdbcType=VARCHAR},
-            </if>
-            <if test="pictureUrl != null">
-                #{pictureUrl,jdbcType=VARCHAR},
-            </if>
-            <if test="status != null">
-                #{status,jdbcType=INTEGER},
-            </if>
-            <if test="source != null">
-                #{source,jdbcType=VARCHAR},
-            </if>
-            <if test="createTime != null">
-                #{createTime,jdbcType=TIMESTAMP},
-            </if>
-            <if test="dataScenarios != null">
-                #{dataScenarios,jdbcType=LONGVARCHAR},
-            </if>
-            <if test="fieldDescription != null">
-                #{fieldDescription,jdbcType=LONGVARCHAR},
-            </if>
-        </trim>
-    </insert>
-    <select id="countByExample" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataExample"
-            resultType="java.lang.Long">
-        select count(*) from admin_data
-        <if test="_parameter != null">
-            <include refid="Example_Where_Clause"/>
-        </if>
-    </select>
-    <update id="updateByExampleSelective" parameterType="map">
-        update admin_data
-        <set>
-            <if test="record.dataId != null">
-                data_id = #{record.dataId,jdbcType=VARCHAR},
-            </if>
-            <if test="record.name != null">
-                name = #{record.name,jdbcType=VARCHAR},
-            </if>
-            <if test="record.pictureUrl != null">
-                picture_url = #{record.pictureUrl,jdbcType=VARCHAR},
-            </if>
-            <if test="record.status != null">
-                status = #{record.status,jdbcType=INTEGER},
-            </if>
-            <if test="record.source != null">
-                source = #{record.source,jdbcType=VARCHAR},
-            </if>
-            <if test="record.createTime != null">
-                create_time = #{record.createTime,jdbcType=TIMESTAMP},
-            </if>
-            <if test="record.dataScenarios != null">
-                data_scenarios = #{record.dataScenarios,jdbcType=LONGVARCHAR},
-            </if>
-            <if test="record.fieldDescription != null">
-                field_description = #{record.fieldDescription,jdbcType=LONGVARCHAR},
-            </if>
-        </set>
-        <if test="_parameter != null">
-            <include refid="Update_By_Example_Where_Clause"/>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Update_By_Example_Where_Clause">
+    <where>
+      <foreach collection="example.oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
         </if>
-    </update>
-    <update id="updateByExampleWithBLOBs" parameterType="map">
-        update admin_data
-        set data_id = #{record.dataId,jdbcType=VARCHAR},
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Base_Column_List">
+    data_id, name, picture_url, status, source, create_time
+  </sql>
+  <sql id="Blob_Column_List">
+    data_scenarios, data_scenarios_original, field_description, field_description_original
+  </sql>
+  <select id="selectByExampleWithBLOBs" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataExample" resultMap="ResultMapWithBLOBs">
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    ,
+    <include refid="Blob_Column_List" />
+    from admin_data
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+    <if test="orderByClause != null">
+      order by ${orderByClause}
+    </if>
+  </select>
+  <select id="selectByExample" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataExample" resultMap="BaseResultMap">
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from admin_data
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+    <if test="orderByClause != null">
+      order by ${orderByClause}
+    </if>
+  </select>
+  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
+    select 
+    <include refid="Base_Column_List" />
+    ,
+    <include refid="Blob_Column_List" />
+    from admin_data
+    where data_id = #{dataId,jdbcType=VARCHAR}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
+    delete from admin_data
+    where data_id = #{dataId,jdbcType=VARCHAR}
+  </delete>
+  <delete id="deleteByExample" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataExample">
+    delete from admin_data
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataWithBLOBs">
+    insert into admin_data (data_id, name, picture_url, 
+      status, source, create_time, 
+      data_scenarios, data_scenarios_original, 
+      field_description, field_description_original
+      )
+    values (#{dataId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{pictureUrl,jdbcType=VARCHAR}, 
+      #{status,jdbcType=INTEGER}, #{source,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
+      #{dataScenarios,jdbcType=LONGVARCHAR}, #{dataScenariosOriginal,jdbcType=LONGVARCHAR}, 
+      #{fieldDescription,jdbcType=LONGVARCHAR}, #{fieldDescriptionOriginal,jdbcType=LONGVARCHAR}
+      )
+  </insert>
+  <insert id="insertSelective" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataWithBLOBs">
+    insert into admin_data
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="dataId != null">
+        data_id,
+      </if>
+      <if test="name != null">
+        name,
+      </if>
+      <if test="pictureUrl != null">
+        picture_url,
+      </if>
+      <if test="status != null">
+        status,
+      </if>
+      <if test="source != null">
+        source,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+      <if test="dataScenarios != null">
+        data_scenarios,
+      </if>
+      <if test="dataScenariosOriginal != null">
+        data_scenarios_original,
+      </if>
+      <if test="fieldDescription != null">
+        field_description,
+      </if>
+      <if test="fieldDescriptionOriginal != null">
+        field_description_original,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="dataId != null">
+        #{dataId,jdbcType=VARCHAR},
+      </if>
+      <if test="name != null">
+        #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="pictureUrl != null">
+        #{pictureUrl,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        #{status,jdbcType=INTEGER},
+      </if>
+      <if test="source != null">
+        #{source,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="dataScenarios != null">
+        #{dataScenarios,jdbcType=LONGVARCHAR},
+      </if>
+      <if test="dataScenariosOriginal != null">
+        #{dataScenariosOriginal,jdbcType=LONGVARCHAR},
+      </if>
+      <if test="fieldDescription != null">
+        #{fieldDescription,jdbcType=LONGVARCHAR},
+      </if>
+      <if test="fieldDescriptionOriginal != null">
+        #{fieldDescriptionOriginal,jdbcType=LONGVARCHAR},
+      </if>
+    </trim>
+  </insert>
+  <select id="countByExample" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataExample" resultType="java.lang.Long">
+    select count(*) from admin_data
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map">
+    update admin_data
+    <set>
+      <if test="record.dataId != null">
+        data_id = #{record.dataId,jdbcType=VARCHAR},
+      </if>
+      <if test="record.name != null">
         name = #{record.name,jdbcType=VARCHAR},
+      </if>
+      <if test="record.pictureUrl != null">
         picture_url = #{record.pictureUrl,jdbcType=VARCHAR},
+      </if>
+      <if test="record.status != null">
         status = #{record.status,jdbcType=INTEGER},
+      </if>
+      <if test="record.source != null">
         source = #{record.source,jdbcType=VARCHAR},
+      </if>
+      <if test="record.createTime != null">
         create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="record.dataScenarios != null">
         data_scenarios = #{record.dataScenarios,jdbcType=LONGVARCHAR},
-        field_description = #{record.fieldDescription,jdbcType=LONGVARCHAR}
-        <if test="_parameter != null">
-            <include refid="Update_By_Example_Where_Clause"/>
-        </if>
-    </update>
-    <update id="updateByExample" parameterType="map">
-        update admin_data
-        set data_id = #{record.dataId,jdbcType=VARCHAR},
-        name = #{record.name,jdbcType=VARCHAR},
-        picture_url = #{record.pictureUrl,jdbcType=VARCHAR},
-        status = #{record.status,jdbcType=INTEGER},
-        source = #{record.source,jdbcType=VARCHAR},
-        create_time = #{record.createTime,jdbcType=TIMESTAMP}
-        <if test="_parameter != null">
-            <include refid="Update_By_Example_Where_Clause"/>
-        </if>
-    </update>
-    <update id="updateByPrimaryKeySelective" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataWithBLOBs">
-        update admin_data
-        <set>
-            <if test="name != null">
-                name = #{name,jdbcType=VARCHAR},
-            </if>
-            <if test="pictureUrl != null">
-                picture_url = #{pictureUrl,jdbcType=VARCHAR},
-            </if>
-            <if test="status != null">
-                status = #{status,jdbcType=INTEGER},
-            </if>
-            <if test="source != null">
-                source = #{source,jdbcType=VARCHAR},
-            </if>
-            <if test="createTime != null">
-                create_time = #{createTime,jdbcType=TIMESTAMP},
-            </if>
-            <if test="dataScenarios != null">
-                data_scenarios = #{dataScenarios,jdbcType=LONGVARCHAR},
-            </if>
-            <if test="fieldDescription != null">
-                field_description = #{fieldDescription,jdbcType=LONGVARCHAR},
-            </if>
-        </set>
-        where data_id = #{dataId,jdbcType=VARCHAR}
-    </update>
-    <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataWithBLOBs">
-        update admin_data
-        set name              = #{name,jdbcType=VARCHAR},
-            picture_url       = #{pictureUrl,jdbcType=VARCHAR},
-            status            = #{status,jdbcType=INTEGER},
-            source            = #{source,jdbcType=VARCHAR},
-            create_time       = #{createTime,jdbcType=TIMESTAMP},
-            data_scenarios    = #{dataScenarios,jdbcType=LONGVARCHAR},
-            field_description = #{fieldDescription,jdbcType=LONGVARCHAR}
-        where data_id = #{dataId,jdbcType=VARCHAR}
-    </update>
-    <update id="updateByPrimaryKey" parameterType="com.sztzjy.resource_center.entity.admin.AdminData">
-        update admin_data
-        set name        = #{name,jdbcType=VARCHAR},
-            picture_url = #{pictureUrl,jdbcType=VARCHAR},
-            status      = #{status,jdbcType=INTEGER},
-            source      = #{source,jdbcType=VARCHAR},
-            create_time = #{createTime,jdbcType=TIMESTAMP}
-        where data_id = #{dataId,jdbcType=VARCHAR}
-    </update>
-
-
-    <resultMap id="dtoMap" type="com.sztzjy.resource_center.entity.admin.AdminDataReturnDto">
-        <id column="data_id" jdbcType="VARCHAR" property="dataId"/>
-        <result column="name" jdbcType="VARCHAR" property="name"/>
-        <result column="picture_url" jdbcType="VARCHAR" property="pictureUrl"/>
-        <result column="status" jdbcType="INTEGER" property="status"/>
-        <result column="data_scenarios" jdbcType="LONGVARCHAR" property="dataScenarios"/>
-        <result column="field_description" jdbcType="LONGVARCHAR" property="fieldDescription"/>
-        <result column="source" jdbcType="VARCHAR" property="source"/>
-        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
-        <result column="id" jdbcType="VARCHAR" property="collectId"/>
-        <collection property="adminDataLabels" ofType="com.sztzjy.resource_center.entity.admin.AdminDataLabel">
-            <id column="label_id" jdbcType="VARCHAR" property="labelId"/>
-            <result column="label_name" jdbcType="VARCHAR" property="name"/>
-            <result column="type" jdbcType="VARCHAR" property="type"/>
-            <result column="data_case_id" jdbcType="VARCHAR" property="dataCaseId"/>
-        </collection>
-        <collection property="adminFiles" ofType="com.sztzjy.resource_center.entity.admin.AdminFile">
-            <id column="file_url" jdbcType="VARCHAR" property="fileUrl"/>
-            <id column="file_id" jdbcType="VARCHAR" property="fileId"/>
-            <result column="file_name" jdbcType="VARCHAR" property="name"/>
-            <result column="source" jdbcType="VARCHAR" property="source"/>
-            <result column="data_case_id" jdbcType="VARCHAR" property="dataCaseId"/>
-        </collection>
-    </resultMap>
-
-    <select id="selectByConditions" resultMap="dtoMap">
-        SELECT a.data_id,a.name,a.picture_url,a.data_scenarios,a.field_description,a.`status`,a.source,a.create_time,
-        ad.`name`as label_name,ad.label_id,ad.type,ad.data_case_id,
-        af.file_url,af.`name` as file_name,af.source,af.file_id,af.data_case_id
-        FROM admin_data a
-        LEFT join admin_data_label ad ON a.data_id = ad.data_case_id
-        LEFT JOIN admin_file af on a.data_id = af.data_case_id
-        LEFT JOIN admin_collect_data acc on a.data_id = acc.data_id
-        <where>
-            <if test="keyWord !=null and keyWord !=''">
-                and a.name like CONCAT('%', #{keyWord}, '%')
-            </if>
-            <if test="labelName !=null and labelName !=''">
-                and ad.name in (#{labelName})
-            </if>
-            <if test="type !=null and type !=''">
-                and a.source != '管理员'
-            </if>
-        </where>
-        order by a.create_time desc
-    </select>
+      </if>
+      <if test="record.dataScenariosOriginal != null">
+        data_scenarios_original = #{record.dataScenariosOriginal,jdbcType=LONGVARCHAR},
+      </if>
+      <if test="record.fieldDescription != null">
+        field_description = #{record.fieldDescription,jdbcType=LONGVARCHAR},
+      </if>
+      <if test="record.fieldDescriptionOriginal != null">
+        field_description_original = #{record.fieldDescriptionOriginal,jdbcType=LONGVARCHAR},
+      </if>
+    </set>
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByExampleWithBLOBs" parameterType="map">
+    update admin_data
+    set data_id = #{record.dataId,jdbcType=VARCHAR},
+      name = #{record.name,jdbcType=VARCHAR},
+      picture_url = #{record.pictureUrl,jdbcType=VARCHAR},
+      status = #{record.status,jdbcType=INTEGER},
+      source = #{record.source,jdbcType=VARCHAR},
+      create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      data_scenarios = #{record.dataScenarios,jdbcType=LONGVARCHAR},
+      data_scenarios_original = #{record.dataScenariosOriginal,jdbcType=LONGVARCHAR},
+      field_description = #{record.fieldDescription,jdbcType=LONGVARCHAR},
+      field_description_original = #{record.fieldDescriptionOriginal,jdbcType=LONGVARCHAR}
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByExample" parameterType="map">
+    update admin_data
+    set data_id = #{record.dataId,jdbcType=VARCHAR},
+      name = #{record.name,jdbcType=VARCHAR},
+      picture_url = #{record.pictureUrl,jdbcType=VARCHAR},
+      status = #{record.status,jdbcType=INTEGER},
+      source = #{record.source,jdbcType=VARCHAR},
+      create_time = #{record.createTime,jdbcType=TIMESTAMP}
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataWithBLOBs">
+    update admin_data
+    <set>
+      <if test="name != null">
+        name = #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="pictureUrl != null">
+        picture_url = #{pictureUrl,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        status = #{status,jdbcType=INTEGER},
+      </if>
+      <if test="source != null">
+        source = #{source,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="dataScenarios != null">
+        data_scenarios = #{dataScenarios,jdbcType=LONGVARCHAR},
+      </if>
+      <if test="dataScenariosOriginal != null">
+        data_scenarios_original = #{dataScenariosOriginal,jdbcType=LONGVARCHAR},
+      </if>
+      <if test="fieldDescription != null">
+        field_description = #{fieldDescription,jdbcType=LONGVARCHAR},
+      </if>
+      <if test="fieldDescriptionOriginal != null">
+        field_description_original = #{fieldDescriptionOriginal,jdbcType=LONGVARCHAR},
+      </if>
+    </set>
+    where data_id = #{dataId,jdbcType=VARCHAR}
+  </update>
+  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.sztzjy.resource_center.entity.admin.AdminDataWithBLOBs">
+    update admin_data
+    set name = #{name,jdbcType=VARCHAR},
+      picture_url = #{pictureUrl,jdbcType=VARCHAR},
+      status = #{status,jdbcType=INTEGER},
+      source = #{source,jdbcType=VARCHAR},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      data_scenarios = #{dataScenarios,jdbcType=LONGVARCHAR},
+      data_scenarios_original = #{dataScenariosOriginal,jdbcType=LONGVARCHAR},
+      field_description = #{fieldDescription,jdbcType=LONGVARCHAR},
+      field_description_original = #{fieldDescriptionOriginal,jdbcType=LONGVARCHAR}
+    where data_id = #{dataId,jdbcType=VARCHAR}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.sztzjy.resource_center.entity.admin.AdminData">
+    update admin_data
+    set name = #{name,jdbcType=VARCHAR},
+      picture_url = #{pictureUrl,jdbcType=VARCHAR},
+      status = #{status,jdbcType=INTEGER},
+      source = #{source,jdbcType=VARCHAR},
+      create_time = #{createTime,jdbcType=TIMESTAMP}
+    where data_id = #{dataId,jdbcType=VARCHAR}
+  </update>
+  <resultMap id="dtoMap" type="com.sztzjy.resource_center.entity.admin.AdminDataReturnDto">
+    <id column="data_id" jdbcType="VARCHAR" property="dataId"/>
+    <result column="name" jdbcType="VARCHAR" property="name"/>
+    <result column="picture_url" jdbcType="VARCHAR" property="pictureUrl"/>
+    <result column="status" jdbcType="INTEGER" property="status"/>
+    <result column="data_scenarios" jdbcType="LONGVARCHAR" property="dataScenarios"/>
+    <result column="data_scenarios_original" jdbcType="LONGVARCHAR" property="dataScenariosOriginal"/>
+    <result column="field_description" jdbcType="LONGVARCHAR" property="fieldDescription"/>
+    <result column="field_description_original" jdbcType="LONGVARCHAR" property="fieldDescriptionOriginal"/>
+    <result column="source" jdbcType="VARCHAR" property="source"/>
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+    <result column="id" jdbcType="VARCHAR" property="collectId"/>
+    <collection property="adminDataLabels" ofType="com.sztzjy.resource_center.entity.admin.AdminDataLabel">
+      <id column="label_id" jdbcType="VARCHAR" property="labelId"/>
+      <result column="label_name" jdbcType="VARCHAR" property="name"/>
+      <result column="type" jdbcType="VARCHAR" property="type"/>
+      <result column="data_case_id" jdbcType="VARCHAR" property="dataCaseId"/>
+    </collection>
+    <collection property="adminFiles" ofType="com.sztzjy.resource_center.entity.admin.AdminFile">
+      <id column="file_url" jdbcType="VARCHAR" property="fileUrl"/>
+      <id column="file_id" jdbcType="VARCHAR" property="fileId"/>
+      <result column="file_name" jdbcType="VARCHAR" property="name"/>
+      <result column="source" jdbcType="VARCHAR" property="source"/>
+      <result column="data_case_id" jdbcType="VARCHAR" property="dataCaseId"/>
+    </collection>
+  </resultMap>
 
+  <select id="selectByConditions" resultMap="dtoMap">
+    SELECT a.data_id,a.name,a.picture_url,a.data_scenarios,a.data_scenarios_original,a.field_description,a.field_description_original,a.`status`,a.source,a.create_time,
+    ad.`name`as label_name,ad.label_id,ad.type,ad.data_case_id,
+    af.file_url,af.`name` as file_name,af.source,af.file_id,af.data_case_id
+    FROM admin_data a
+    LEFT join admin_data_label ad ON a.data_id = ad.data_case_id
+    LEFT JOIN admin_file af on a.data_id = af.data_case_id
+    LEFT JOIN admin_collect_data acc on a.data_id = acc.data_id
+    <where>
+      <if test="keyWord !=null and keyWord !=''">
+        and a.name like CONCAT('%', #{keyWord}, '%')
+      </if>
+      <if test="labelName !=null and labelName !=''">
+        and ad.name in (#{labelName})
+      </if>
+      <if test="type !=null and type !=''">
+        and a.source != '管理员'
+      </if>
+    </where>
+    order by a.create_time desc
+  </select>
 
-    <select id="selectByConditionsBySchoolId" resultMap="dtoMap">
-        SELECT a.data_id,a.name,a.picture_url,a.data_scenarios,a.field_description,a.`status`,a.source,a.create_time,
-        ad.`name`as label_name,ad.label_id,ad.type,ad.data_case_id,
-        af.file_url,af.`name` as file_name,af.source,af.file_id,af.data_case_id,
-        acc.id
-        FROM admin_data a
-        LEFT join admin_data_label ad ON a.data_id = ad.data_case_id
-        LEFT JOIN admin_file af on a.data_id = af.data_case_id
-        LEFT JOIN admin_collect_data acc on a.data_id = acc.data_id
-        <where>
-            and a.status=1
-            <if test="keyWord !=null and keyWord !=''">
-                and a.name like CONCAT('%', #{keyWord}, '%')
-            </if>
-            <if test="labelName !=null and labelName !=''">
-                and ad.name = #{labelName}
-            </if>
-            <if test="source !=null and source !=''">
-                and a.source in (#{source},'管理员')
-            </if>
-            <if test="userId !=null and userId !=''">
-                and acc.user_id = #{userId}
-            </if>
-        </where>
-        order by a.create_time desc
-    </select>
 
+  <select id="selectByConditionsBySchoolId" resultMap="dtoMap">
+    SELECT a.data_id,a.name,a.picture_url,a.data_scenarios,a.data_scenarios_original,a.field_description,a.field_description_original,a.`status`,a.source,a.create_time,
+    ad.`name`as label_name,ad.label_id,ad.type,ad.data_case_id,
+    af.file_url,af.`name` as file_name,af.source,af.file_id,af.data_case_id,
+    acc.id
+    FROM admin_data a
+    LEFT join admin_data_label ad ON a.data_id = ad.data_case_id
+    LEFT JOIN admin_file af on a.data_id = af.data_case_id
+    LEFT JOIN admin_collect_data acc on a.data_id = acc.data_id
+    <where>
+      and a.status=1
+      <if test="keyWord !=null and keyWord !=''">
+        and a.name like CONCAT('%', #{keyWord}, '%')
+      </if>
+      <if test="labelName !=null and labelName !=''">
+        and ad.name = #{labelName}
+      </if>
+      <if test="source !=null and source !=''">
+        and a.source in (#{source},'管理员')
+      </if>
+      <if test="userId !=null and userId !=''">
+        and acc.user_id = #{userId}
+      </if>
+    </where>
+    order by a.create_time desc
+  </select>
 </mapper>
\ No newline at end of file

From a52e395ccc8097cefafa0ca1d0db8b74d85ebbf2 Mon Sep 17 00:00:00 2001
From: whb <17803890193@163.com>
Date: Thu, 1 Aug 2024 17:37:31 +0800
Subject: [PATCH 7/8] =?UTF-8?q?=E6=96=B0=E5=A2=9Eipynb=E6=96=87=E4=BB=B6?=
 =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=AD=89=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 pom.xml                                       |   6 +
 .../resource_center/config/Constant.java      |   3 +
 .../new_module/stu/JupyterhubController.java  | 215 ++++++++++++++++++
 3 files changed, 224 insertions(+)
 create mode 100644 src/main/java/com/sztzjy/resource_center/controller/new_module/stu/JupyterhubController.java

diff --git a/pom.xml b/pom.xml
index f115ca6..16ab815 100644
--- a/pom.xml
+++ b/pom.xml
@@ -218,6 +218,12 @@
             <artifactId>ip2region</artifactId>
             <version>2.6.5</version>
         </dependency>
+        <!-- Apache HttpMime -->
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpmime</artifactId>
+            <version>4.5.14</version>
+        </dependency>
     </dependencies>
 
     <build>
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/new_module/stu/JupyterhubController.java b/src/main/java/com/sztzjy/resource_center/controller/new_module/stu/JupyterhubController.java
new file mode 100644
index 0000000..bd52a30
--- /dev/null
+++ b/src/main/java/com/sztzjy/resource_center/controller/new_module/stu/JupyterhubController.java
@@ -0,0 +1,215 @@
+package com.sztzjy.resource_center.controller.new_module.stu;
+
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.sztzjy.resource_center.annotation.AnonymousAccess;
+import com.sztzjy.resource_center.config.Constant;
+import com.sztzjy.resource_center.util.ResultEntity;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.entity.mime.MultipartEntityBuilder;
+import org.apache.http.entity.mime.content.ByteArrayBody;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+import java.util.Optional;
+
+/**
+ * @author 17803
+ * @date 2024-07-30 15:23
+ */
+
+@Api(tags = "jupyterhub的Api接口")
+@RequestMapping("api/jupyterhub")
+@RestController
+public class JupyterhubController {
+
+
+
+    @ApiOperation("创建容器")
+    @GetMapping("/jumpJupyerHub")
+    public ResultEntity jumpJupyerHub() throws IOException {
+        startServer("jupyterhub");
+        System.out.println("启动服务!");
+        String url = generateToken("jupyterhub");
+        return new ResultEntity<>(HttpStatus.OK,"容器创建成功!",url);
+        }
+
+
+    public static String generateToken(String username) throws IOException {
+        CloseableHttpClient client = HttpClients.createDefault();
+        HttpPost request = new HttpPost(Constant.JUPYTERHUB_API_URL + "/users/" + username + "/tokens");
+        request.addHeader("Authorization", "Bearer " + Constant.ADMIN_TOKEN);
+        request.addHeader("Content-Type", "application/json");
+
+        String json = "{\"note\": \"" + username + "\"}";
+        StringEntity entity = new StringEntity(json);
+        request.setEntity(entity);
+
+        HttpResponse response = client.execute(request);
+        HttpEntity responseEntity = response.getEntity();
+        String responseBody = EntityUtils.toString(responseEntity);
+
+        if (response.getStatusLine().getStatusCode() == 201) {
+
+            // 解析 JSON 响应体
+            JSONObject jsonObject = JSON.parseObject(responseBody);
+            // 提取生成的令牌
+            String token = jsonObject.getString("token");
+
+
+            System.out.println("Token : " + token);
+
+            String url =   "http://jrdsj.sztzjy.com:8000/user/" + username + "/?token=" + token;
+
+            return  url;
+        } else {
+            System.err.println("Failed to generate token. Status code: " + response.getStatusLine().getStatusCode());
+            System.err.println("Response: " + responseBody);
+            return null;
+        }
+    }
+
+    // 启动用户的 Jupyter 服务器
+    public static void startServer(String username) throws IOException {
+
+        // 启动服务器后将需要的文件复制到刚创建的容器内 模拟实现文件挂载
+        CloseableHttpClient client = HttpClients.createDefault();
+        HttpPost request = new HttpPost(Constant.JUPYTERHUB_API_URL + "/users/" + username + "/server");
+        request.addHeader("Authorization", "Bearer " + Constant.ADMIN_TOKEN);
+        request.addHeader("Content-Type", "application/json");
+
+        HttpResponse response = client.execute(request);
+        HttpEntity responseEntity = response.getEntity();
+        String responseBody = EntityUtils.toString(responseEntity);
+
+        if (response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 201) {
+
+
+            System.out.println("服务成功的启动: " + username);
+
+
+            client.close();
+        }
+    }
+
+
+
+
+
+    @ApiOperation("超管端或者教师端上传ipynb文件")
+    @PostMapping("/uploadFileByIpynb")
+    @AnonymousAccess
+    public ResponseEntity<String> uploadFileByIpynb(@RequestPart @ApiParam("文件") MultipartFile file, @ApiParam("案例名") String caseName) {
+        String url = "https://jrdsj.sztzjy.com:598/api/jupyterhub/uploadFileByIpynb";
+
+        try {
+            uploadFile(url, file, caseName);
+            return new ResponseEntity<>("上传成功", HttpStatus.OK);
+        } catch (IOException e) {
+            e.printStackTrace();
+            return new ResponseEntity<>("上传失败", HttpStatus.INTERNAL_SERVER_ERROR);
+        }
+    }
+
+    public static void uploadFile(String url, MultipartFile file, String caseName) throws IOException {
+        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
+            HttpPost uploadFile = new HttpPost(url);
+
+            // Build the multipart entity
+            MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+            builder.addPart("file", new ByteArrayBody(file.getBytes(), file.getOriginalFilename())); // Use ByteArrayBody for MultipartFile
+            builder.addTextBody("caseName", caseName);
+
+            HttpEntity entity = builder.build();
+            uploadFile.setEntity(entity);
+
+            // Execute the request
+            try (CloseableHttpResponse response = httpClient.execute(uploadFile)) {
+                HttpEntity responseEntity = response.getEntity();
+                String responseString = EntityUtils.toString(responseEntity);
+                System.out.println("Response: " + responseString);
+            }
+        }
+    }
+
+
+    @ApiOperation("保存时候判断ipynb文件是否存在")
+    @GetMapping("/filesIfExist")
+    @AnonymousAccess
+    public ResultEntity filesIfExist(@ApiParam("参数为:案例名") String caseName) throws InterruptedException, IOException {
+        String url = "https://jrdsj.sztzjy.com:598/api/jupyterhub/uploadFileByIpynbExist?caseName=" + caseName;
+
+        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
+            HttpGet httpGet = new HttpGet(url);
+
+            // 执行 GET 请求
+            try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
+                HttpEntity responseEntity = response.getEntity();
+                String responseString = EntityUtils.toString(responseEntity);
+
+                // 解析 JSON 响应
+                ObjectMapper objectMapper = new ObjectMapper();
+                JsonNode jsonResponse = objectMapper.readTree(responseString);
+
+                // 假设返回的 JSON 对象包含 "data" 字段
+                JsonNode dataNode = jsonResponse.get("data");
+                return new ResultEntity<>(HttpStatus.OK,dataNode != null && dataNode.asBoolean());
+            }
+        }
+
+    }
+
+
+
+    @ApiOperation("删除ipynb文件")
+    @GetMapping("/delUploadFileByIpynb")
+    @AnonymousAccess
+    public ResultEntity delUploadFileByIpynb(@ApiParam("参数为:案例名") String caseName) throws InterruptedException, IOException {
+        String url = "https://jrdsj.sztzjy.com:598/api/jupyterhub/delUploadFileByIpynb?caseName=" + caseName;
+
+        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
+            HttpGet httpGet = new HttpGet(url);
+
+            // 执行 GET 请求
+            try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
+                HttpEntity responseEntity = response.getEntity();
+                String responseString = EntityUtils.toString(responseEntity);
+
+                // 解析 JSON 响应
+                ObjectMapper objectMapper = new ObjectMapper();
+                JsonNode jsonResponse = objectMapper.readTree(responseString);
+
+                // 假设返回的 JSON 对象包含 "data" 字段
+                JsonNode dataNode = jsonResponse.get("data");
+                return new ResultEntity<>(HttpStatus.OK,dataNode != null && dataNode.asBoolean());
+            }
+        }
+
+    }
+
+
+
+
+
+}

From 80d8f7d7583735a2918b428107666b6cd60a5229 Mon Sep 17 00:00:00 2001
From: whb <17803890193@163.com>
Date: Fri, 2 Aug 2024 09:25:26 +0800
Subject: [PATCH 8/8] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B8=8A=E4=BC=A0?=
 =?UTF-8?q?=E7=9A=84ipyenb=E6=96=87=E4=BB=B6=E5=90=8D=E4=B9=B1=E7=A0=81?=
 =?UTF-8?q?=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../new_module/stu/JupyterhubController.java  | 34 +++++++++++++++++--
 1 file changed, 31 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/sztzjy/resource_center/controller/new_module/stu/JupyterhubController.java b/src/main/java/com/sztzjy/resource_center/controller/new_module/stu/JupyterhubController.java
index bd52a30..a2d65c3 100644
--- a/src/main/java/com/sztzjy/resource_center/controller/new_module/stu/JupyterhubController.java
+++ b/src/main/java/com/sztzjy/resource_center/controller/new_module/stu/JupyterhubController.java
@@ -16,7 +16,9 @@ import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
 import org.apache.http.entity.StringEntity;
+import org.apache.http.entity.mime.HttpMultipartMode;
 import org.apache.http.entity.mime.MultipartEntityBuilder;
 import org.apache.http.entity.mime.content.ByteArrayBody;
 import org.apache.http.impl.client.CloseableHttpClient;
@@ -132,14 +134,39 @@ public class JupyterhubController {
         }
     }
 
+//    public static void uploadFile(String url, MultipartFile file, String caseName) throws IOException {
+//        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
+//            HttpPost uploadFile = new HttpPost(url);
+//
+//            // Build the multipart entity
+//            MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+//            builder.addPart("file", new ByteArrayBody(file.getBytes(), file.getOriginalFilename())); // Use ByteArrayBody for MultipartFile
+//            builder.addTextBody("caseName", caseName);
+//
+//            HttpEntity entity = builder.build();
+//            uploadFile.setEntity(entity);
+//
+//            // Execute the request
+//            try (CloseableHttpResponse response = httpClient.execute(uploadFile)) {
+//                HttpEntity responseEntity = response.getEntity();
+//                String responseString = EntityUtils.toString(responseEntity, "UTF-8");
+//                System.out.println("Response: " + responseString);
+//            }
+//        }
+//    }
+
     public static void uploadFile(String url, MultipartFile file, String caseName) throws IOException {
         try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
             HttpPost uploadFile = new HttpPost(url);
 
             // Build the multipart entity
             MultipartEntityBuilder builder = MultipartEntityBuilder.create();
-            builder.addPart("file", new ByteArrayBody(file.getBytes(), file.getOriginalFilename())); // Use ByteArrayBody for MultipartFile
-            builder.addTextBody("caseName", caseName);
+
+            // Use ByteArrayBody with proper encoding for the file name
+            ByteArrayBody byteArrayBody = new ByteArrayBody(file.getBytes(), file.getOriginalFilename());
+            builder.addPart("file", byteArrayBody);
+            builder.addTextBody("caseName", caseName, ContentType.TEXT_PLAIN.withCharset("UTF-8"));
+            builder.setMode(HttpMultipartMode.RFC6532);//解决文件名乱码问题
 
             HttpEntity entity = builder.build();
             uploadFile.setEntity(entity);
@@ -147,7 +174,8 @@ public class JupyterhubController {
             // Execute the request
             try (CloseableHttpResponse response = httpClient.execute(uploadFile)) {
                 HttpEntity responseEntity = response.getEntity();
-                String responseString = EntityUtils.toString(responseEntity);
+                // Convert response entity to String with UTF-8 encoding
+                String responseString = EntityUtils.toString(responseEntity, "UTF-8");
                 System.out.println("Response: " + responseString);
             }
         }