From f1092d53966cf3b3b93be7fc59d913cd13d2ec37 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Mon, 16 Aug 2021 16:17:47 +0800
Subject: [PATCH] 1.用户新增角色关联持证字段 2.新增接口,考试开始,修改考试的状态为考试中 3.考试查询接口修改

---
 src/main/java/org/springblade/modules/apply/service/ApplyService.java          |    7 +++
 src/main/java/org/springblade/modules/system/mapper/UserMapper.xml             |    6 +++
 src/main/java/org/springblade/modules/apply/service/impl/ApplyServiceImpl.java |   28 ++++++++++++++
 src/main/java/org/springblade/modules/apply/controller/ApplyController.java    |   12 ++++++
 src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml          |    8 ++--
 src/main/java/org/springblade/modules/system/controller/UserController.java    |   13 ++++++
 src/main/java/org/springblade/modules/exam/vo/ExamPaperVO.java                 |    5 ++
 7 files changed, 75 insertions(+), 4 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 097f552..83945ce 100644
--- a/src/main/java/org/springblade/modules/apply/controller/ApplyController.java
+++ b/src/main/java/org/springblade/modules/apply/controller/ApplyController.java
@@ -573,4 +573,16 @@
 		return applyService.getSecurityApplyDetail(apply);
 	}
 
+
+	/**
+	 * 修改考试状态
+	 * @param apply 报名信息,包含userId,applyid
+	 * @return
+	 */
+	@PostMapping("/updateApplyStatus")
+	public void updateApplyStatus(@RequestBody ApplyVO apply){
+		applyService.updateApplyStatus(apply);
+	}
+
+
 }
diff --git a/src/main/java/org/springblade/modules/apply/service/ApplyService.java b/src/main/java/org/springblade/modules/apply/service/ApplyService.java
index f9f88be..ac8d265 100644
--- a/src/main/java/org/springblade/modules/apply/service/ApplyService.java
+++ b/src/main/java/org/springblade/modules/apply/service/ApplyService.java
@@ -102,4 +102,11 @@
 	 * @return
 	 */
     ApplyVO getSecurityApplyDetail(ApplyVO apply);
+
+	/**
+	 * 修改考试状态
+	 * @param apply 报名信息,包含userId,applyid
+	 * @return
+	 */
+    void updateApplyStatus(ApplyVO apply);
 }
diff --git a/src/main/java/org/springblade/modules/apply/service/impl/ApplyServiceImpl.java b/src/main/java/org/springblade/modules/apply/service/impl/ApplyServiceImpl.java
index a702dba..941f8f7 100644
--- a/src/main/java/org/springblade/modules/apply/service/impl/ApplyServiceImpl.java
+++ b/src/main/java/org/springblade/modules/apply/service/impl/ApplyServiceImpl.java
@@ -23,6 +23,8 @@
 import org.springblade.modules.exam.service.ExamPaperService;
 import org.springblade.modules.system.entity.User;
 import org.springblade.modules.system.service.IUserService;
+import org.springblade.modules.training.entity.TrainingRegistration;
+import org.springblade.modules.training.service.TrainingRegistrationService;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -42,6 +44,8 @@
 	private final ExamPaperService examPaperService;
 
 	private final IUserService userService;
+
+	private final TrainingRegistrationService trainingRegistrationService;
 
 	/**
 	 * 自定义分页数据
@@ -395,4 +399,28 @@
 	public ApplyVO getSecurityApplyDetail(ApplyVO apply) {
 		return baseMapper.getSecurityApplyDetail(apply);
 	}
+
+
+	/**
+	 * 修改考试状态
+	 * @param apply 报名信息,包含userId,applyid
+	 * @return
+	 */
+	@Override
+	public void updateApplyStatus(ApplyVO apply) {
+		//正式考
+		if (apply.getExamType()==1){
+			//考试中
+			apply.setIsExam(3);
+			baseMapper.updateById(apply);
+		}
+		//模拟考
+		if (apply.getExamType()==2){
+			TrainingRegistration trainingRegistration = new TrainingRegistration();
+			trainingRegistration.setId(apply.getId());
+			//考试中
+			trainingRegistration.setIsExam(3);
+			trainingRegistrationService.updateById(trainingRegistration);
+		}
+	}
 }
diff --git a/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml b/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
index 67650ba..f35aa03 100644
--- a/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
+++ b/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
@@ -134,8 +134,8 @@
     <!--查询考试人员考试信息-->
     <select id="getExamDetail" resultType="org.springblade.modules.exam.vo.ExamPaperVO">
         (select
-            ke.id,ke.exam_name examName,
-            sa.candidate_no candidateNo,
+            ke.id,ke.exam_name examName,ke.exam_type examType,
+            sa.candidate_no candidateNo,sa.id applyId,
             bu.real_name realName,bu.sex,bu.cardid idCardNo
         from
             ksxt_exam ke
@@ -156,8 +156,8 @@
         union all
 
         (select
-            ke.id,ke.exam_name examName,
-            str.candidate_no candidateNo,
+            ke.id,ke.exam_name examName,ke.exam_type examType,
+            str.candidate_no candidateNo,str.id applyId,
             bu.real_name realName,bu.sex,bu.cardid idCardNo
         from
             ksxt_exam ke
diff --git a/src/main/java/org/springblade/modules/exam/vo/ExamPaperVO.java b/src/main/java/org/springblade/modules/exam/vo/ExamPaperVO.java
index 7dead06..36f9f0f 100644
--- a/src/main/java/org/springblade/modules/exam/vo/ExamPaperVO.java
+++ b/src/main/java/org/springblade/modules/exam/vo/ExamPaperVO.java
@@ -31,4 +31,9 @@
 	 * 性别 1 男  2 女
 	 */
 	private Integer sex;
+
+	/**
+	 * 考试 id
+	 */
+	private Long applyId;
 }
diff --git a/src/main/java/org/springblade/modules/system/controller/UserController.java b/src/main/java/org/springblade/modules/system/controller/UserController.java
index 08f7d12..ace0f09 100644
--- a/src/main/java/org/springblade/modules/system/controller/UserController.java
+++ b/src/main/java/org/springblade/modules/system/controller/UserController.java
@@ -170,6 +170,19 @@
 	//@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
 	public R submit(@Valid @RequestBody User user) throws Exception {
 		CacheUtil.clear(USER_CACHE);
+		//查询角色
+		if (null!=user.getRoleId()){
+			Role role = new Role();
+			role.setId(Long.parseLong(user.getRoleId()));
+			Role one = roleService.getOne(Condition.getQueryWrapper(role));
+			if (one.getRoleAlias().equals("保安")){
+				user.setHold("1");
+			}
+			if (one.getRoleAlias().equals("未持证保安")){
+				user.setHold("2");
+			}
+		}
+
 		return R.status(userService.submit(user));
 	}
 
diff --git a/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml b/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
index e5c50d2..6282a40 100644
--- a/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
+++ b/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
@@ -105,6 +105,9 @@
         <if test="user.securitynumber!=null and user.securitynumber != ''">
             and bu.securitynumber = #{user.securitynumber}
         </if>
+        <if test="user.examinationType!=null and user.examinationType != ''">
+            and bu.examination_type = #{user.examinationType}
+        </if>
         <if test="deptIdList!=null and deptIdList.size>0">
             and bu.id in (
             SELECT
@@ -155,6 +158,9 @@
         <if test="user.securitynumber!=null and user.securitynumber != ''">
             and securitynumber = #{user.securitynumber}
         </if>
+        <if test="user.examinationType!=null and user.examinationType != ''">
+            and examination_type = #{user.examinationType}
+        </if>
         <if test="deptIdList!=null and deptIdList.size>0">
             and id in (
             SELECT

--
Gitblit v1.9.3