From 4f5952c0082ef451dbf2c7ac4c2fb6055cb02f38 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Wed, 18 Aug 2021 11:58:00 +0800
Subject: [PATCH] 开始考试接口调用修改

---
 src/main/java/org/springblade/modules/apply/controller/ApplyController.java |   25 ++++++++++++++++++-------
 1 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/springblade/modules/apply/controller/ApplyController.java b/src/main/java/org/springblade/modules/apply/controller/ApplyController.java
index c749f31..c6f1b8b 100644
--- a/src/main/java/org/springblade/modules/apply/controller/ApplyController.java
+++ b/src/main/java/org/springblade/modules/apply/controller/ApplyController.java
@@ -24,7 +24,9 @@
 import org.springblade.modules.apply.vo.ApplyPaPerVO;
 import org.springblade.modules.apply.vo.ApplyVO;
 import org.springblade.modules.exam.entity.ExamPaper;
+import org.springblade.modules.exam.entity.ExamScore;
 import org.springblade.modules.exam.service.ExamPaperService;
+import org.springblade.modules.exam.service.ExamScoreService;
 import org.springblade.modules.system.entity.User;
 import org.springblade.modules.system.service.IUserService;
 import org.springframework.web.bind.annotation.*;
@@ -50,6 +52,8 @@
 	private final ExamPaperService examPaperService;
 
 	private final IUserService userService;
+
+	private final ExamScoreService examScoreService;
 
 	/**
 	 * 自定义分页
@@ -98,7 +102,7 @@
 			if (1==user.getIsApply()){
 				return R.data(201,"已报名,不能重复报名");
 			}
-			if (2==user.getIsApply() || -1==user.getIsApply()){
+			if (2==user.getIsApply() || -1==user.getIsApply() || 3==user.getIsApply()){
 				//默认通过
 				apply.setApplyStatus(2);
 				//默认为未考试状态
@@ -389,9 +393,6 @@
 				return R.data(200,"取消报名成功");
 			}
 		}else {
-			if (user.getIsApply()==2) {
-				return R.data(201,"尚未报名");
-			}
 			if(user.getIsApply()==1){
 				apply.setApplyStatus(4);
 				boolean status = applyService.updateById(apply);
@@ -401,6 +402,8 @@
 				if (status){
 					return R.data(200,"取消报名成功");
 				}
+			}else {
+				return R.data(201,"尚未报名");
 			}
 		}
 		return R.data(202,"取消报名失败");
@@ -468,7 +471,7 @@
 					user.setIsApply(1);
 					userService.updateById(user);
 				} else {
-					if (user.getIsApply() == 2 || -1==user.getIsApply()) {
+					if (user.getIsApply() == 2 || -1==user.getIsApply() || 3==user.getIsApply()) {
 						Apply apply1 = new Apply();
 						apply1.setApplyStatus(2);
 						//默认为未考试状态
@@ -501,7 +504,7 @@
 						user.setIsApply(1);
 						userService.updateById(user);
 					} else {
-						if (user.getIsApply() == 2 || -1==user.getIsApply()) {
+						if (user.getIsApply() == 2 || -1==user.getIsApply() || 3==user.getIsApply()) {
 							Apply apply1 = new Apply();
 							apply1.setApplyStatus(2);
 							//默认为未考试状态
@@ -619,8 +622,16 @@
 	 * @return
 	 */
 	@PostMapping("/updateApplyStatus")
-	public void updateApplyStatus(@RequestBody ApplyVO apply){
+	public ExamScore updateApplyStatus(@RequestBody ApplyVO apply){
 		applyService.updateApplyStatus(apply);
+		//新增考试成绩,没有成绩数据,待提交答题后更新数据
+		ExamScore examScore = new ExamScore();
+		examScore.setExamId(apply.getExamId().toString());
+		examScore.setUserId(apply.getUserId().toString());
+		examScore.setExamTime(new Date());
+		//新增
+		examScoreService.save(examScore);
+		return examScore;
 	}
 
 

--
Gitblit v1.9.3