|
@@ -72,11 +72,16 @@ public class TBExamInvigilateUserController {
|
|
|
@Transactional
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
public Result save(@ApiJsonObject(name = "saveInvigilateUser", value = {
|
|
|
+ @ApiJsonProperty(key = "examId", type = "long", example = "1", description = "考试批次id", required = true),
|
|
|
@ApiJsonProperty(key = "roomCode", description = "考场代码"),
|
|
|
@ApiJsonProperty(key = "userIds", description = "用户id")
|
|
|
}) @ApiParam(value = "监考员信息", required = true) @RequestBody Map<String, Object> mapParameter) {
|
|
|
String roomCode = null;
|
|
|
try {
|
|
|
+ if (Objects.isNull(mapParameter.get("examId")) || Objects.equals(mapParameter.get("examId"), "")) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
|
|
|
+ }
|
|
|
+ Long examId = Long.parseLong(String.valueOf(mapParameter.get("examId")));
|
|
|
if (Objects.isNull(mapParameter.get("roomCode")) || Objects.equals(mapParameter.get("roomCode"), "")) {
|
|
|
throw new BusinessException(ExceptionResultEnum.ROOMCODE_IS_NULL);
|
|
|
}
|
|
@@ -88,20 +93,20 @@ public class TBExamInvigilateUserController {
|
|
|
if (userIds.size() > 3) {
|
|
|
throw new BusinessException(ExceptionResultEnum.ERROR.getStatusCode(), ExceptionResultEnum.ERROR.getCode(), "一个考场最多设置3名监考员");
|
|
|
}
|
|
|
- TBOrg tbOrg = (TBOrg) ServletUtil.getRequestOrg();
|
|
|
- QueryWrapper<TBExamInvigilateUser> tbExamInvigilateUserQueryWrapper = new QueryWrapper<>();
|
|
|
- tbExamInvigilateUserQueryWrapper.lambda().eq(TBExamInvigilateUser::getRoomCode, roomCode);
|
|
|
- if (Objects.nonNull(tbOrg) && Objects.isNull(tbOrg.getId())) {
|
|
|
- throw new BusinessException("监考员机构id不允许为空");
|
|
|
- }
|
|
|
- Long orgId = tbOrg.getId();
|
|
|
- List<TBExamInvigilateUser> tbExamInvigilateUserList = tbExamInvigilateUserService.list(tbExamInvigilateUserQueryWrapper);
|
|
|
- List<String> roomNameList = tbExamInvigilateUserList.stream().map(s -> s.getRoomName()).collect(Collectors.toList());
|
|
|
- tbExamInvigilateUserService.remove(tbExamInvigilateUserQueryWrapper);
|
|
|
if (userIds.size() > 0) {
|
|
|
+ TBOrg tbOrg = (TBOrg) ServletUtil.getRequestOrg();
|
|
|
+ QueryWrapper<TBExamInvigilateUser> tbExamInvigilateUserQueryWrapper = new QueryWrapper<>();
|
|
|
+ tbExamInvigilateUserQueryWrapper.lambda().eq(TBExamInvigilateUser::getRoomCode, roomCode);
|
|
|
+ if (Objects.nonNull(tbOrg) && Objects.isNull(tbOrg.getId())) {
|
|
|
+ throw new BusinessException("监考员机构id不允许为空");
|
|
|
+ }
|
|
|
+ List<TBExamInvigilateUser> tbExamInvigilateUserList = tbExamInvigilateUserService.list(tbExamInvigilateUserQueryWrapper);
|
|
|
+ Long orgId = tbOrg.getId();
|
|
|
+ List<String> roomNameList = tbExamInvigilateUserList.stream().map(s -> s.getRoomName()).collect(Collectors.toList());
|
|
|
+ tbExamInvigilateUserService.remove(tbExamInvigilateUserQueryWrapper);
|
|
|
tbExamInvigilateUserList = new ArrayList<>();
|
|
|
for (int i = 0; i < userIds.size(); i++) {
|
|
|
- TBExamInvigilateUser tbExamInvigilateUser = new TBExamInvigilateUser(orgId, Long.parseLong(userIds.get(i)), roomCode, roomNameList.get(0));
|
|
|
+ TBExamInvigilateUser tbExamInvigilateUser = new TBExamInvigilateUser(examId, orgId, Long.parseLong(userIds.get(i)), roomCode, roomNameList.get(0));
|
|
|
tbExamInvigilateUserList.add(tbExamInvigilateUser);
|
|
|
}
|
|
|
tbExamInvigilateUserService.saveBatch(tbExamInvigilateUserList);
|