From 8d42b23c07433f11cb0b1e16d9c74b0e29fd35ce Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期五, 05 七月 2024 09:57:42 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev
---
src/main/java/com/ycl/jxkg/controller/student/ExamPaperAnswerController.java | 133 +++++++++++++++++++-------------------------
1 files changed, 57 insertions(+), 76 deletions(-)
diff --git a/src/main/java/com/ycl/jxkg/controller/student/ExamPaperAnswerController.java b/src/main/java/com/ycl/jxkg/controller/student/ExamPaperAnswerController.java
index 80d7715..acbdaf4 100644
--- a/src/main/java/com/ycl/jxkg/controller/student/ExamPaperAnswerController.java
+++ b/src/main/java/com/ycl/jxkg/controller/student/ExamPaperAnswerController.java
@@ -1,65 +1,46 @@
package com.ycl.jxkg.controller.student;
+import com.alibaba.fastjson.JSON;
+import com.github.pagehelper.PageInfo;
import com.ycl.jxkg.base.BaseApiController;
import com.ycl.jxkg.base.Result;
-import com.ycl.jxkg.domain.*;
-import com.ycl.jxkg.domain.enums.ExamPaperAnswerStatusEnum;
-import com.ycl.jxkg.event.CalculateExamPaperAnswerCompleteEvent;
-import com.ycl.jxkg.event.UserEvent;
-import com.ycl.jxkg.service.ExamPaperAnswerService;
+import com.ycl.jxkg.domain.ExamPaperAnswerInfo;
+import com.ycl.jxkg.domain.entity.ExamPaperScore;
+import com.ycl.jxkg.domain.entity.User;
+import com.ycl.jxkg.domain.vo.PaperFixQuestionVO;
+import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperMarkNavbarVO;
+import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperScoreVO;
+import com.ycl.jxkg.domain.vo.student.exam.ExamPaperSubmitVO;
+import com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageResponseVO;
+import com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageVO;
+import com.ycl.jxkg.service.ExamPaperScoreService;
import com.ycl.jxkg.service.ExamPaperService;
import com.ycl.jxkg.service.SubjectService;
-import com.ycl.jxkg.utils.DateTimeUtil;
-import com.ycl.jxkg.utils.ExamUtil;
-import com.ycl.jxkg.utils.PageInfoHelper;
-import com.ycl.jxkg.vo.admin.exam.ExamPaperEditRequestVO;
-import com.ycl.jxkg.vo.student.exam.ExamPaperReadVO;
-import com.ycl.jxkg.vo.student.exam.ExamPaperSubmitVO;
-import com.ycl.jxkg.vo.student.exampaper.ExamPaperAnswerPageResponseVO;
-import com.ycl.jxkg.vo.student.exampaper.ExamPaperAnswerPageVO;
-import com.github.pagehelper.PageInfo;
+import com.ycl.jxkg.service.UserService;
+import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
-import java.util.Date;
+import java.util.Objects;
+@RequiredArgsConstructor
@RestController("StudentExamPaperAnswerController")
@RequestMapping(value = "/api/student/exampaper/answer")
public class ExamPaperAnswerController extends BaseApiController {
- private final ExamPaperAnswerService examPaperAnswerService;
+ private final ExamPaperScoreService examPaperScoreService;
+ private final UserService userService;
private final ExamPaperService examPaperService;
private final SubjectService subjectService;
private final ApplicationEventPublisher eventPublisher;
-
- @Autowired
- public ExamPaperAnswerController(ExamPaperAnswerService examPaperAnswerService, ExamPaperService examPaperService, SubjectService subjectService, ApplicationEventPublisher eventPublisher) {
- this.examPaperAnswerService = examPaperAnswerService;
- this.examPaperService = examPaperService;
- this.subjectService = subjectService;
- this.eventPublisher = eventPublisher;
- }
@RequestMapping(value = "/pageList", method = RequestMethod.POST)
public Result<PageInfo<ExamPaperAnswerPageResponseVO>> pageList(@RequestBody @Valid ExamPaperAnswerPageVO model) {
model.setCreateUser(getCurrentUser().getId());
- PageInfo<ExamPaperAnswer> pageInfo = examPaperAnswerService.studentPage(model);
- PageInfo<ExamPaperAnswerPageResponseVO> page = PageInfoHelper.copyMap(pageInfo, e -> {
- ExamPaperAnswerPageResponseVO vo = new ExamPaperAnswerPageResponseVO();
- BeanUtils.copyProperties(e, vo);
- Subject subject = subjectService.selectById(vo.getSubjectId());
- vo.setDoTime(ExamUtil.secondToVM(e.getDoTime()));
- vo.setSystemScore(ExamUtil.scoreToVM(e.getSystemScore()));
- vo.setUserScore(ExamUtil.scoreToVM(e.getUserScore()));
- vo.setPaperScore(ExamUtil.scoreToVM(e.getPaperScore()));
- vo.setSubjectName(subject.getName());
- vo.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime()));
- return vo;
- });
+ PageInfo<ExamPaperAnswerPageResponseVO> page = examPaperScoreService.studentPage(model);
return Result.ok(page);
}
@@ -67,55 +48,55 @@
@RequestMapping(value = "/answerSubmit", method = RequestMethod.POST)
public Result answerSubmit(@RequestBody @Valid ExamPaperSubmitVO examPaperSubmitVO) {
User user = getCurrentUser();
- ExamPaperAnswerInfo examPaperAnswerInfo = examPaperAnswerService.calculateExamPaperAnswer(examPaperSubmitVO, user);
+ ExamPaperAnswerInfo examPaperAnswerInfo = examPaperScoreService.calculateExamPaperAnswer(examPaperSubmitVO, user);
if (null == examPaperAnswerInfo) {
return Result.fail(2, "璇曞嵎涓嶈兘閲嶅鍋�");
}
- ExamPaperAnswer examPaperAnswer = examPaperAnswerInfo.getExamPaperAnswer();
- Integer userScore = examPaperAnswer.getUserScore();
- String scoreVm = ExamUtil.scoreToVM(userScore);
- UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date());
- String content = user.getUserName() + " 鎻愪氦璇曞嵎锛�" + examPaperAnswerInfo.getExamPaper().getName()
- + " 寰楀垎锛�" + scoreVm
- + " 鑰楁椂锛�" + ExamUtil.secondToVM(examPaperAnswer.getDoTime());
- userEventLog.setContent(content);
- eventPublisher.publishEvent(new CalculateExamPaperAnswerCompleteEvent(examPaperAnswerInfo));
- eventPublisher.publishEvent(new UserEvent(userEventLog));
- return Result.ok(scoreVm);
+// ExamPaperScore examPaperScore = examPaperAnswerInfo.getExamPaperScore();
+// Integer userScore = examPaperScore.getUserScore();
+// String scoreVm = ExamUtil.scoreToVM(userScore);
+// UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date());
+// String content = user.getUserName() + " 鎻愪氦璇曞嵎锛�" + examPaperAnswerInfo.getExamPaper().getName()
+// + " 寰楀垎锛�" + scoreVm
+// + " 鑰楁椂锛�" + ExamUtil.secondToVM(examPaperScore.getDoTime());
+// userEventLog.setContent(content);
+// eventPublisher.publishEvent(new CalculateExamPaperAnswerCompleteEvent(examPaperAnswerInfo));
+// eventPublisher.publishEvent(new UserEvent(userEventLog));
+// return Result.ok(scoreVm);
+ return Result.ok();
}
-
@RequestMapping(value = "/edit", method = RequestMethod.POST)
public Result edit(@RequestBody @Valid ExamPaperSubmitVO examPaperSubmitVO) {
- boolean notJudge = examPaperSubmitVO.getAnswerItems().stream().anyMatch(i -> i.getDoRight() == null && i.getScore() == null);
- if (notJudge) {
- return Result.fail(2, "鏈夋湭鎵规敼棰樼洰");
- }
-
- ExamPaperAnswer examPaperAnswer = examPaperAnswerService.selectById(examPaperSubmitVO.getId());
- ExamPaperAnswerStatusEnum examPaperAnswerStatusEnum = ExamPaperAnswerStatusEnum.fromCode(examPaperAnswer.getStatus());
- if (examPaperAnswerStatusEnum == ExamPaperAnswerStatusEnum.Complete) {
- return Result.fail(3, "璇曞嵎宸插畬鎴�");
- }
- String score = examPaperAnswerService.judge(examPaperSubmitVO);
- User user = getCurrentUser();
- UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date());
- String content = user.getUserName() + " 鎵规敼璇曞嵎锛�" + examPaperAnswer.getPaperName() + " 寰楀垎锛�" + score;
- userEventLog.setContent(content);
- eventPublisher.publishEvent(new UserEvent(userEventLog));
+// boolean notJudge = examPaperSubmitVO.getAnswerItems().stream().anyMatch(i -> i.getDoRight() == null && i.getScore() == null);
+// if (notJudge) {
+// return Result.fail(2, "鏈夋湭鎵规敼棰樼洰");
+// }
+//
+// ExamPaperScore examPaperScore = examPaperScoreService.getById(examPaperSubmitVO.getId());
+// ExamPaperAnswerStatusEnum examPaperAnswerStatusEnum = ExamPaperAnswerStatusEnum.fromCode(examPaperScore.getStatus());
+// if (examPaperAnswerStatusEnum == ExamPaperAnswerStatusEnum.Complete) {
+// return Result.fail(3, "璇曞嵎宸插畬鎴�");
+// }
+ String score = examPaperScoreService.judge(examPaperSubmitVO);
+// User user = getCurrentUser();
+// UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date());
+// String content = user.getUserName() + " 鎵规敼璇曞嵎锛�" + examPaperScore.get() + " 寰楀垎锛�" + score;
+// userEventLog.setContent(content);
+// eventPublisher.publishEvent(new UserEvent(userEventLog));
return Result.ok(score);
}
@RequestMapping(value = "/read/{id}", method = RequestMethod.POST)
- public Result<ExamPaperReadVO> read(@PathVariable Integer id) {
- ExamPaperAnswer examPaperAnswer = examPaperAnswerService.selectById(id);
- ExamPaperReadVO vm = new ExamPaperReadVO();
- ExamPaperEditRequestVO paper = examPaperService.examPaperToVM(examPaperAnswer.getExamPaperId());
- ExamPaperSubmitVO answer = examPaperAnswerService.examPaperAnswerToVM(examPaperAnswer.getId());
- vm.setPaper(paper);
- vm.setAnswer(answer);
- return Result.ok(vm);
+ public Result<ExamPaperScoreVO> read(@PathVariable Integer id) {
+ ExamPaperScore examPaperScore = examPaperScoreService.getById(id);
+ ExamPaperScoreVO examPaperScoreVO = new ExamPaperScoreVO();
+ BeanUtils.copyProperties(examPaperScore, examPaperScoreVO);
+ User user = userService.getById(examPaperScore.getUserId());
+ examPaperScoreVO.setUserName(Objects.nonNull(user) ? user.getRealName() : "鐢ㄦ埛宸叉敞閿�");
+ examPaperScoreVO.setNavbar(JSON.parseArray(examPaperScore.getNavbar(), ExamPaperMarkNavbarVO.class));
+ examPaperScoreVO.setTitleItems(JSON.parseArray(examPaperScore.getPaperContent(), PaperFixQuestionVO.class));
+ return Result.ok(examPaperScoreVO);
}
-
}
--
Gitblit v1.8.0