From 767f8e4c5b8bdb9b87c7529fe01220f7fa3671b1 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Mon, 16 Aug 2021 21:52:17 +0800
Subject: [PATCH] 1.取消报名接口修改, 2.批量报名接口修改
---
src/main/java/org/springblade/modules/apply/controller/ApplyController.java | 128 +++++++++++++++++++++++++++++++++++-------
1 files changed, 106 insertions(+), 22 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 fa2658f..5e1b5b1 100644
--- a/src/main/java/org/springblade/modules/apply/controller/ApplyController.java
+++ b/src/main/java/org/springblade/modules/apply/controller/ApplyController.java
@@ -98,7 +98,7 @@
if (1==user.getIsApply()){
return R.data(201,"已报名,不能重复报名");
}
- if (2==user.getIsApply()){
+ if (2==user.getIsApply() || -1==user.getIsApply()){
//默认通过
apply.setApplyStatus(2);
//默认为未考试状态
@@ -379,7 +379,6 @@
public R cancelApply(@RequestBody Apply apply){
//查询人员是否已报名
User user = userService.getById(apply.getUserId());
- System.out.println("user = " + user);
if(null==user.getIsApply()){
apply.setApplyStatus(4);
boolean status = applyService.updateById(apply);
@@ -403,7 +402,44 @@
return R.data(200,"取消报名成功");
}
}
+ }
+ return R.data(202,"取消报名失败");
+ }
+
+ /**
+ * 公司报名列表取消报名,无applyId
+ * @param apply 考试报名信息对象
+ */
+ @PostMapping("/cancelApplyNotApplyId")
+ public R cancelApplyNotApplyId(@RequestBody Apply apply){
+ //查询人员是否已报名
+ User user = userService.getById(apply.getUserId());
+ //查询报名信息,取最新的一条(即当前userId,)applyId最大的一条记录
+ Apply apply1 = applyService.getMaxApplyIdByUserIdInfo(apply.getUserId());
+ if(null==user.getIsApply()){
+ apply1.setApplyStatus(4);
+ boolean status = applyService.updateById(apply1);
+ //修改保安报名状态
+ user.setIsApply(2);
+ userService.updateById(user);
+ if (status){
+ return R.data(200,"取消报名成功");
+ }
+ }else {
+ if (user.getIsApply()==2) {
+ return R.data(201,"尚未报名");
+ }
+ if(user.getIsApply()==1){
+ apply1.setApplyStatus(4);
+ boolean status = applyService.updateById(apply1);
+ //修改保安报名状态
+ user.setIsApply(2);
+ userService.updateById(user);
+ if (status){
+ return R.data(200,"取消报名成功");
+ }
+ }
}
return R.data(202,"取消报名失败");
}
@@ -411,27 +447,16 @@
/**
* 批量报名
- * @param apply 考试报名信息对象
+ * @param ids userIds 人员
*/
@PostMapping("/batchApply")
- public R batchApply(@RequestBody ApplyVO apply){
- List<String> list = Arrays.asList(apply.getUserIds().split(","));
- list.forEach(userId ->{
- User user = userService.getById(userId);
- //未报名的新增,已报名的不做处理
- if (null==user.getIsApply()) {
- Apply apply1 = new Apply();
- apply1.setApplyStatus(2);
- //默认为未考试状态
- apply1.setIsExam(1);
- apply1.setApplyTime(new Date());
- apply1.setUserId(Long.parseLong(userId));
- applyService.save(apply1);
- //修改保安报名状态
- user.setIsApply(1);
- userService.updateById(user);
- }else {
- if (user.getIsApply()==2) {
+ public R batchApply(@RequestParam String ids,@RequestParam String deptId){
+ if (!ids.equals("")) {
+ List<String> list = Arrays.asList(ids.split(","));
+ list.forEach(userId -> {
+ User user = userService.getById(userId);
+ //未报名的新增,已报名的不做处理
+ if (null == user.getIsApply()) {
Apply apply1 = new Apply();
apply1.setApplyStatus(2);
//默认为未考试状态
@@ -442,9 +467,56 @@
//修改保安报名状态
user.setIsApply(1);
userService.updateById(user);
+ } else {
+ if (user.getIsApply() == 2 || -1==user.getIsApply()) {
+ Apply apply1 = new Apply();
+ apply1.setApplyStatus(2);
+ //默认为未考试状态
+ apply1.setIsExam(1);
+ apply1.setApplyTime(new Date());
+ apply1.setUserId(Long.parseLong(userId));
+ applyService.save(apply1);
+ //修改保安报名状态
+ user.setIsApply(1);
+ userService.updateById(user);
+ }
}
+ });
+ }else {
+ //查询所有未报名的人员
+ List<User> users = userService.getNotApplyIdList(deptId);
+ System.out.println("users = " + users.size());
+ if (users.size()>0){
+ users.forEach(user ->{
+ //未报名的新增,已报名的不做处理
+ if (null == user.getIsApply()) {
+ Apply apply1 = new Apply();
+ apply1.setApplyStatus(2);
+ //默认为未考试状态
+ apply1.setIsExam(1);
+ apply1.setApplyTime(new Date());
+ apply1.setUserId(user.getId());
+ applyService.save(apply1);
+ //修改保安报名状态
+ user.setIsApply(1);
+ userService.updateById(user);
+ } else {
+ if (user.getIsApply() == 2 || -1==user.getIsApply()) {
+ Apply apply1 = new Apply();
+ apply1.setApplyStatus(2);
+ //默认为未考试状态
+ apply1.setIsExam(1);
+ apply1.setApplyTime(new Date());
+ apply1.setUserId(user.getId());
+ applyService.save(apply1);
+ //修改保安报名状态
+ user.setIsApply(1);
+ userService.updateById(user);
+ }
+ }
+ });
}
- });
+ }
return R.data(200,"报名成功");
}
@@ -540,4 +612,16 @@
return applyService.getSecurityApplyDetail(apply);
}
+
+ /**
+ * 修改考试状态
+ * @param apply 报名信息,包含userId,applyid
+ * @return
+ */
+ @PostMapping("/updateApplyStatus")
+ public void updateApplyStatus(@RequestBody ApplyVO apply){
+ applyService.updateApplyStatus(apply);
+ }
+
+
}
--
Gitblit v1.9.3