whb
commit d251f63a91

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

@ -55,7 +55,7 @@ public class CaseStepController {
@PostMapping("updateCase") @PostMapping("updateCase")
public ResultEntity<HttpStatus> updateCase(@RequestBody SysCaseQuestionStepWithBLOBs caseQuestionStepWithBLOBs, public ResultEntity<HttpStatus> updateCase(@RequestBody SysCaseQuestionStepWithBLOBs caseQuestionStepWithBLOBs,
@ApiParam("谁调的请求,传管理员/学校ID") @RequestParam String source) { @ApiParam("谁调的请求,传管理员/学校ID") @RequestParam String source) {
List<SysTopicAndCourse> sysTopicAndCourses = getSysTopicAndCourses(caseQuestionStepWithBLOBs.getCaseId()); // List<SysTopicAndCourse> sysTopicAndCourses = getSysTopicAndCourses(caseQuestionStepWithBLOBs.getCaseId());
// if (!sysTopicAndCourses.isEmpty()) { // if (!sysTopicAndCourses.isEmpty()) {
// return new ResultEntity<>(HttpStatus.BAD_REQUEST, "该案例题正在被使用!"); // return new ResultEntity<>(HttpStatus.BAD_REQUEST, "该案例题正在被使用!");
// } // }
@ -63,7 +63,7 @@ public class CaseStepController {
//todo 管理员任意修改,老师只能改自己的 //todo 管理员任意修改,老师只能改自己的
SysCaseQuestion sysCaseQuestion = sysCaseQuestionMapper.selectByPrimaryKey(caseQuestionStepWithBLOBs.getCaseId()); SysCaseQuestion sysCaseQuestion = sysCaseQuestionMapper.selectByPrimaryKey(caseQuestionStepWithBLOBs.getCaseId());
if ("管理员".equals(source) || source.equals(sysCaseQuestion.getSource())) { if ("管理员".equals(source) || source.equals(sysCaseQuestion.getSource())) {
caseQuestionStepMapper.updateByPrimaryKey(caseQuestionStepWithBLOBs); caseQuestionStepMapper.updateByPrimaryKeyWithBLOBs(caseQuestionStepWithBLOBs);
return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); return new ResultEntity<>(HttpStatus.OK, "编辑成功!");
} else { } else {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "权限不足!"); return new ResultEntity<>(HttpStatus.BAD_REQUEST, "权限不足!");

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

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

@ -293,6 +293,7 @@ public class CaseApi {
SysCaseQuestionExample example1 = new SysCaseQuestionExample(); SysCaseQuestionExample example1 = new SysCaseQuestionExample();
example1.createCriteria().andCaseIdIn(collect).andSourceEqualTo("管理员"); example1.createCriteria().andCaseIdIn(collect).andSourceEqualTo("管理员");
example1.setOrderByClause("create_time");
List<SysCaseQuestion> list = caseQuestionMapper.selectByExampleWithBLOBs(example1); List<SysCaseQuestion> list = caseQuestionMapper.selectByExampleWithBLOBs(example1);
return list; return list;
} }
@ -307,12 +308,8 @@ public class CaseApi {
@PostMapping("selectCaseStepListBatchByIdListAndSort") @PostMapping("selectCaseStepListBatchByIdListAndSort")
@ApiOperation("查询案例题步骤并排序") @ApiOperation("查询案例题步骤并排序")
@AnonymousAccess @AnonymousAccess
public List<SysCaseQuestionStepWithBLOBs> selectCaseStepListBatchByIdListAndSort(@RequestBody List<String> caseIdList) { public List<SysCaseQuestionStepWithBLOBs> selectCaseStepListBatchByIdListAndSort(@RequestParam String threeId) {
SysCaseQuestionStepExample example = new SysCaseQuestionStepExample(); return caseQuestionStepMapper.selectCaseStepListBatchByIdListAndSort(threeId);
example.createCriteria().andCaseIdIn(caseIdList);
example.setOrderByClause("sort");
List<SysCaseQuestionStepWithBLOBs> sysCaseQuestionStepWithBLOBs = caseQuestionStepMapper.selectByExampleWithBLOBs(example);
return sysCaseQuestionStepWithBLOBs;
} }

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

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

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

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

@ -45,4 +45,6 @@ public interface SysCaseQuestionStepMapper {
List<TrainingDto> selectTrainingByIds(@Param("list") List<String> caseStepIdList); List<TrainingDto> selectTrainingByIds(@Param("list") List<String> caseStepIdList);
List<SysCaseQuestionStepWithBLOBs> getCaseStepByIds(@Param("ids") List<String> ids); List<SysCaseQuestionStepWithBLOBs> getCaseStepByIds(@Param("ids") List<String> ids);
List<SysCaseQuestionStepWithBLOBs> selectCaseStepListBatchByIdListAndSort(@Param("threeId") String threeId);
} }

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

@ -48,7 +48,51 @@ public class CompressUtil {
if (keepDirStructure != null && keepDirStructure) { if (keepDirStructure != null && keepDirStructure) {
zos.putNextEntry(new ZipEntry(relativePath)); zos.putNextEntry(new ZipEntry(relativePath));
} else { } 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; int len;
while ((len = fis.read(buf)) > 0) { while ((len = fis.read(buf)) > 0) {

@ -421,7 +421,8 @@
</resultMap> </resultMap>
<select id="selectTrainingByIds" resultMap="DtoBaseResultMap"> <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 FROM sys_case_question_steps sqs
JOIN sys_case_questions sq ON sqs.case_id = sq.case_id 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 JOIN sys_topic_and_course s3 ON sq.case_id = s3.topic_id
@ -440,4 +441,15 @@
#{item} #{item}
</foreach> </foreach>
</select> </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> </mapper>

@ -223,4 +223,12 @@
source = #{source,jdbcType=VARCHAR} source = #{source,jdbcType=VARCHAR}
where resource_data_id = #{resourceDataId,jdbcType=VARCHAR} where resource_data_id = #{resourceDataId,jdbcType=VARCHAR}
</update> </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> </mapper>
Loading…
Cancel
Save