【修改】删除配置文件定时任务限制,【新增】浏览器考点设置
This commit is contained in:
@@ -27,7 +27,7 @@ public class GetPointsController {
|
||||
return CommonResult.success(examGetPointsService.get_file_point(pointsVo));
|
||||
}
|
||||
/**
|
||||
* 得出MYSQL操作考点
|
||||
* 文件得出MYSQL操作考点
|
||||
* @return 得分
|
||||
*/
|
||||
@PostMapping("/get_mysql_point")
|
||||
@@ -38,12 +38,12 @@ public class GetPointsController {
|
||||
* 新增MYSQL操作考点
|
||||
* @return 得分
|
||||
*/
|
||||
@PostMapping("/set_mysql_point")
|
||||
public CommonResult set_mysql_point(@RequestBody Points points) {
|
||||
return CommonResult.success(examGetPointsService.set_mysql_point(points));
|
||||
}
|
||||
// @PostMapping("/set_mysql_point")
|
||||
// public CommonResult set_mysql_point(@RequestBody Points points) {
|
||||
// return CommonResult.success(examGetPointsService.set_mysql_point(points));
|
||||
// }
|
||||
/**
|
||||
* 更新MYSQL操作考点
|
||||
* 新增/更新MYSQL操作考点
|
||||
* @return 得分
|
||||
*/
|
||||
@PostMapping("/update_mysql_point")
|
||||
@@ -56,12 +56,12 @@ public class GetPointsController {
|
||||
return CommonResult.success(examGetPointsService.getPointById(quId));
|
||||
}
|
||||
/**
|
||||
* 得出浏览器操作考点
|
||||
* 新增修改浏览器操作考点
|
||||
* @return 得分
|
||||
*/
|
||||
@PostMapping("/get_browser_point")
|
||||
@PostMapping("/set_browser_point")
|
||||
//todo 老师自己设置,不读文件
|
||||
public CommonResult get_browser_point(@RequestBody List<ExamQuestionAnswer> examQuestionAnswers) throws IOException {
|
||||
return CommonResult.success(examGetPointsService.get_browser_point());
|
||||
public CommonResult get_browser_point(@RequestBody Points points) {
|
||||
return CommonResult.success(examGetPointsService.get_browser_point(points));
|
||||
}
|
||||
}
|
||||
|
@@ -15,9 +15,9 @@ public interface ExamGetPointsService {
|
||||
|
||||
List<String> get_mysql_point(PointsVo pointsVo) throws IOException;
|
||||
|
||||
List<ExamQuestionAnswer> get_browser_point();
|
||||
boolean get_browser_point(Points points);
|
||||
|
||||
boolean set_mysql_point(Points points);
|
||||
// boolean set_mysql_point(Points points);
|
||||
|
||||
boolean update_mysql_point(Points points);
|
||||
|
||||
|
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.ibatis.executor.BatchResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.ExamMysqlKeyword;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer;
|
||||
@@ -90,13 +91,12 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
|
||||
})
|
||||
.sorted(Comparator.comparingInt(answer -> Integer.parseInt(answer.getSort()))) // 按 sort 排序
|
||||
.collect(Collectors.toList());
|
||||
answerList.addAll(formattedDifferences);
|
||||
// zip_file_sth.delete();
|
||||
// zip_file_answer.delete();
|
||||
// folderStu.delete();
|
||||
// folderAnswer.delete();
|
||||
|
||||
return answerList;
|
||||
answerList.addAll(formattedDifferences);
|
||||
zip_file_sth.delete();
|
||||
zip_file_answer.delete();
|
||||
deleteFolder(folderStu);
|
||||
deleteFolder(folderAnswer);
|
||||
return answerList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,10 +107,23 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
|
||||
ConfigDO config = configService.getConfigByKey("file_down_path");
|
||||
|
||||
String sthPath = ZipUtil.downloadStudentFile(pointsVo.getAnswerPath(), config.getValue());
|
||||
System.out.println(sthPath);
|
||||
List<String> sqlStatements = readSQLFromFile(sthPath);
|
||||
File zip_file = new File(sthPath);
|
||||
zip_file.delete();
|
||||
return sqlStatements;
|
||||
}
|
||||
|
||||
public static void deleteFolder(File folder) {
|
||||
if (folder.isDirectory()) {
|
||||
File[] files = folder.listFiles();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
deleteFolder(file); // 递归删除所有子文件/文件夹
|
||||
}
|
||||
}
|
||||
}
|
||||
folder.delete(); // 删除空文件夹或文件
|
||||
}
|
||||
private static List<String> readSQLFromFile(String filePath) throws IOException {
|
||||
|
||||
|
||||
@@ -163,45 +176,67 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
|
||||
return sqlList;
|
||||
}
|
||||
@Override
|
||||
public List<ExamQuestionAnswer> get_browser_point() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean set_mysql_point(Points points) {
|
||||
public boolean get_browser_point(Points points) {
|
||||
try {
|
||||
List<ExamQuestionAnswer> questionAnswerList = points.getQuestionAnswerList();
|
||||
if (CollectionUtils.isEmpty(questionAnswerList)) {
|
||||
String quId = points.getQuId();
|
||||
examQuestionAnswerMapper.deleteExamQuestionAnswerByQuesId(quId);
|
||||
|
||||
// 如果没有新数据就返回
|
||||
if (CollectionUtils.isEmpty(points.getQuestionAnswerList())) {
|
||||
return true;
|
||||
}
|
||||
List<ExamMysqlKeyword> allKeywords = new ArrayList<>();
|
||||
|
||||
//设置sort
|
||||
AtomicInteger sortCounter = new AtomicInteger(1);
|
||||
points.getQuestionAnswerList().forEach(answer -> {
|
||||
answer.setSort(String.valueOf(sortCounter.getAndIncrement()));
|
||||
});
|
||||
List<ExamQuestionAnswer> questionAnswerList = points.getQuestionAnswerList();
|
||||
for (ExamQuestionAnswer examQuestionAnswer : questionAnswerList) {
|
||||
String answerId = IdUtils.simpleUUID();
|
||||
examQuestionAnswer.setAnswerId(answerId);
|
||||
examQuestionAnswer.setQuId(points.getQuId());
|
||||
List<ExamMysqlKeyword> keywordList = examQuestionAnswer.getExamMysqlKeywordList();
|
||||
if (!CollectionUtils.isEmpty(keywordList)) {
|
||||
for (ExamMysqlKeyword keyword : keywordList) {
|
||||
keyword.setAnswerId(answerId);
|
||||
keyword.setKeywordId(IdUtils.simpleUUID());
|
||||
}
|
||||
allKeywords.addAll(keywordList);
|
||||
}
|
||||
examQuestionAnswer.setAnswerId(IdUtils.simpleUUID());
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(allKeywords)) {
|
||||
mysqlKeywordMapper.insertOrUpdate(allKeywords);
|
||||
}
|
||||
|
||||
examQuestionAnswerMapper.insertOrUpdate(questionAnswerList);
|
||||
examQuestionAnswerMapper.insertExamQuestionAnswerList(questionAnswerList);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("保存考试点信息失败", e);
|
||||
return false;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean set_mysql_point(Points points) {
|
||||
// try {
|
||||
// List<ExamQuestionAnswer> questionAnswerList = points.getQuestionAnswerList();
|
||||
// if (CollectionUtils.isEmpty(questionAnswerList)) {
|
||||
// return true;
|
||||
// }
|
||||
// List<ExamMysqlKeyword> allKeywords = new ArrayList<>();
|
||||
//
|
||||
// for (ExamQuestionAnswer examQuestionAnswer : questionAnswerList) {
|
||||
// String answerId = IdUtils.simpleUUID();
|
||||
// examQuestionAnswer.setAnswerId(answerId);
|
||||
// examQuestionAnswer.setQuId(points.getQuId());
|
||||
// List<ExamMysqlKeyword> keywordList = examQuestionAnswer.getExamMysqlKeywordList();
|
||||
// if (!CollectionUtils.isEmpty(keywordList)) {
|
||||
// for (ExamMysqlKeyword keyword : keywordList) {
|
||||
// keyword.setAnswerId(answerId);
|
||||
// keyword.setKeywordId(IdUtils.simpleUUID());
|
||||
// }
|
||||
// allKeywords.addAll(keywordList);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (!CollectionUtils.isEmpty(allKeywords)) {
|
||||
// mysqlKeywordMapper.insertOrUpdate(allKeywords);
|
||||
// }
|
||||
//
|
||||
// examQuestionAnswerMapper.insertOrUpdate(questionAnswerList);
|
||||
// return true;
|
||||
// } catch (Exception e) {
|
||||
// log.error("保存考试点信息失败", e);
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public boolean update_mysql_point(Points points) {
|
||||
try {
|
||||
@@ -227,11 +262,12 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
|
||||
|
||||
// 新的 keyword 收集
|
||||
List<ExamMysqlKeyword> newKeywordList = new ArrayList<>();
|
||||
AtomicInteger counter = new AtomicInteger(0);
|
||||
for (ExamQuestionAnswer answer : questionAnswerList) {
|
||||
String answerId = IdUtils.simpleUUID();
|
||||
answer.setAnswerId(answerId);
|
||||
answer.setQuId(quId); // 以防前端未传
|
||||
|
||||
answer.setSort(String.valueOf(counter.getAndIncrement())); // 设置排序字段(String 类型)
|
||||
List<ExamMysqlKeyword> keywordList = answer.getExamMysqlKeywordList();
|
||||
if (!CollectionUtils.isEmpty(keywordList)) {
|
||||
for (ExamMysqlKeyword keyword : keywordList) {
|
||||
@@ -243,9 +279,9 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
|
||||
}
|
||||
|
||||
// 插入新答案和关键词
|
||||
examQuestionAnswerMapper.insertOrUpdate(questionAnswerList);
|
||||
examQuestionAnswerMapper.insert(questionAnswerList);
|
||||
if (!CollectionUtils.isEmpty(newKeywordList)) {
|
||||
mysqlKeywordMapper.insertOrUpdate(newKeywordList);
|
||||
mysqlKeywordMapper.insert(newKeywordList);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user