wangliang hace 4 años
padre
commit
db38af7334

+ 16 - 11
themis-backend/src/main/java/com/qmth/themis/backend/api/TBExamInvigilateUserController.java

@@ -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);

+ 3 - 2
themis-backend/src/main/java/com/qmth/themis/backend/api/TBUserController.java

@@ -576,6 +576,7 @@ public class TBUserController {
         if (Objects.isNull(mapParameter.get("orgId"))) {
             throw new BusinessException(ExceptionResultEnum.ORG_ID_IS_NULL);
         }
+        TBUser loginUser = (TBUser) ServletUtil.getRequestAccount();
         Long orgId = Long.parseLong(String.valueOf(mapParameter.get("orgId")));
         try {
             Gson gson = new Gson();
@@ -588,7 +589,7 @@ public class TBUserController {
             if (Objects.isNull(tbUser.getId())) {
                 tbUser.setId(Constants.idGen.next());
                 tbUser.setOrgId(orgId);
-                tbUser.setCreateId(tbUser.getId());
+                tbUser.setCreateId(loginUser.getId());
                 if (Objects.nonNull(roleSet) && roleSet.size() > 0) {
                     TBUser finalTbUser = tbUser;
                     roleSet.forEach(s -> {
@@ -607,7 +608,7 @@ public class TBUserController {
                         tbUserRoleService.save(tbUserRole);
                     });
                 }
-                tbUser.setUpdateId(tbUser.getId());
+                tbUser.setUpdateId(loginUser.getId());
             }
             tbUserService.saveOrUpdate(tbUser);
         } catch (Exception e) {

+ 7 - 6
themis-business/src/main/java/com/qmth/themis/business/entity/TBExamInvigilateUser.java

@@ -1,5 +1,6 @@
 package com.qmth.themis.business.entity;
 
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.qmth.themis.business.enums.InvigilateMonitorStatusEnum;
@@ -25,27 +26,27 @@ public class TBExamInvigilateUser implements Serializable {
     private Long id;
 
     @ApiModelProperty(value = "考试批次ID")
-    @TableField("exam_id")
+    @TableField(value = "exam_id")
     private Long examId;
 
     @ApiModelProperty(value = "机构ID")
-    @TableField("org_id")
+    @TableField(value = "org_id")
     private Long orgId;
 
     @ApiModelProperty(value = "用户ID")
-    @TableField("user_id")
+    @TableField(value = "user_id", updateStrategy = FieldStrategy.IGNORED)
     private Long userId;
 
     @ApiModelProperty(value = "考场代码")
-    @TableField("room_code")
+    @TableField(value = "room_code")
     private String roomCode;
 
     @ApiModelProperty(value = "考场名称")
-    @TableField("room_name")
+    @TableField(value = "room_name")
     private String roomName;
 
     @ApiModelProperty(value = "监考状态,NOT_START:未开始,START:监考中,FINISHED:已结束")
-    @TableField("monitor_status")
+    @TableField(value = "monitor_status")
     private InvigilateMonitorStatusEnum monitorStatus;
 
     public TBExamInvigilateUser() {

+ 1 - 0
themis-business/src/main/resources/db/init.sql

@@ -777,6 +777,7 @@ CREATE TABLE `t_b_user` (
   `create_id` bigint DEFAULT NULL COMMENT '创建人id',
   `update_id` bigint DEFAULT NULL COMMENT '更新人id',
   PRIMARY KEY (`id`)
+  UNIQUE KEY `t_b_user_loginName_orgId_Idx` (`login_name`,`org_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户';
 
 -- ----------------------------

+ 2 - 2
themis-business/src/main/resources/mapper/TBUserMapper.xml

@@ -26,13 +26,13 @@
             where
             t.id = tbu.org_id) as orgName,(
             select
-            tbu.name
+            t.name
             from
             t_b_user t
             where
             t.id = tbu.create_id) as createName, tbu.create_time as createTime, (
             select
-            tbu.name
+            t.name
             from
             t_b_user t
             where