Jelajahi Sumber

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamRoomStudentRelationServiceImpl.java
Joburgess 5 tahun lalu
induk
melakukan
b942a3082b
20 mengubah file dengan 228 tambahan dan 67 penghapusan
  1. 13 20
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/web/controller/UserController.java
  2. 1 1
      edu-im/edu-im-server/src/main/java/com/keao/edu/im/controller/RoomController.java
  3. 1 0
      edu-im/edu-im-server/src/main/java/com/keao/edu/im/dao/StudentAttendanceDao.java
  4. 1 0
      edu-im/edu-im-server/src/main/java/com/keao/edu/im/dao/TeacherAttendanceDao.java
  5. 103 18
      edu-im/edu-im-server/src/main/java/com/keao/edu/im/service/Impl/RoomServiceImpl.java
  6. 3 1
      edu-im/edu-im-server/src/main/java/com/keao/edu/im/service/RoomService.java
  7. 23 0
      edu-user/edu-user-client-api/src/main/java/com/keao/edu/user/api/client/EduUserFeignService.java
  8. 6 0
      edu-user/edu-user-client-api/src/main/java/com/keao/edu/user/api/client/fallback/EduUserFeignServiceFallback.java
  9. 2 2
      edu-user/edu-user-client-api/src/main/java/com/keao/edu/user/api/entity/ExamRoomStudentRelation.java
  10. 7 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamRoomStudentRelationController.java
  11. 2 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/SubjectController.java
  12. 10 2
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamRoomStudentRelationDao.java
  13. 1 1
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/dto/ExamRoomStudentRelationDto.java
  14. 14 3
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/entity/Subject.java
  15. 1 1
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/page/SubjectQueryInfo.java
  16. 10 1
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamRoomStudentRelationService.java
  17. 6 1
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamRoomStudentRelationServiceImpl.java
  18. 1 1
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/SubjectServiceImpl.java
  19. 7 4
      edu-user/edu-user-server/src/main/resources/config/mybatis/ExamRoomStudentRelationMapper.xml
  20. 16 11
      edu-user/edu-user-server/src/main/resources/config/mybatis/SubjectMapper.xml

+ 13 - 20
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/web/controller/UserController.java

@@ -1,24 +1,5 @@
 package com.keao.edu.auth.web.controller;
 
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-
-import java.util.Date;
-
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.MediaType;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
 import com.keao.edu.auth.api.dto.AuthUser;
 import com.keao.edu.auth.api.entity.SysUser;
 import com.keao.edu.auth.api.util.SecurityConstants;
@@ -34,6 +15,18 @@ import com.keao.edu.im.api.client.ImFeignService;
 import com.keao.edu.im.api.entity.ImResult;
 import com.keao.edu.im.api.entity.ImUserModel;
 import com.keao.edu.util.date.DateUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Date;
 
 @RestController()
 @RequestMapping("user")
@@ -222,7 +215,7 @@ public class UserController extends BaseController {
 	}
 
 	@ApiOperation(value = "修改用户")
-	@PostMapping(value = "/update", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
+	@PostMapping(value = "/update")
 	public Object update(SysUser sysUser) {
 		AuthUser user = SecurityUtils.getUser();
 		if (user != null) {

+ 1 - 1
edu-im/edu-im-server/src/main/java/com/keao/edu/im/controller/RoomController.java

@@ -44,7 +44,7 @@ public class RoomController{
     @RequestMapping(value = "/leave", method = RequestMethod.POST)
     public Object leaveRoom(@RequestBody ReqUserData data)
             throws ApiException, Exception {
-        boolean result = roomService.leaveRoom(data.getRoomId());
+        boolean result = roomService.leaveRoom(data.getRoomId(),data.getUserId());
         return new BaseResponse<>(result);
     }
 

+ 1 - 0
edu-im/edu-im-server/src/main/java/com/keao/edu/im/dao/StudentAttendanceDao.java

@@ -7,4 +7,5 @@ import org.springframework.stereotype.Repository;
 @Repository
 public interface StudentAttendanceDao extends JpaRepository<StudentAttendance, Long> {
 
+    StudentAttendance findByUserIdAndExaminationBasicIdAndExamRoomId(Integer userId,Integer basicId,Long roomId);
 }

+ 1 - 0
edu-im/edu-im-server/src/main/java/com/keao/edu/im/dao/TeacherAttendanceDao.java

@@ -8,4 +8,5 @@ import org.springframework.stereotype.Repository;
 @Repository
 public interface TeacherAttendanceDao extends JpaRepository<TeacherAttendance, Long> {
 
+    TeacherAttendance findByTeacherIdAndExaminationBasicIdAndExamRoomId(Integer teacherId,Integer basicId,Long roomId);
 }

+ 103 - 18
edu-im/edu-im-server/src/main/java/com/keao/edu/im/service/Impl/RoomServiceImpl.java

@@ -1,9 +1,8 @@
 package com.keao.edu.im.service.Impl;
 
-import com.keao.edu.user.api.client.EduUserFeignService;
 import com.keao.edu.auth.api.client.SysUserFeignService;
-import com.keao.edu.user.api.entity.ExamRoom;
 import com.keao.edu.auth.api.entity.SysUser;
+import com.keao.edu.common.enums.YesOrNoEnum;
 import com.keao.edu.common.exception.BizException;
 import com.keao.edu.im.common.ApiException;
 import com.keao.edu.im.common.ErrorEnum;
@@ -19,6 +18,9 @@ import com.keao.edu.im.utils.CodeUtil;
 import com.keao.edu.im.utils.DateTimeUtils;
 import com.keao.edu.im.utils.IdentifierUtils;
 import com.keao.edu.im.whiteboard.WhiteBoardHelper;
+import com.keao.edu.user.api.client.EduUserFeignService;
+import com.keao.edu.user.api.entity.ExamRoom;
+import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -29,6 +31,8 @@ import org.springframework.transaction.annotation.Transactional;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import static com.keao.edu.im.pojo.RoleEnum.Student;
+
 /**
  * Created by super_zou on 2019/11/28.
  */
@@ -115,7 +119,14 @@ public class RoomServiceImpl implements RoomService {
             }else if(isAssistant){
                 roleEnum = RoleEnum.AssistantTeacher;
             }else {
-                roleEnum = RoleEnum.Student;
+                ExamRoomStudentRelation examRoomStudentRelation = eduUserFeignService.getExamRoomStudentRelation(examRoom.getExaminationBasicId(), roomId, sysUser.getId());
+                if(examRoomStudentRelation == null){
+                    throw new BizException("学员考试数据异常");
+                }
+                if(examRoomStudentRelation.getClassroomSwitch() == YesOrNoEnum.NO){
+                    throw new BizException("考级入口已关闭");
+                }
+                roleEnum = Student;
             }
             saveRoomMember(userId,sysUser.getAvatar(), realName, roomId, roleEnum.getValue(), !isDisableCamera,!isMusicMode, curTime);
             IMApiResultInfo resultInfo = imHelper.joinGroup(new String[]{userId}, roomId, roomId);
@@ -130,6 +141,15 @@ public class RoomServiceImpl implements RoomService {
         } else {
             RoomMember roomMember = memberList.get(0);
             roleEnum = RoleEnum.getEnumByValue(roomMember.getRole());
+            if(roleEnum == Student){
+                ExamRoomStudentRelation examRoomStudentRelation = eduUserFeignService.getExamRoomStudentRelation(examRoom.getExaminationBasicId(), roomId, sysUser.getId());
+                if(examRoomStudentRelation == null){
+                    throw new BizException("学员考试数据异常");
+                }
+                if(examRoomStudentRelation.getClassroomSwitch() == YesOrNoEnum.NO){
+                    throw new BizException("考级入口已关闭");
+                }
+            }
 //            roomMemberDao.updateCameraByRidAndUid(roomId, userId, !isDisableCamera);
             userResult.setCamera(roomMember.isCamera());
             userResult.setHandUp(roomMember.isHand());
@@ -196,23 +216,82 @@ public class RoomServiceImpl implements RoomService {
             }
         }
         if(userId.equals(examRoom.getMainTeacherUserId()) || isAssistant){
+            TeacherAttendance attendance = teacherAttendanceDao.findByTeacherIdAndExaminationBasicIdAndExamRoomId(userId, examRoom.getExaminationBasicId(), examRoom.getId());
+            if(attendance != null){
+                return;
+            }
             TeacherAttendance teacherAttendance = new TeacherAttendance();
             teacherAttendance.setExamRoomId(examRoom.getId());
             teacherAttendance.setSignInTime(date);
             teacherAttendance.setTeacherId(userId);
             teacherAttendance.setTenantId(examRoom.getTenantId());
             teacherAttendance.setCreateTime(date);
+            teacherAttendance.setExaminationBasicId(examRoom.getExaminationBasicId());
             teacherAttendanceDao.save(teacherAttendance);
         }else {
+            StudentAttendance attendance = studentAttendanceDao.findByUserIdAndExaminationBasicIdAndExamRoomId(userId, examRoom.getExaminationBasicId(), examRoom.getId());
+            if(attendance != null){
+                return;
+            }
             StudentAttendance studentAttendance = new StudentAttendance();
             studentAttendance.setExamRoomId(examRoom.getId());
             studentAttendance.setSignInTime(date);
             studentAttendance.setUserId(userId);
             studentAttendance.setCreateTime(date);
+            studentAttendance.setExaminationBasicId(examRoom.getExaminationBasicId());
             studentAttendanceDao.save(studentAttendance);
         }
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
+    public void signOut(Long roomId) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        Integer userId = sysUser.getId();
+        log.info("roomSignIn: roomId={}, userId={}", roomId, userId);
+        ExamRoom examRoom = eduUserFeignService.getExamRoom(roomId.intValue());
+        Date date = new Date();
+        boolean isAssistant = false;
+        if (StringUtils.isNotEmpty(examRoom.getAssistantTeacherUserIdList())){
+            List<String> list = Arrays.asList(examRoom.getAssistantTeacherUserIdList().split(","));
+            if(list.contains(userId)){
+                isAssistant = true;
+            }
+        }
+        if(userId.equals(examRoom.getMainTeacherUserId()) || isAssistant){
+            TeacherAttendance attendance = teacherAttendanceDao.findByTeacherIdAndExaminationBasicIdAndExamRoomId(userId, examRoom.getExaminationBasicId(), examRoom.getId());
+            if(attendance == null){
+                attendance = new TeacherAttendance();
+                attendance.setExamRoomId(examRoom.getId());
+                attendance.setSignInTime(date);
+                attendance.setSignOutTime(date);
+                attendance.setTeacherId(userId);
+                attendance.setTenantId(examRoom.getTenantId());
+                attendance.setCreateTime(date);
+                attendance.setExaminationBasicId(examRoom.getExaminationBasicId());
+                teacherAttendanceDao.save(attendance);
+            }else {
+                attendance.setSignOutTime(date);
+                teacherAttendanceDao.saveAndFlush(attendance);
+            }
+        }else {
+            StudentAttendance attendance = studentAttendanceDao.findByUserIdAndExaminationBasicIdAndExamRoomId(userId, examRoom.getExaminationBasicId(), examRoom.getId());
+            if(attendance == null){
+                attendance = new StudentAttendance();
+                attendance.setExamRoomId(examRoom.getId());
+                attendance.setSignInTime(date);
+                attendance.setSignOutTime(date);
+                attendance.setUserId(userId);
+                attendance.setCreateTime(date);
+                attendance.setExaminationBasicId(examRoom.getExaminationBasicId());
+                studentAttendanceDao.save(attendance);
+            }else {
+                attendance.setSignOutTime(date);
+                studentAttendanceDao.saveAndFlush(attendance);
+            }
+        }
+    }
+
     private void saveRoom(String roomId, String roomName, Date createTime, String display) {
         Room room = new Room();
         room.setRid(roomId);
@@ -242,12 +321,17 @@ public class RoomServiceImpl implements RoomService {
 
     @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
     @Override
-    public Boolean leaveRoom(String roomId){
-        SysUser user = sysUserFeignService.queryUserInfo();
-        String userId = user.getId().toString();
+    public Boolean leaveRoom(String roomId,String userId){
+        SysUser user = null;
+        if(StringUtils.isEmpty(userId)){
+            user = sysUserFeignService.queryUserInfo();
+            userId = user.getId().toString();
+        }else {
+            user = sysUserFeignService.queryUserById(Integer.parseInt(userId));
+        }
         log.info("leaveRoom: roomId={}, userId={}", roomId,userId);
 
-        CheckUtils.checkArgument(user != null, "user must't be null");
+        CheckUtils.checkArgument(userId != null, "userId must't be null");
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
         List<Room> roomList = roomDao.findByRid(roomId);
         if (roomList.size() == 0) {
@@ -313,6 +397,7 @@ public class RoomServiceImpl implements RoomService {
             }
         }
         userDao.deleteByUid(userId);
+        this.signOut(Long.parseLong(roomId));
         return true;
     }
 
@@ -381,7 +466,7 @@ public class RoomServiceImpl implements RoomService {
                         log.info("change the role: {}, {}, {}, result: {}", roomId, userId, changedRole, r);
                         result = true;
                     }*/
-                    if (oldUsers.get(0).getRole() != RoleEnum.Student.getValue() && isUserDisplay(roomList.get(0), oldUsers.get(0).getUid())) {
+                    if (oldUsers.get(0).getRole() != Student.getValue() && isUserDisplay(roomList.get(0), oldUsers.get(0).getUid())) {
                         updateDisplay(roomId, userId, "", 1);
                     } else {
                         log.info("don't update display: room={}, userRole={}", roomList.get(0), RoleEnum.getEnumByValue(oldUsers.get(0).getRole()));
@@ -424,7 +509,7 @@ public class RoomServiceImpl implements RoomService {
             Thread.sleep(50);
             log.info("published msg: msg={}", msg);
             List<Room> roomList = roomDao.findByRid(roomId);
-            if (kickedUsers.get(0).getRole() != RoleEnum.Student.getValue() && isUserDisplay(roomList.get(0), userId)) {
+            if (kickedUsers.get(0).getRole() != Student.getValue() && isUserDisplay(roomList.get(0), userId)) {
                 updateDisplay(roomId, userId, "", 1);
             } else {
                 log.info("don't update display: room={}, userRole={}", roomId, RoleEnum.getEnumByValue(kickedUsers.get(0).getRole()));
@@ -671,7 +756,7 @@ public class RoomServiceImpl implements RoomService {
                 roomMembers.add(new RoomMember(split[i]));
             }
         }else {
-            roomMembers = roomMemberDao.findByRidAndRole(data.getRoomId(),RoleEnum.Student.getValue());
+            roomMembers = roomMemberDao.findByRidAndRole(data.getRoomId(), Student.getValue());
         }
         if(roomMembers.size() == 0){
             return false;
@@ -823,7 +908,7 @@ public class RoomServiceImpl implements RoomService {
 
         ScheduledTaskInfo taskInfo = scheduleManager.executeTask(ticket);
         log.info("approveSpeech: task = {}", taskInfo);
-        roomMemberDao.updateRoleByRidAndUid(roomId, taskInfo.getApplyUserId(), RoleEnum.Student.getValue());
+        roomMemberDao.updateRoleByRidAndUid(roomId, taskInfo.getApplyUserId(), Student.getValue());
 
         SpeechResultMessage msg = new SpeechResultMessage(SpeechResultMessage.Action_Approve);
         List<UserInfo> userInfoList = userDao.findByUid(taskInfo.getApplyUserId());
@@ -833,7 +918,7 @@ public class RoomServiceImpl implements RoomService {
         if (!userInfoList.isEmpty()) {
             msg.setReqUserName(userInfoList.get(0).getName());
         }
-        msg.setRole(RoleEnum.Student.getValue());
+        msg.setRole(Student.getValue());
         IMApiResultInfo resultInfo = imHelper.publishMessage(userId, taskInfo.getApplyUserId(), roomId, msg);
         if (!resultInfo.isSuccess()) {
             throw new ApiException(ErrorEnum.ERR_MESSAGE_ERROR, resultInfo.getErrorMessage());
@@ -841,7 +926,7 @@ public class RoomServiceImpl implements RoomService {
 
         RoleChangedMessage rcMsg = new RoleChangedMessage(userId);
         List<RoleChangedMessage.ChangedUser> changedUserList = new ArrayList<>();
-        RoleChangedMessage.ChangedUser user = new RoleChangedMessage.ChangedUser(taskInfo.getApplyUserId(), RoleEnum.Student.getValue());
+        RoleChangedMessage.ChangedUser user = new RoleChangedMessage.ChangedUser(taskInfo.getApplyUserId(), Student.getValue());
         if (!userInfoList.isEmpty()) {
             user.setUserName(userInfoList.get(0).getName());
         }
@@ -864,7 +949,7 @@ public class RoomServiceImpl implements RoomService {
         SpeechResultMessage msg = new SpeechResultMessage(SpeechResultMessage.Action_Reject);
         msg.setOpUserId(userId);
         msg.setOpUserName(authUser.getUsername());
-        msg.setRole(RoleEnum.Student.getValue());
+        msg.setRole(Student.getValue());
         IMApiResultInfo resultInfo = imHelper.publishMessage(userId, taskInfo.getApplyUserId(), roomId, msg);
         if (resultInfo.isSuccess()) {
             return true;
@@ -910,7 +995,7 @@ public class RoomServiceImpl implements RoomService {
             log.info("don't update display: room={}", roomList.get(0));
         }
 
-        roomMemberDao.updateRoleByRidAndUid(roomId, userId, RoleEnum.Student.getValue());
+        roomMemberDao.updateRoleByRidAndUid(roomId, userId, Student.getValue());
 //        roomMemberDao.updateRoleByRidAndUid(roomId, userId, RoleEnum.RoleAssistant.getValue());
 
         AssistantTransferMessage msg = new AssistantTransferMessage();
@@ -1040,7 +1125,7 @@ public class RoomServiceImpl implements RoomService {
         if (targetUser.isEmpty()) {
             throw new ApiException(ErrorEnum.ERR_USER_NOT_EXIST_IN_ROOM);
         } else {
-            if (!RoleEnum.getEnumByValue(targetUser.get(0).getRole()).equals(RoleEnum.Student)) {
+            if (!RoleEnum.getEnumByValue(targetUser.get(0).getRole()).equals(Student)) {
                 log.error("change role error: targetUserId={}, targetRole = {}", targetUser, RoleEnum.getEnumByValue(targetRole));
                 throw new ApiException(ErrorEnum.ERR_CHANGE_ROLE);
             }
@@ -1052,8 +1137,8 @@ public class RoomServiceImpl implements RoomService {
 
         List<RoomMember> teachers = roomMemberDao.findByRidAndRole(roomId, RoleEnum.MainTeacher.getValue());
         if (!teachers.isEmpty()) {
-            roomMemberDao.updateRoleByRidAndUid(roomId, teachers.get(0).getUid(), RoleEnum.Student.getValue());
-            RoleChangedMessage.ChangedUser user = new RoleChangedMessage.ChangedUser(teachers.get(0).getUid(), RoleEnum.Student.getValue());
+            roomMemberDao.updateRoleByRidAndUid(roomId, teachers.get(0).getUid(), Student.getValue());
+            RoleChangedMessage.ChangedUser user = new RoleChangedMessage.ChangedUser(teachers.get(0).getUid(), Student.getValue());
             List<UserInfo> userInfoList = userDao.findByUid(teachers.get(0).getUid());
             if (!userInfoList.isEmpty()) {
                 user.setUserName(userInfoList.get(0).getName());

+ 3 - 1
edu-im/edu-im-server/src/main/java/com/keao/edu/im/service/RoomService.java

@@ -19,7 +19,9 @@ public interface RoomService {
 
     void signIn(Long roomId);
 
-    public Boolean leaveRoom(String roomId) throws ApiException, Exception;
+    void signOut(Long roomId);
+
+    public Boolean leaveRoom(String roomId,String userId) throws ApiException, Exception;
 
     //only host
     public Boolean downgrade(String roomId, List<ReqChangeUserRoleData.ChangedUser> users) throws ApiException, Exception;

+ 23 - 0
edu-user/edu-user-client-api/src/main/java/com/keao/edu/user/api/client/EduUserFeignService.java

@@ -1,18 +1,41 @@
 package com.keao.edu.user.api.client;
 
 
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.keao.edu.common.config.FeignConfiguration;
 import com.keao.edu.user.api.client.fallback.EduUserFeignServiceFallback;
 import com.keao.edu.user.api.entity.ExamRoom;
+import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.*;
 
 @FeignClient(contextId = "eduUserFeignService", name = "user-server", configuration = { FeignConfiguration.class }, fallback = EduUserFeignServiceFallback.class)
 public interface EduUserFeignService {
 
+	/**
+	 * 获取考场信息
+	 * @param id
+	 * @return
+	 */
 	@GetMapping(value = "examRoom/get")
 	ExamRoom getExamRoom(@RequestParam("id") Integer id);
 
+	/**
+	 * 学生报名
+	 * @param organId
+	 * @param phone
+	 * @return
+	 */
 	@PostMapping(value = "student/apply")
 	Object studentApply(@RequestParam("organId") Integer organId, @RequestParam("phone") String phone);
+
+	/**
+	 * 获取考场与学生关联
+	 * @param basicId
+	 * @param roomId
+	 * @param studentId
+	 * @return
+	 */
+	@GetMapping(value = "roomStudentRelation/get")
+	ExamRoomStudentRelation getExamRoomStudentRelation(@RequestParam("basicId") Integer basicId, @RequestParam("roomId") String roomId, @RequestParam("studentId") Integer studentId);
 }

+ 6 - 0
edu-user/edu-user-client-api/src/main/java/com/keao/edu/user/api/client/fallback/EduUserFeignServiceFallback.java

@@ -2,6 +2,7 @@ package com.keao.edu.user.api.client.fallback;
 
 import com.keao.edu.user.api.client.EduUserFeignService;
 import com.keao.edu.user.api.entity.ExamRoom;
+import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
 import com.keao.edu.user.api.entity.Student;
 import org.springframework.stereotype.Component;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -19,4 +20,9 @@ public class EduUserFeignServiceFallback implements EduUserFeignService {
 		return null;
 	}
 
+	@Override
+	public ExamRoomStudentRelation getExamRoomStudentRelation(Integer basicId, String roomId, Integer studentId) {
+		return null;
+	}
+
 }

+ 2 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/entity/ExamRoomStudentRelation.java → edu-user/edu-user-client-api/src/main/java/com/keao/edu/user/api/entity/ExamRoomStudentRelation.java

@@ -1,6 +1,6 @@
-package com.keao.edu.user.entity;
+package com.keao.edu.user.api.entity;
 
-import com.keao.edu.user.enums.YesOrNoEnum;
+import com.keao.edu.common.enums.YesOrNoEnum;
 import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 

+ 7 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamRoomStudentRelationController.java

@@ -5,6 +5,7 @@ import com.keao.edu.auth.api.entity.SysUser;
 import com.keao.edu.common.controller.BaseController;
 import com.keao.edu.common.entity.HttpResponseResult;
 import com.keao.edu.common.page.PageInfo;
+import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
 import com.keao.edu.user.dto.ExamRoomStudentRelationDto;
 import com.keao.edu.user.page.ExamRoomStudentRelationQueryInfo;
 import com.keao.edu.user.service.ExamRoomStudentRelationService;
@@ -33,6 +34,12 @@ public class ExamRoomStudentRelationController extends BaseController {
         return succeed();
     }
 
+    @ApiOperation("获取教室学员关联")
+    @GetMapping(value = "/getExamRoomStudentRelation")
+    public ExamRoomStudentRelation getExamRoomStudentRelation(Integer basicId, String roomId, Integer studentId) {
+        return examRoomStudentRelationService.getExamRoomStudentRelation(basicId,roomId,studentId);
+    }
+
     @ApiOperation("给教室分配学员")
     @PostMapping(value = "/addStudentForRoom")
     public HttpResponseResult addStudentForRoom(Long examRoomId, String studentIds){

+ 2 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/SubjectController.java

@@ -4,6 +4,7 @@ package com.keao.edu.user.controller;
 import com.keao.edu.common.controller.BaseController;
 import com.keao.edu.common.entity.HttpResponseResult;
 import com.keao.edu.common.page.PageInfo;
+import com.keao.edu.common.tenant.TenantContextHolder;
 import com.keao.edu.user.entity.Subject;
 import com.keao.edu.user.page.SubjectQueryInfo;
 import com.keao.edu.user.service.SubjectService;
@@ -28,6 +29,7 @@ public class SubjectController extends BaseController {
     @PostMapping("/upset")
     @PreAuthorize("@pcs.hasPermissions('subject/upset')")
     public HttpResponseResult update(@RequestBody Subject subject){
+        subject.setTenantId(TenantContextHolder.getTenantId().toString());
         subjectService.upSetSubject(subject);
         return succeed();
     }

+ 10 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamRoomStudentRelationDao.java

@@ -2,7 +2,7 @@ package com.keao.edu.user.dao;
 
 import com.keao.edu.common.dal.BaseDAO;
 import com.keao.edu.user.dto.ExamRoomStudentRelationDto;
-import com.keao.edu.user.entity.ExamRoomStudentRelation;
+import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -28,7 +28,7 @@ public interface ExamRoomStudentRelationDao extends BaseDAO<Long, ExamRoomStuden
      * @author Joburgess
      * @date 2020.06.24
      * @param examRoomId:
-     * @return java.util.List<com.keao.edu.user.entity.ExamRoomStudentRelation>
+     * @return java.util.List<com.keao.edu.user.api.entity.ExamRoomStudentRelation>
      */
     List<ExamRoomStudentRelation> findStudentsWithExamRoom(@Param("examRoomId") Long examRoomId);
 
@@ -52,4 +52,12 @@ public interface ExamRoomStudentRelationDao extends BaseDAO<Long, ExamRoomStuden
      */
     int deleteWithExamRooms(@Param("examRoomIds") List<Long> examRoomIds);
 
+    /**
+     * 获取教室学员关联
+     * @param basicId
+     * @param roomId
+     * @param studentId
+     * @return
+     */
+    ExamRoomStudentRelation getExamRoomStudentRelation(@Param("basicId") Integer basicId, @Param("roomId") String roomId, @Param("studentId") Integer studentId);
 }

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dto/ExamRoomStudentRelationDto.java

@@ -2,7 +2,7 @@ package com.keao.edu.user.dto;
 
 import com.keao.edu.auth.api.entity.SysUser;
 import com.keao.edu.user.entity.ExamRegistration;
-import com.keao.edu.user.entity.ExamRoomStudentRelation;
+import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
 import com.keao.edu.user.entity.Subject;
 import io.swagger.annotations.ApiModelProperty;
 

+ 14 - 3
edu-user/edu-user-server/src/main/java/com/keao/edu/user/entity/Subject.java

@@ -23,6 +23,9 @@ public class Subject {
 	@ApiModelProperty(value = "父级",required = false)
 	private Integer parentSubjectId;
 
+	@ApiModelProperty(value = "父级名称",required = false)
+	private String parentName;
+
 	@ApiModelProperty(value = "图片",required = false)
 	private String img;
 
@@ -31,13 +34,21 @@ public class Subject {
 	private java.util.Date updateTime;
 
 	@ApiModelProperty(value = "是否删除",required = false)
-	private YesOrNoEnum delFlag;
+	private Boolean delFlag;
 
 	@ApiModelProperty(value = "子节点列表",required = false)
 	private List<Subject> subjects;
 
 	private String tenantId;
 
+	public String getParentName() {
+		return parentName;
+	}
+
+	public void setParentName(String parentName) {
+		this.parentName = parentName;
+	}
+
 	public Subject() {
 	}
 
@@ -118,11 +129,11 @@ public class Subject {
 		return this.updateTime;
 	}
 
-	public YesOrNoEnum getDelFlag() {
+	public Boolean getDelFlag() {
 		return delFlag;
 	}
 
-	public void setDelFlag(YesOrNoEnum delFlag) {
+	public void setDelFlag(Boolean delFlag) {
 		this.delFlag = delFlag;
 	}
 

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/page/SubjectQueryInfo.java

@@ -7,7 +7,7 @@ import io.swagger.annotations.ApiModelProperty;
 
 public class SubjectQueryInfo extends QueryInfo {
     @ApiModelProperty(value = "父节点编号,默认0",required = false)
-    private Integer parentId = 0;
+    private Integer parentId;
 
     @ApiModelProperty(value = "节点状态,默认0未删除,1删除",required = false)
     private YesOrNoEnum delFlag = YesOrNoEnum.NO;

+ 10 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamRoomStudentRelationService.java

@@ -3,7 +3,7 @@ package com.keao.edu.user.service;
 import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.service.BaseService;
 import com.keao.edu.user.dto.ExamRoomStudentRelationDto;
-import com.keao.edu.user.entity.ExamRoomStudentRelation;
+import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
 import com.keao.edu.user.page.ExamRoomStudentRelationQueryInfo;
 
 public interface ExamRoomStudentRelationService extends BaseService<Long, ExamRoomStudentRelation> {
@@ -44,4 +44,13 @@ public interface ExamRoomStudentRelationService extends BaseService<Long, ExamRo
      * @return void
      */
     void deleteStudentFromRoom(Long examRoomId, String studentIds);
+
+    /**
+     * 获取教室学员关联
+     * @param basicId
+     * @param roomId
+     * @param studentId
+     * @return
+     */
+    ExamRoomStudentRelation getExamRoomStudentRelation(Integer basicId, String roomId, Integer studentId);
 }

+ 6 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamRoomStudentRelationServiceImpl.java

@@ -11,7 +11,7 @@ import com.keao.edu.user.dao.ExamRoomDao;
 import com.keao.edu.user.dao.ExamRoomStudentRelationDao;
 import com.keao.edu.user.dao.StudentExamResultDao;
 import com.keao.edu.user.dto.ExamRoomStudentRelationDto;
-import com.keao.edu.user.entity.ExamRoomStudentRelation;
+import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
 import com.keao.edu.user.entity.StudentExamResult;
 import com.keao.edu.user.entity.Subject;
 import com.keao.edu.user.page.ExamRoomStudentRelationQueryInfo;
@@ -131,4 +131,9 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 		List<Integer> studentIds = Arrays.asList(studentIdsStr.split(",")).stream().map(e -> Integer.valueOf(e)).collect(Collectors.toList());
 		examRoomStudentRelationDao.deleteStudentsFromExamRoom(examRoomId, studentIds);
 	}
+
+	@Override
+	public ExamRoomStudentRelation getExamRoomStudentRelation(Integer basicId, String roomId, Integer studentId) {
+		return examRoomStudentRelationDao.getExamRoomStudentRelation(basicId,roomId,studentId);
+	}
 }

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/SubjectServiceImpl.java

@@ -38,7 +38,7 @@ public class SubjectServiceImpl extends BaseServiceImpl<Integer, Subject> implem
 
     @Override
     public void upSetSubject(Subject subject) {
-        if(subject.getDelFlag() == YesOrNoEnum.YES){
+        if(subject.getDelFlag() != null && subject.getDelFlag() == true){
             subjectDao.delete(subject.getId());
             return;
         }

+ 7 - 4
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamRoomStudentRelationMapper.xml

@@ -6,7 +6,7 @@
 -->
 <mapper namespace="com.keao.edu.user.dao.ExamRoomStudentRelationDao">
 	
-	<resultMap type="com.keao.edu.user.entity.ExamRoomStudentRelation" id="ExamRoomStudentRelation">
+	<resultMap type="com.keao.edu.user.api.entity.ExamRoomStudentRelation" id="ExamRoomStudentRelation">
 		<result column="id_" property="id" />
 		<result column="examination_basic_id_" property="examinationBasicId" />
 		<result column="exam_room_id_" property="examRoomId" />
@@ -34,12 +34,12 @@
 	</select>
 	
 	<!-- 向数据库增加一条记录 -->
-	<insert id="insert" parameterType="com.keao.edu.user.entity.ExamRoomStudentRelation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+	<insert id="insert" parameterType="com.keao.edu.user.api.entity.ExamRoomStudentRelation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 		INSERT INTO exam_room_student_relation (id_,examination_basic_id_,exam_room_id_,student_id_,create_time_,update_time_,tenant_id_)
 		VALUES(#{id},#{examinationBasicId},#{examRoomId},#{studentId},NOW(),NOW(),#{tenantId})
 	</insert>
 
-	<insert id="batchInsert" parameterType="com.keao.edu.user.entity.ExamRoomStudentRelation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+	<insert id="batchInsert" parameterType="com.keao.edu.user.api.entity.ExamRoomStudentRelation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 		INSERT INTO exam_room_student_relation (examination_basic_id_,exam_room_id_,student_id_,create_time_,update_time_,tenant_id_)
 		VALUES
 		<foreach collection="roomStudents" item="roomStudent" separator=",">
@@ -48,7 +48,7 @@
 	</insert>
 	
 	<!-- 根据主键查询一条记录 -->
-	<update id="update" parameterType="com.keao.edu.user.entity.ExamRoomStudentRelation">
+	<update id="update" parameterType="com.keao.edu.user.api.entity.ExamRoomStudentRelation">
 		UPDATE exam_room_student_relation
 		<set>
 			<if test="examinationBasicId != null">
@@ -151,4 +151,7 @@
 	<select id="findStudentsWithExamRoom" resultMap="ExamRoomStudentRelation">
 		SELECT id_, examination_basic_id_, exam_room_id_, student_id_ FROM exam_room_student_relation WHERE exam_room_id_=#{examRoomId}
 	</select>
+	<select id="getExamRoomStudentRelation" resultMap="ExamRoomStudentRelation">
+		SELECT * FROM exam_room_student_relation WHERE exam_room_id_ = #{roomId} AND examination_basic_id_ = #{basicId} AND student_id_ = #{studentId} LIMIT 1
+	</select>
 </mapper>

+ 16 - 11
edu-user/edu-user-server/src/main/resources/config/mybatis/SubjectMapper.xml

@@ -11,10 +11,11 @@
         <result column="name_" property="name"/>
         <result column="code_" property="code"/>
         <result column="parent_subject_id_" property="parentSubjectId"/>
+        <result column="parent_name_" property="parentName"/>
         <result column="img_" property="img"/>
         <result column="create_time_" property="createTime"/>
         <result column="update_time_" property="updateTime"/>
-        <result column="del_flag_" property="delFlag" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler"/>
+        <result column="del_flag_" property="delFlag"/>
         <result column="tenant_id_" property="tenantId"/>
     </resultMap>
 
@@ -31,8 +32,8 @@
     <!-- 向数据库增加一条记录 -->
     <insert id="insert" parameterType="com.keao.edu.user.entity.Subject" useGeneratedKeys="true" keyColumn="id"
             keyProperty="id">
-        INSERT INTO subject (id_,name_,code_,parent_subject_id_,img_,create_time_,update_time_,tenant_id_,tenant_id_)
-        VALUES(#{id},#{name},#{code},#{parentSubjectId},#{img},now(),now(),#{tenantId},#{tenantId})
+        INSERT INTO subject (id_,name_,code_,parent_subject_id_,img_,create_time_,update_time_,tenant_id_)
+        VALUES(#{id},#{name},#{code},#{parentSubjectId},#{img},now(),now(),#{tenantId})
     </insert>
 
     <!-- 根据主键查询一条记录 -->
@@ -40,7 +41,7 @@
         UPDATE subject
         <set>
             <if test="delFlag != null">
-                del_flag_ = #{delFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
+                del_flag_ = #{delFlag},
             </if>
             <if test="parentSubjectId != null">
                 parent_subject_id_ = #{parentSubjectId},
@@ -71,15 +72,16 @@
 
     <!-- 分页查询 -->
     <select id="queryPage" resultMap="Subject" parameterType="map">
-        SELECT * FROM subject
+        SELECT s.*,sp.name_ parent_name_ FROM subject s
+        LEFT JOIN `subject` sp ON s.parent_subject_id_ = sp.id_
         <include refid="querySubPageSql"/>
-        ORDER BY id_
+        ORDER BY s.id_
         <include refid="global.limit"/>
     </select>
 
     <!-- 查询当前表的总记录数 -->
     <select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM subject <include refid="querySubPageSql"/>
+		SELECT COUNT(*) FROM subject s <include refid="querySubPageSql"/>
 	</select>
 
     <select id="findByParentId" resultMap="Subject">
@@ -104,15 +106,18 @@
 
     <sql id="querySubPageSql">
         <where>
-            tenant_id_ = #{tenantId}
+            s.tenant_id_ = #{tenantId}
             <if test="parentId != null">
-                AND parent_subject_id_ = #{parentId}
+                AND s.parent_subject_id_ = #{parentId}
+            </if>
+            <if test="parentId == null">
+                AND s.parent_subject_id_ != 0
             </if>
             <if test="tenantId != null">
-                AND tenant_id_ = #{tenantId}
+                AND s.tenant_id_ = #{tenantId}
             </if>
             <if test="delFlag != null">
-                AND del_flag_ = #{delFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}
+                AND s.del_flag_ = #{delFlag}
             </if>
         </where>
     </sql>