|
@@ -542,26 +542,35 @@ public class KmtExerciseQuestionDealServiceImpl implements KmtExerciseQuestionDe
|
|
|
@Override
|
|
|
public ResponseEntity removeQuestionNumMark(String userId, QuestionNumMarkRemoveVo request) {
|
|
|
ResponseEntity responseEntity = new ResponseEntity();
|
|
|
+
|
|
|
if (request.getStartX() < 0 || request.getStartY() < 0 || request.getEndX() < 0 || request.getEndY() < 0){
|
|
|
return responseEntity.failure("请把坐标定位在图片内");
|
|
|
- }
|
|
|
-
|
|
|
- KmtExerciseQuestion kmtExerciseQuestion = kmtExerciseQuestionService.getById(request.getQuestionId());
|
|
|
- kmtExerciseMapper.updateQuestionStartPointAndEndPoint(request.getStartX(), request.getStartY(),
|
|
|
- request.getEndX(), request.getEndY(), request.getQuestionId());
|
|
|
- TbLibManager manager = bookManagerDao.findByUserIdAndType(userId, 18);
|
|
|
- if (manager != null && kmtExerciseQuestion != null && kmtExerciseQuestion.getDealStatus() > 3 && kmtExerciseQuestion.getDealStatus() != 7) {
|
|
|
- String path = this.removeQuestionNumMark(request.getStartX(), request.getStartY(), request.getEndX(), request.getEndY(), kmtExerciseQuestion.getImage());
|
|
|
- String content = JSONFileUtil.readJSONFile(PropertiesUtil.getValue("EXERCISE_JSON_FILE_PATH") + kmtExerciseQuestion.getQuestionPath());
|
|
|
- if (StringUtil.isNotBlank(content) && StringUtil.isNotBlank(path)) {
|
|
|
- Map<String, Object> map = JSON.parseObject(content, Map.class);
|
|
|
- map.put("question_json", Collections.singletonList(ExerciseUtil.getExerciseQuestionAnswerValue(path)));
|
|
|
- map.put("question", "<img src='" + PropertiesUtil.getValue("STATIC_FILE_URL") + path + "'/>");
|
|
|
- JSONFileUtil.saveJSONFile(PropertiesUtil.getValue("EXERCISE_JSON_FILE_PATH") + kmtExerciseQuestion.getQuestionPath(), JSON.toJSONString(map));
|
|
|
- ThreadPool.getInstance().addTask(new SyncSaveExerciseQuestionsTask(kmtExerciseMapper, exerciseQuestionSearchService, Collections.singletonList(kmtExerciseQuestion.getId())));
|
|
|
+ } else {
|
|
|
+ KmtExerciseQuestion kmtExerciseQuestion = kmtExerciseQuestionService.getById(request.getQuestionId());
|
|
|
+ if (kmtExerciseQuestion != null && StringUtil.isNotBlank(kmtExerciseQuestion.getImage())) {
|
|
|
+ Map<String, Integer> widthAndHeight = ExerciseUtil.getImageWidthAndHeight(kmtExerciseQuestion.getImage());
|
|
|
+ int width = widthAndHeight.get("width");
|
|
|
+ int height = widthAndHeight.get("height");
|
|
|
+ if (request.getStartX() > width || request.getEndX() > width || request.getStartY() > height || request.getEndY() > height){
|
|
|
+ return responseEntity.failure("请把坐标定位在图片内");
|
|
|
+ }
|
|
|
+ kmtExerciseMapper.updateQuestionStartPointAndEndPoint(request.getStartX(), request.getStartY(),
|
|
|
+ request.getEndX(), request.getEndY(), request.getQuestionId());
|
|
|
+ TbLibManager manager = bookManagerDao.findByUserIdAndType(userId, 18);
|
|
|
+ if (manager != null && kmtExerciseQuestion.getDealStatus() > 3 && kmtExerciseQuestion.getDealStatus() != 7) {
|
|
|
+ String path = this.removeQuestionNumMark(request.getStartX(), request.getStartY(), request.getEndX(), request.getEndY(), kmtExerciseQuestion.getImage());
|
|
|
+ String content = JSONFileUtil.readJSONFile(PropertiesUtil.getValue("EXERCISE_JSON_FILE_PATH") + kmtExerciseQuestion.getQuestionPath());
|
|
|
+ if (StringUtil.isNotBlank(content) && StringUtil.isNotBlank(path)) {
|
|
|
+ Map<String, Object> map = JSON.parseObject(content, Map.class);
|
|
|
+ map.put("question_json", Collections.singletonList(ExerciseUtil.getExerciseQuestionAnswerValue(path)));
|
|
|
+ map.put("question", "<img src='" + PropertiesUtil.getValue("STATIC_FILE_URL") + path + "'/>");
|
|
|
+ JSONFileUtil.saveJSONFile(PropertiesUtil.getValue("EXERCISE_JSON_FILE_PATH") + kmtExerciseQuestion.getQuestionPath(), JSON.toJSONString(map));
|
|
|
+ ThreadPool.getInstance().addTask(new SyncSaveExerciseQuestionsTask(kmtExerciseMapper, exerciseQuestionSearchService, Collections.singletonList(kmtExerciseQuestion.getId())));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ return responseEntity.success("成功");
|
|
|
}
|
|
|
- return responseEntity.success("成功");
|
|
|
}
|
|
|
|
|
|
@Override
|