创建考试时的权限校验逻辑修改

This commit is contained in:
thesai 2021-01-12 20:47:35 +08:00
parent 02078eb039
commit 0faa785f90
3 changed files with 11 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import club.joylink.rtss.dao.*;
import club.joylink.rtss.entity.*; import club.joylink.rtss.entity.*;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.training.ITrainingV1Service; import club.joylink.rtss.services.training.ITrainingV1Service;
import club.joylink.rtss.simulation.cbtc.GroupSimulationService;
import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.UserVO;
import club.joylink.rtss.vo.client.*; import club.joylink.rtss.vo.client.*;
import club.joylink.rtss.vo.client.training.TrainingResultVO; import club.joylink.rtss.vo.client.training.TrainingResultVO;
@ -50,6 +51,9 @@ public class UserExamService implements IUserExamService {
@Autowired @Autowired
private LsLessonDAO lessonDAO; private LsLessonDAO lessonDAO;
@Autowired
private GroupSimulationService groupSimulationService;
@Override @Override
@Transactional @Transactional
public UserExamVO generateExamInstance(long examId, UserVO userVO) { public UserExamVO generateExamInstance(long examId, UserVO userVO) {
@ -63,8 +67,9 @@ public class UserExamService implements IUserExamService {
calendar.setTime(new Date()); calendar.setTime(new Date());
calendar.add(Calendar.SECOND, examDef.getDuration()); calendar.add(Calendar.SECOND, examDef.getDuration());
LsLesson lesson = this.lessonDAO.selectByPrimaryKey(examDef.getLessonId()); LsLesson lesson = this.lessonDAO.selectByPrimaryKey(examDef.getLessonId());
List<UserPermissionVO> examPermission = iUserPermissionService.getExamUserPermission(userVO, lesson.getMapId(), lesson.getPrdType(), lesson.getId()); groupSimulationService.confirmHasPermission(userVO, lesson.getMapId(), lesson.getPrdType());
BusinessExceptionAssertEnum.SIMULATION_PERMISSION_NOT_AVAILABLE.assertCollectionNotEmpty(examPermission); // List<UserPermissionVO> examPermission = iUserPermissionService.getExamUserPermission(userVO, lesson.getMapId(), lesson.getPrdType(), lesson.getId());
// BusinessExceptionAssertEnum.SIMULATION_PERMISSION_NOT_AVAILABLE.assertCollectionNotEmpty(examPermission);
} }
// 判断是否在考试时间之内 // 判断是否在考试时间之内
if (examDef.getStartTime() != null) { if (examDef.getStartTime() != null) {

View File

@ -276,5 +276,7 @@ public interface GroupSimulationService {
void changePassengerFlow(String group, Long passengerFlowId); void changePassengerFlow(String group, Long passengerFlowId);
void confirmHasPermission(UserVO userVO, Long mapId, String prdType);
boolean hasPermission(UserVO userVO, Long mapId, String prdType); boolean hasPermission(UserVO userVO, Long mapId, String prdType);
} }

View File

@ -952,7 +952,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
/** /**
* 确认该用户有权限进入该仿真 * 确认该用户有权限进入该仿真
*/ */
private void confirmHasPermission(UserVO userVO, Long mapId, String prdType) { @Override
public void confirmHasPermission(UserVO userVO, Long mapId, String prdType) {
BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertTrue(hasPermission(userVO, mapId, prdType)); BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertTrue(hasPermission(userVO, mapId, prdType));
} }